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

Commit 0d5b81ba authored by Pierre Couillaud's avatar Pierre Couillaud Committed by Brian Egizi
Browse files

When sharing to new frontend, stop sharing with old



Cherry picked Idd465a97749328138852fee19eeba87310ccc0bc to master due to b/286408867.

Code was merged via `-s ours` and is missing even though the sha exists on the target branch. Cherry pick is required to bring in the code.

Manually remove the "Merged in" directive to allow for downstream propagation.

Bug: 280826683
Test: android.media.tv.tuner.cts.TunerTest
Signed-off-by: default avatarPierre Couillaud <pierre@broadcom.com>
(cherry picked from https://android-review.googlesource.com/q/commit:6b126f0ef71da3f0d4afcc2d31dc8ff6f9a0efa9)
Change-Id: I0750ba6552fd6239f22b2e65d95cf32c12fe3e82
parent ecae99ea
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1468,6 +1468,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
@@ -81,6 +81,11 @@ public final class ClientProfile {

    private Set<Integer> mUsingDemuxHandles = 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.
     */
@@ -225,12 +230,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
@@ -1087,9 +1087,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);
    }

@@ -1099,6 +1105,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);
        }