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

Commit 486ba6ea authored by Henry Fang's avatar Henry Fang Committed by Automerger Merge Worker
Browse files

Merge "yield resource if the request come from same client with same priority"...

Merge "yield resource if the request come from same client with same priority" into udc-dev am: 360db7b8 am: 1dbef69c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21995003



Change-Id: Icee10447a49291085b4f9179ddf09a2c02cffa5e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents cf3ae12f 1dbef69c
Loading
Loading
Loading
Loading
+26 −5
Original line number Original line Diff line number Diff line
@@ -1019,6 +1019,7 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        int inUseLowestPriorityFrHandle = TunerResourceManager.INVALID_RESOURCE_HANDLE;
        int inUseLowestPriorityFrHandle = TunerResourceManager.INVALID_RESOURCE_HANDLE;
        // Priority max value is 1000
        // Priority max value is 1000
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        boolean isRequestFromSameProcess = false;
        // If the desired frontend id was specified, we only need to check the frontend.
        // If the desired frontend id was specified, we only need to check the frontend.
        boolean hasDesiredFrontend = request.desiredId != TunerFrontendRequest.DEFAULT_DESIRED_ID;
        boolean hasDesiredFrontend = request.desiredId != TunerFrontendRequest.DEFAULT_DESIRED_ID;
        for (FrontendResource fr : getFrontendResources().values()) {
        for (FrontendResource fr : getFrontendResources().values()) {
@@ -1048,6 +1049,8 @@ public class TunerResourceManagerService extends SystemService implements IBinde
                    if (currentLowestPriority > priority) {
                    if (currentLowestPriority > priority) {
                        inUseLowestPriorityFrHandle = fr.getHandle();
                        inUseLowestPriorityFrHandle = fr.getHandle();
                        currentLowestPriority = priority;
                        currentLowestPriority = priority;
                        isRequestFromSameProcess = (requestClient.getProcessId()
                            == (getClientProfile(fr.getOwnerClientId())).getProcessId());
                    }
                    }
                }
                }
            }
            }
