Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd70df2c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix bug in DemuxResource allocation logic" into main

parents c06e875c 251f22a3
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -1454,6 +1454,7 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        boolean hasDesiredDemuxCap = request.desiredFilterTypes
                != DemuxFilterMainType.UNDEFINED;
        int smallestNumOfSupportedCaps = Integer.SIZE + 1;
        int smallestNumOfSupportedCapsInUse = Integer.SIZE + 1;
        for (DemuxResource dr : getDemuxResources().values()) {
            if (!hasDesiredDemuxCap || dr.hasSufficientCaps(request.desiredFilterTypes)) {
                if (!dr.isInUse()) {
@@ -1476,13 +1477,19 @@ public class TunerResourceManagerService extends SystemService implements IBinde
                            currentLowestPriority = priority;
                            isRequestFromSameProcess = (requestClient.getProcessId()
                                == (getClientProfile(dr.getOwnerClientId())).getProcessId());

                            // reset the smallest caps when lower priority resource is found
                            smallestNumOfSupportedCapsInUse = numOfSupportedCaps;

                            shouldUpdate = true;
                        }
                        // update smallest caps
                        if (smallestNumOfSupportedCaps > numOfSupportedCaps) {
                            smallestNumOfSupportedCaps = numOfSupportedCaps;
                        } else {
                            // This is the case when the priority is the same as previously found
                            // one. Update smallest caps when priority.
                            if (smallestNumOfSupportedCapsInUse > numOfSupportedCaps) {
                                smallestNumOfSupportedCapsInUse = numOfSupportedCaps;
                                shouldUpdate = true;
                            }
                        }
                        if (shouldUpdate) {
                            inUseLowestPriorityDrHandle = dr.getHandle();
                        }