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

Commit 6b126f0e authored by Pierre Couillaud's avatar Pierre Couillaud
Browse files

When sharing to new frontend, stop sharing with old



Bug: 280826683
Test: android.media.tv.tuner.cts.TunerTest
Change-Id: Idd465a97749328138852fee19eeba87310ccc0bc
Signed-off-by: default avatarPierre Couillaud <pierre@broadcom.com>
parent fa1378eb
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1342,6 +1342,10 @@ int JTuner::shareFrontend(int feId) {
        return (int)Result::INVALID_STATE;
    }

    if (mDemuxClient != NULL) {
        mDemuxClient->setFrontendDataSourceById(feId);
    }

    mSharedFeId = feId;
    return (int)Result::SUCCESS;
}
+14 −0
Original line number Diff line number Diff line
@@ -79,6 +79,11 @@ public final class ClientProfile {
     */
    private Set<Integer> mShareFeClientIds = new HashSet<>();

    /**
     * Client id sharee that has shared frontend with the current client.
     */
    private Integer mShareeFeClientId = INVALID_RESOURCE_ID;

    /**
     * List of the Lnb handles that are used by the current client.
     */
@@ -223,12 +228,21 @@ public final class ClientProfile {
        return mShareFeClientIds;
    }

    public Integer getShareeFeClientId() {
        return mShareeFeClientId;
    }

    public void setShareeFeClientId(Integer shareeFeClientId) {
        mShareeFeClientId = shareeFeClientId;
    }

    /**
     * Called when the client released a frontend.
     */
    public void releaseFrontend() {
        mUsingFrontendHandles.clear();
        mShareFeClientIds.clear();
        mShareeFeClientId = INVALID_RESOURCE_ID;
        mPrimaryUsingFrontendHandle = TunerResourceManager.INVALID_RESOURCE_HANDLE;
    }

+8 −0
Original line number Diff line number Diff line
@@ -996,9 +996,15 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        if (DEBUG) {
            Slog.d(TAG, "shareFrontend from " + selfClientId + " with " + targetClientId);
        }
        Integer shareeFeClientId = getClientProfile(selfClientId).getShareeFeClientId();
        if (shareeFeClientId != ClientProfile.INVALID_RESOURCE_ID) {
            getClientProfile(shareeFeClientId).stopSharingFrontend(selfClientId);
            getClientProfile(selfClientId).releaseFrontend();
        }
        for (int feId : getClientProfile(targetClientId).getInUseFrontendHandles()) {
            getClientProfile(selfClientId).useFrontend(feId);
        }
        getClientProfile(selfClientId).setShareeFeClientId(targetClientId);
        getClientProfile(targetClientId).shareFrontend(selfClientId);
    }

@@ -1008,6 +1014,8 @@ public class TunerResourceManagerService extends SystemService implements IBinde
        // change the owner of all the inUse frontend
        newOwnerProfile.shareFrontend(currentOwnerId);
        currentOwnerProfile.stopSharingFrontend(newOwnerId);
        newOwnerProfile.setShareeFeClientId(ClientProfile.INVALID_RESOURCE_ID);
        currentOwnerProfile.setShareeFeClientId(newOwnerId);
        for (int inUseHandle : newOwnerProfile.getInUseFrontendHandles()) {
            getFrontendResource(inUseHandle).setOwner(newOwnerId);
        }