@@ -1063,7 +1066,8 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        // When all the resources are occupied, grant the lowest priority resource if the
        // When all the resources are occupied, grant the lowest priority resource if the
        // request client has higher priority.
        // request client has higher priority.
        if (inUseLowestPriorityFrHandle != TunerResourceManager.INVALID_RESOURCE_HANDLE
        if (inUseLowestPriorityFrHandle != TunerResourceManager.INVALID_RESOURCE_HANDLE
                && (requestClient.getPriority() > currentLowestPriority)) {
            && ((requestClient.getPriority() > currentLowestPriority) || (
            (requestClient.getPriority() == currentLowestPriority) && isRequestFromSameProcess))) {
            if (!reclaimResource(
            if (!reclaimResource(
                    getFrontendResource(inUseLowestPriorityFrHandle).getOwnerClientId(),
                    getFrontendResource(inUseLowestPriorityFrHandle).getOwnerClientId(),
                    TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND)) {
                    TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND)) {
@@ -1182,6 +1186,7 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        int inUseLowestPriorityLnbHandle = TunerResourceManager.INVALID_RESOURCE_HANDLE;
        int inUseLowestPriorityLnbHandle = TunerResourceManager.INVALID_RESOURCE_HANDLE;
        // Priority max value is 1000
        // Priority max value is 1000
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        boolean isRequestFromSameProcess = false;
        for (LnbResource lnb : getLnbResources().values()) {
        for (LnbResource lnb : getLnbResources().values()) {
            if (!lnb.isInUse()) {
            if (!lnb.isInUse()) {
                // Grant the unused lnb with lower handle first
                // Grant the unused lnb with lower handle first
@@ -1194,6 +1199,8 @@ public class TunerResourceManagerService extends SystemService implements IBinde
                if (currentLowestPriority > priority) {
                if (currentLowestPriority > priority) {
                    inUseLowestPriorityLnbHandle = lnb.getHandle();
                    inUseLowestPriorityLnbHandle = lnb.getHandle();
                    currentLowestPriority = priority;
                    currentLowestPriority = priority;
                    isRequestFromSameProcess = (requestClient.getProcessId()
                        == (getClientProfile(lnb.getOwnerClientId())).getProcessId());
                }
                }
            }
            }
        }
        }
@@ -1208,7 +1215,8 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        // When all the resources are occupied, grant the lowest priority resource if the
        // When all the resources are occupied, grant the lowest priority resource if the
        // request client has higher priority.
        // request client has higher priority.
        if (inUseLowestPriorityLnbHandle > TunerResourceManager.INVALID_RESOURCE_HANDLE
        if (inUseLowestPriorityLnbHandle > TunerResourceManager.INVALID_RESOURCE_HANDLE
                && (requestClient.getPriority() > currentLowestPriority)) {
            && ((requestClient.getPriority() > currentLowestPriority) || (
            (requestClient.getPriority() == currentLowestPriority) && isRequestFromSameProcess))) {
            if (!reclaimResource(getLnbResource(inUseLowestPriorityLnbHandle).getOwnerClientId(),
            if (!reclaimResource(getLnbResource(inUseLowestPriorityLnbHandle).getOwnerClientId(),
                    TunerResourceManager.TUNER_RESOURCE_TYPE_LNB)) {
                    TunerResourceManager.TUNER_RESOURCE_TYPE_LNB)) {
                return false;
                return false;
@@ -1240,6 +1248,7 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        int lowestPriorityOwnerId = -1;
        int lowestPriorityOwnerId = -1;
        // Priority max value is 1000
        // Priority max value is 1000
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        boolean isRequestFromSameProcess = false;
        if (!cas.isFullyUsed()) {
        if (!cas.isFullyUsed()) {
            casSessionHandle[0] = generateResourceHandle(
            casSessionHandle[0] = generateResourceHandle(
                    TunerResourceManager.TUNER_RESOURCE_TYPE_CAS_SESSION, cas.getSystemId());
                    TunerResourceManager.TUNER_RESOURCE_TYPE_CAS_SESSION, cas.getSystemId());
@@ -1252,12 +1261,15 @@ public class TunerResourceManagerService extends SystemService implements IBinde
            if (currentLowestPriority > priority) {
            if (currentLowestPriority > priority) {
                lowestPriorityOwnerId = ownerId;
                lowestPriorityOwnerId = ownerId;
                currentLowestPriority = priority;
                currentLowestPriority = priority;
                isRequestFromSameProcess = (requestClient.getProcessId()
                    == (getClientProfile(ownerId)).getProcessId());
            }
            }
        }
        }


        // When all the Cas sessions are occupied, reclaim the lowest priority client if the
        // When all the Cas sessions are occupied, reclaim the lowest priority client if the
        // request client has higher priority.
        // request client has higher priority.
        if (lowestPriorityOwnerId > -1 && (requestClient.getPriority() > currentLowestPriority)) {
        if (lowestPriorityOwnerId > -1 && ((requestClient.getPriority() > currentLowestPriority)
        || ((requestClient.getPriority() == currentLowestPriority) && isRequestFromSameProcess))) {
            if (!reclaimResource(lowestPriorityOwnerId,
            if (!reclaimResource(lowestPriorityOwnerId,
                    TunerResourceManager.TUNER_RESOURCE_TYPE_CAS_SESSION)) {
                    TunerResourceManager.TUNER_RESOURCE_TYPE_CAS_SESSION)) {
                return false;
                return false;
@@ -1289,6 +1301,7 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        int lowestPriorityOwnerId = -1;
        int lowestPriorityOwnerId = -1;
        // Priority max value is 1000
        // Priority max value is 1000
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        boolean isRequestFromSameProcess = false;
        if (!ciCam.isFullyUsed()) {
        if (!ciCam.isFullyUsed()) {
            ciCamHandle[0] = generateResourceHandle(
            ciCamHandle[0] = generateResourceHandle(
                    TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND_CICAM, ciCam.getCiCamId());
                    TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND_CICAM, ciCam.getCiCamId());
@@ -1301,12 +1314,16 @@ public class TunerResourceManagerService extends SystemService implements IBinde
            if (currentLowestPriority > priority) {
            if (currentLowestPriority > priority) {
                lowestPriorityOwnerId = ownerId;
                lowestPriorityOwnerId = ownerId;
                currentLowestPriority = priority;
                currentLowestPriority = priority;
                isRequestFromSameProcess = (requestClient.getProcessId()
                    == (getClientProfile(ownerId)).getProcessId());
            }
            }
        }
        }


        // When all the CiCam sessions are occupied, reclaim the lowest priority client if the
        // When all the CiCam sessions are occupied, reclaim the lowest priority client if the
        // request client has higher priority.
        // request client has higher priority.
        if (lowestPriorityOwnerId > -1 && (requestClient.getPriority() > currentLowestPriority)) {
        if (lowestPriorityOwnerId > -1 && ((requestClient.getPriority() > currentLowestPriority)
            || ((requestClient.getPriority() == currentLowestPriority)
                && isRequestFromSameProcess))) {
            if (!reclaimResource(lowestPriorityOwnerId,
            if (!reclaimResource(lowestPriorityOwnerId,
                    TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND_CICAM)) {
                    TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND_CICAM)) {
                return false;
                return false;
@@ -1424,6 +1441,7 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        int inUseLowestPriorityDrHandle = TunerResourceManager.INVALID_RESOURCE_HANDLE;
        int inUseLowestPriorityDrHandle = TunerResourceManager.INVALID_RESOURCE_HANDLE;
        // Priority max value is 1000
        // Priority max value is 1000
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        int currentLowestPriority = MAX_CLIENT_PRIORITY + 1;
        boolean isRequestFromSameProcess = false;
        // If the desired demux id was specified, we only need to check the demux.
        // If the desired demux id was specified, we only need to check the demux.
        boolean hasDesiredDemuxCap = request.desiredFilterTypes
        boolean hasDesiredDemuxCap = request.desiredFilterTypes
                != DemuxFilterMainType.UNDEFINED;
                != DemuxFilterMainType.UNDEFINED;
@@ -1448,6 +1466,8 @@ public class TunerResourceManagerService extends SystemService implements IBinde
                        // update lowest priority
                        // update lowest priority
                        if (currentLowestPriority > priority) {
                        if (currentLowestPriority > priority) {
                            currentLowestPriority = priority;
                            currentLowestPriority = priority;
                            isRequestFromSameProcess = (requestClient.getProcessId()
                                == (getClientProfile(dr.getOwnerClientId())).getProcessId());
                            shouldUpdate = true;
                            shouldUpdate = true;
                        }
                        }
                        // update smallest caps
                        // update smallest caps
@@ -1473,7 +1493,8 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        // When all the resources are occupied, grant the lowest priority resource if the
        // When all the resources are occupied, grant the lowest priority resource if the
        // request client has higher priority.
        // request client has higher priority.
        if (inUseLowestPriorityDrHandle != TunerResourceManager.INVALID_RESOURCE_HANDLE
        if (inUseLowestPriorityDrHandle != TunerResourceManager.INVALID_RESOURCE_HANDLE
                && (requestClient.getPriority() > currentLowestPriority)) {
            && ((requestClient.getPriority() > currentLowestPriority) || (
            (requestClient.getPriority() == currentLowestPriority) && isRequestFromSameProcess))) {
            if (!reclaimResource(
            if (!reclaimResource(
                    getDemuxResource(inUseLowestPriorityDrHandle).getOwnerClientId(),
                    getDemuxResource(inUseLowestPriorityDrHandle).getOwnerClientId(),
                    TunerResourceManager.TUNER_RESOURCE_TYPE_DEMUX)) {
                    TunerResourceManager.TUNER_RESOURCE_TYPE_DEMUX)) {