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

Commit 65c06123 authored by Venkatarama Avadhani's avatar Venkatarama Avadhani
Browse files

Fix MediaCas claimResource logic

When a resource is claimed by a resource challenger, and there is only 1
resource available, the check in claimResource that the CAS is fully
used is incorrect. The challenger "challenges" for a resource from the
CAS only if the CAS was fully used and if the challenger wins, then the
CAS will continue to be fully used. Removing this check.

Bug: 381864924
Flag: EXEMPT bugfix
Test: atest android.media.misc.cts.MediaCasTest
Change-Id: I51cd5c2f8f939ffdb504b9043a22bc06c07985cc
parent e67b918e
Loading
Loading
Loading
Loading
+10 −19
Original line number Diff line number Diff line
@@ -1283,33 +1283,19 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        if (DEBUG) {
            Slog.d(TAG, "requestCasSession(request=" + request + ")");
        }
        int[] reclaimOwnerId = new int[1];
        if (!claimCasSession(request, casSessionHandle, reclaimOwnerId)) {
        if (!claimCasSession(request, casSessionHandle)) {
            return false;
        }
        if (casSessionHandle[0] == TunerResourceManager.INVALID_RESOURCE_HANDLE) {
            return false;
        }
        if (reclaimOwnerId[0] != INVALID_CLIENT_ID) {
            if (!reclaimResource(reclaimOwnerId[0],
                    TunerResourceManager.TUNER_RESOURCE_TYPE_CAS_SESSION)) {
                return false;
            }
            synchronized (mLock) {
                if (getCasResource(request.casSystemId).isFullyUsed()) {
                    Slog.e(TAG, "Reclaimed cas still fully used");
                    return false;
                }
                updateCasClientMappingOnNewGrant(request.casSystemId, request.clientId);
            }
        }
        return true;
    }

    protected boolean claimCasSession(CasSessionRequest request, long[] casSessionHandle,
            int[] reclaimOwnerId) throws RemoteException {
    protected boolean claimCasSession(CasSessionRequest request, long[] casSessionHandle)
            throws RemoteException {
        casSessionHandle[0] = TunerResourceManager.INVALID_RESOURCE_HANDLE;
        reclaimOwnerId[0] = INVALID_CLIENT_ID;

        synchronized (mLock) {
            if (!checkClientExists(request.clientId)) {
                throw new RemoteException("Request cas from unregistered client:"
@@ -1357,7 +1343,12 @@ public class TunerResourceManagerService extends SystemService implements IBinde
                                            && requestClient
                                                    .resourceOwnershipRetentionEnabled())))) {
                casSessionHandle[0] = cas.getHandle();
                reclaimOwnerId[0] = lowestPriorityOwnerId;
                if (!reclaimResource(
                        lowestPriorityOwnerId,
                        TunerResourceManager.TUNER_RESOURCE_TYPE_CAS_SESSION)) {
                    return false;
                }
                updateCasClientMappingOnNewGrant(request.casSystemId, request.clientId);
                return true;
            }
        }