Merge "When sharing to new frontend, stop sharing with old"

This commit is contained in:
Henry Fang
2023-06-06 22:19:35 +00:00
committed by Gerrit Code Review
3 changed files with 26 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}