Loading media/java/android/media/MediaCas.java +1 −1 Original line number Diff line number Diff line Loading @@ -897,7 +897,7 @@ public final class MediaCas implements AutoCloseable { synchronized (mSessionMap) { if (mSessionMap.get(session) != null) { mTunerResourceManager.releaseCasSession(mSessionMap.get(session)); mTunerResourceManager.releaseCasSession(mSessionMap.get(session), mClientId); mSessionMap.remove(session); } } Loading media/java/android/media/tv/tuner/Tuner.java +2 −2 Original line number Diff line number Diff line Loading @@ -351,12 +351,12 @@ public class Tuner implements AutoCloseable { public void close() { if (mFrontendHandle != null) { nativeCloseFrontendByHandle(mFrontendHandle); mTunerResourceManager.releaseFrontend(mFrontendHandle); mTunerResourceManager.releaseFrontend(mFrontendHandle, mClientId); mFrontendHandle = null; mFrontend = null; } if (mLnb != null) { mTunerResourceManager.releaseLnb(mLnbHandle); mTunerResourceManager.releaseLnb(mLnbHandle, mClientId); mLnb = null; mLnbHandle = null; } Loading media/java/android/media/tv/tunerresourcemanager/ITunerResourceManager.aidl +15 −8 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ interface ITunerResourceManager { * Updates the available Frontend resources information on the current device. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestFrontend(TunerFrontendRequest,int[])} and {@link #releaseFrontend(int)} call. * {@link #requestFrontend(TunerFrontendRequest,int[])} and {@link #releaseFrontend(int, int)} * call. * * @param infos an array of the available {@link TunerFrontendInfo} information. */ Loading @@ -95,7 +96,8 @@ interface ITunerResourceManager { * Updates the available Cas resource information on the current device. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestCasSession(CasSessionRequest, int[])} and {@link #releaseCasSession(int)} call. * {@link #requestCasSession(CasSessionRequest, int[])} and {@link #releaseCasSession(int, int)} * call. * * @param casSystemId id of the updating CAS system. * @param maxSessionNum the max session number of the CAS system that is updated. Loading @@ -106,7 +108,7 @@ interface ITunerResourceManager { * Updates the available Lnb resource information on the current device. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestLnb(TunerLnbRequest, int[])} and {@link #releaseLnb(int)} call. * {@link #requestLnb(TunerLnbRequest, int[])} and {@link #releaseLnb(int, int)} call. * * @param lnbIds ids of the updating lnbs. */ Loading Loading @@ -255,8 +257,9 @@ interface ITunerResourceManager { * before this release. * * @param frontendHandle the handle of the released frontend. * @param clientId the id of the client that is releasing the frontend. */ void releaseFrontend(in int frontendHandle); void releaseFrontend(in int frontendHandle, int clientId); /* * Notifies the TRM that the Demux with the given handle was released. Loading @@ -264,8 +267,9 @@ interface ITunerResourceManager { * <p>Client must call this whenever it releases a demux. * * @param demuxHandle the handle of the released Tuner Demux. * @param clientId the id of the client that is releasing the demux. */ void releaseDemux(in int demuxHandle); void releaseDemux(in int demuxHandle, int clientId); /* * Notifies the TRM that the Descrambler with the given handle was released. Loading @@ -273,8 +277,9 @@ interface ITunerResourceManager { * <p>Client must call this whenever it releases a descrambler. * * @param demuxHandle the handle of the released Tuner Descrambler. * @param clientId the id of the client that is releasing the descrambler. */ void releaseDescrambler(in int descramblerHandle); void releaseDescrambler(in int descramblerHandle, int clientId); /* * Notifies the TRM that the given Cas session has been released. Loading @@ -284,8 +289,9 @@ interface ITunerResourceManager { * <p><strong>Note:</strong> {@link #updateCasInfo(int, int)} must be called before this release. * * @param sessionResourceId the id of the released CAS session. * @param clientId the id of the client that is releasing the cas session. */ void releaseCasSession(in int sessionResourceId); void releaseCasSession(in int sessionResourceId, int clientId); /* * Notifies the TRM that the Lnb with the given handle was released. Loading @@ -295,8 +301,9 @@ interface ITunerResourceManager { * <p><strong>Note:</strong> {@link #setLnbInfos(int[])} must be called before this release. * * @param lnbHandle the handle of the released Tuner Lnb. * @param clientId the id of the client that is releasing the lnb. */ void releaseLnb(in int lnbHandle); void releaseLnb(in int lnbHandle, int clientId); /* * Compare two clients' priority. Loading media/java/android/media/tv/tunerresourcemanager/TunerResourceManager.java +19 −13 Original line number Diff line number Diff line Loading @@ -180,7 +180,8 @@ public class TunerResourceManager { * Updates the current TRM of the TunerHAL Frontend information. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestFrontend(TunerFrontendRequest, int[])} and {@link #releaseFrontend(int)} call. * {@link #requestFrontend(TunerFrontendRequest, int[])} and * {@link #releaseFrontend(int, int)} call. * * @param infos an array of the available {@link TunerFrontendInfo} information. */ Loading @@ -196,7 +197,7 @@ public class TunerResourceManager { * Updates the TRM of the current CAS information. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestCasSession(CasSessionRequest, int[])} and {@link #releaseCasSession(int)} * {@link #requestCasSession(CasSessionRequest, int[])} and {@link #releaseCasSession(int, int)} * call. * * @param casSystemId id of the updating CAS system. Loading @@ -214,7 +215,7 @@ public class TunerResourceManager { * Updates the TRM of the current Lnb information. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestLnb(TunerLnbRequest, int[])} and {@link #releaseLnb(int)} call. * {@link #requestLnb(TunerLnbRequest, int[])} and {@link #releaseLnb(int, int)} call. * * @param lnbIds ids of the updating lnbs. */ Loading Loading @@ -420,10 +421,11 @@ public class TunerResourceManager { * before this release. * * @param frontendHandle the handle of the released frontend. * @param clientId the id of the client that is releasing the frontend. */ public void releaseFrontend(int frontendHandle) { public void releaseFrontend(int frontendHandle, int clientId) { try { mService.releaseFrontend(frontendHandle); mService.releaseFrontend(frontendHandle, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -435,10 +437,11 @@ public class TunerResourceManager { * <p>Client must call this whenever it releases an Demux. * * @param demuxHandle the handle of the released Tuner Demux. * @param clientId the id of the client that is releasing the demux. */ public void releaseDemux(int demuxHandle) { public void releaseDemux(int demuxHandle, int clientId) { try { mService.releaseDemux(demuxHandle); mService.releaseDemux(demuxHandle, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -450,10 +453,11 @@ public class TunerResourceManager { * <p>Client must call this whenever it releases an Descrambler. * * @param descramblerHandle the handle of the released Tuner Descrambler. * @param clientId the id of the client that is releasing the descrambler. */ public void releaseDescrambler(int descramblerHandle) { public void releaseDescrambler(int descramblerHandle, int clientId) { try { mService.releaseDescrambler(descramblerHandle); mService.releaseDescrambler(descramblerHandle, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -468,10 +472,11 @@ public class TunerResourceManager { * release. * * @param sessionResourceId the id of the released CAS session. * @param clientId the id of the client that is releasing the cas session. */ public void releaseCasSession(int sessionResourceId) { public void releaseCasSession(int sessionResourceId, int clientId) { try { mService.releaseCasSession(sessionResourceId); mService.releaseCasSession(sessionResourceId, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -485,10 +490,11 @@ public class TunerResourceManager { * <p><strong>Note:</strong> {@link #setLnbInfoList(int[])} must be called before this release. * * @param lnbHandle the handle of the released Tuner Lnb. * @param clientId the id of the client that is releasing the lnb. */ public void releaseLnb(int lnbHandle) { public void releaseLnb(int lnbHandle, int clientId) { try { mService.releaseLnb(lnbHandle); mService.releaseLnb(lnbHandle, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading services/core/java/com/android/server/tv/tunerresourcemanager/TunerResourceManagerService.java +37 −21 Original line number Diff line number Diff line Loading @@ -257,20 +257,28 @@ public class TunerResourceManagerService extends SystemService { } @Override public void releaseFrontend(int frontendHandle) throws RemoteException { public void releaseFrontend(int frontendHandle, int clientId) throws RemoteException { enforceTunerAccessPermission("releaseFrontend"); enforceTrmAccessPermission("releaseFrontend"); if (!validateResourceHandle(TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND, frontendHandle)) { throw new RemoteException("frontendHandle can't be invalid"); } int frontendId = getResourceIdFromHandle(frontendHandle); FrontendResource fe = getFrontendResource(frontendId); if (fe == null) { throw new RemoteException("Releasing frontend does not exist."); } if (fe.getOwnerClientId() != clientId) { throw new RemoteException("Client is not the current owner of the releasing fe."); } synchronized (mLock) { releaseFrontendInternal(getResourceIdFromHandle(frontendHandle)); releaseFrontendInternal(fe); } } @Override public void releaseDemux(int demuxHandle) { public void releaseDemux(int demuxHandle, int clientId) { enforceTunerAccessPermission("releaseDemux"); enforceTrmAccessPermission("releaseDemux"); if (DEBUG) { Loading @@ -279,7 +287,7 @@ public class TunerResourceManagerService extends SystemService { } @Override public void releaseDescrambler(int descramblerHandle) { public void releaseDescrambler(int descramblerHandle, int clientId) { enforceTunerAccessPermission("releaseDescrambler"); enforceTrmAccessPermission("releaseDescrambler"); if (DEBUG) { Loading @@ -288,7 +296,7 @@ public class TunerResourceManagerService extends SystemService { } @Override public void releaseCasSession(int sessionResourceId) { public void releaseCasSession(int sessionResourceId, int clientId) { enforceTrmAccessPermission("releaseCasSession"); if (DEBUG) { Slog.d(TAG, "releaseCasSession(sessionResourceId=" + sessionResourceId + ")"); Loading @@ -296,14 +304,22 @@ public class TunerResourceManagerService extends SystemService { } @Override public void releaseLnb(int lnbHandle) throws RemoteException { public void releaseLnb(int lnbHandle, int clientId) throws RemoteException { enforceTunerAccessPermission("releaseLnb"); enforceTrmAccessPermission("releaseLnb"); if (!validateResourceHandle(TunerResourceManager.TUNER_RESOURCE_TYPE_LNB, lnbHandle)) { throw new RemoteException("lnbHandle can't be invalid"); } int lnbId = getResourceIdFromHandle(lnbHandle); LnbResource lnb = getLnbResource(lnbId); if (lnb == null) { throw new RemoteException("Releasing lnb does not exist."); } if (lnb.getOwnerClientId() != clientId) { throw new RemoteException("Client is not the current owner of the releasing lnb."); } synchronized (mLock) { releaseLnbInternal(getResourceIdFromHandle(lnbHandle)); releaseLnbInternal(lnb); } } Loading Loading @@ -568,19 +584,19 @@ public class TunerResourceManagerService extends SystemService { } @VisibleForTesting void releaseFrontendInternal(int frontendId) { void releaseFrontendInternal(FrontendResource fe) { if (DEBUG) { Slog.d(TAG, "releaseFrontend(id=" + frontendId + ")"); Slog.d(TAG, "releaseFrontend(id=" + fe.getId() + ")"); } updateFrontendClientMappingOnRelease(frontendId); updateFrontendClientMappingOnRelease(fe); } @VisibleForTesting void releaseLnbInternal(int lnbId) { void releaseLnbInternal(LnbResource lnb) { if (DEBUG) { Slog.d(TAG, "releaseLnb(lnbId=" + lnbId + ")"); Slog.d(TAG, "releaseLnb(lnbId=" + lnb.getId() + ")"); } updateLnbClientMappingOnRelease(lnbId); updateLnbClientMappingOnRelease(lnb); } @VisibleForTesting Loading @@ -588,6 +604,7 @@ public class TunerResourceManagerService extends SystemService { if (DEBUG) { Slog.d(TAG, "requestDemux(request=" + request + ")"); } // There are enough Demux resources, so we don't manage Demux in R. demuxHandle[0] = generateResourceHandle(TunerResourceManager.TUNER_RESOURCE_TYPE_DEMUX, 0); return true; } Loading @@ -597,6 +614,7 @@ public class TunerResourceManagerService extends SystemService { if (DEBUG) { Slog.d(TAG, "requestDescrambler(request=" + request + ")"); } // There are enough Descrambler resources, so we don't manage Descrambler in R. descramblerHandle[0] = generateResourceHandle(TunerResourceManager.TUNER_RESOURCE_TYPE_DESCRAMBLER, 0); return true; Loading Loading @@ -694,11 +712,10 @@ public class TunerResourceManagerService extends SystemService { } } private void updateFrontendClientMappingOnRelease(int frontendId) { FrontendResource releasingFrontend = getFrontendResource(frontendId); private void updateFrontendClientMappingOnRelease(@NonNull FrontendResource releasingFrontend) { ClientProfile ownerProfile = getClientProfile(releasingFrontend.getOwnerClientId()); releasingFrontend.removeOwner(); ownerProfile.releaseFrontend(frontendId); ownerProfile.releaseFrontend(releasingFrontend.getId()); for (int exclusiveGroupMember : releasingFrontend.getExclusiveGroupMemberFeIds()) { getFrontendResource(exclusiveGroupMember).removeOwner(); ownerProfile.releaseFrontend(exclusiveGroupMember); Loading @@ -712,11 +729,10 @@ public class TunerResourceManagerService extends SystemService { ownerProfile.useLnb(grantingId); } private void updateLnbClientMappingOnRelease(int lnbId) { LnbResource releasingLnb = getLnbResource(lnbId); private void updateLnbClientMappingOnRelease(@NonNull LnbResource releasingLnb) { ClientProfile ownerProfile = getClientProfile(releasingLnb.getOwnerClientId()); releasingLnb.removeOwner(); ownerProfile.releaseLnb(lnbId); ownerProfile.releaseLnb(releasingLnb.getId()); } /** Loading Loading @@ -761,7 +777,7 @@ public class TunerResourceManagerService extends SystemService { private void removeFrontendResource(int removingId) { FrontendResource fe = getFrontendResource(removingId); if (fe.isInUse()) { releaseFrontendInternal(removingId); releaseFrontendInternal(fe); } for (int excGroupmemberFeId : fe.getExclusiveGroupMemberFeIds()) { getFrontendResource(excGroupmemberFeId) Loading Loading @@ -789,7 +805,7 @@ public class TunerResourceManagerService extends SystemService { private void removeLnbResource(int removingId) { LnbResource lnb = getLnbResource(removingId); if (lnb.isInUse()) { releaseLnbInternal(removingId); releaseLnbInternal(lnb); } mLnbResources.remove(removingId); } Loading Loading
media/java/android/media/MediaCas.java +1 −1 Original line number Diff line number Diff line Loading @@ -897,7 +897,7 @@ public final class MediaCas implements AutoCloseable { synchronized (mSessionMap) { if (mSessionMap.get(session) != null) { mTunerResourceManager.releaseCasSession(mSessionMap.get(session)); mTunerResourceManager.releaseCasSession(mSessionMap.get(session), mClientId); mSessionMap.remove(session); } } Loading
media/java/android/media/tv/tuner/Tuner.java +2 −2 Original line number Diff line number Diff line Loading @@ -351,12 +351,12 @@ public class Tuner implements AutoCloseable { public void close() { if (mFrontendHandle != null) { nativeCloseFrontendByHandle(mFrontendHandle); mTunerResourceManager.releaseFrontend(mFrontendHandle); mTunerResourceManager.releaseFrontend(mFrontendHandle, mClientId); mFrontendHandle = null; mFrontend = null; } if (mLnb != null) { mTunerResourceManager.releaseLnb(mLnbHandle); mTunerResourceManager.releaseLnb(mLnbHandle, mClientId); mLnb = null; mLnbHandle = null; } Loading
media/java/android/media/tv/tunerresourcemanager/ITunerResourceManager.aidl +15 −8 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ interface ITunerResourceManager { * Updates the available Frontend resources information on the current device. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestFrontend(TunerFrontendRequest,int[])} and {@link #releaseFrontend(int)} call. * {@link #requestFrontend(TunerFrontendRequest,int[])} and {@link #releaseFrontend(int, int)} * call. * * @param infos an array of the available {@link TunerFrontendInfo} information. */ Loading @@ -95,7 +96,8 @@ interface ITunerResourceManager { * Updates the available Cas resource information on the current device. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestCasSession(CasSessionRequest, int[])} and {@link #releaseCasSession(int)} call. * {@link #requestCasSession(CasSessionRequest, int[])} and {@link #releaseCasSession(int, int)} * call. * * @param casSystemId id of the updating CAS system. * @param maxSessionNum the max session number of the CAS system that is updated. Loading @@ -106,7 +108,7 @@ interface ITunerResourceManager { * Updates the available Lnb resource information on the current device. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestLnb(TunerLnbRequest, int[])} and {@link #releaseLnb(int)} call. * {@link #requestLnb(TunerLnbRequest, int[])} and {@link #releaseLnb(int, int)} call. * * @param lnbIds ids of the updating lnbs. */ Loading Loading @@ -255,8 +257,9 @@ interface ITunerResourceManager { * before this release. * * @param frontendHandle the handle of the released frontend. * @param clientId the id of the client that is releasing the frontend. */ void releaseFrontend(in int frontendHandle); void releaseFrontend(in int frontendHandle, int clientId); /* * Notifies the TRM that the Demux with the given handle was released. Loading @@ -264,8 +267,9 @@ interface ITunerResourceManager { * <p>Client must call this whenever it releases a demux. * * @param demuxHandle the handle of the released Tuner Demux. * @param clientId the id of the client that is releasing the demux. */ void releaseDemux(in int demuxHandle); void releaseDemux(in int demuxHandle, int clientId); /* * Notifies the TRM that the Descrambler with the given handle was released. Loading @@ -273,8 +277,9 @@ interface ITunerResourceManager { * <p>Client must call this whenever it releases a descrambler. * * @param demuxHandle the handle of the released Tuner Descrambler. * @param clientId the id of the client that is releasing the descrambler. */ void releaseDescrambler(in int descramblerHandle); void releaseDescrambler(in int descramblerHandle, int clientId); /* * Notifies the TRM that the given Cas session has been released. Loading @@ -284,8 +289,9 @@ interface ITunerResourceManager { * <p><strong>Note:</strong> {@link #updateCasInfo(int, int)} must be called before this release. * * @param sessionResourceId the id of the released CAS session. * @param clientId the id of the client that is releasing the cas session. */ void releaseCasSession(in int sessionResourceId); void releaseCasSession(in int sessionResourceId, int clientId); /* * Notifies the TRM that the Lnb with the given handle was released. Loading @@ -295,8 +301,9 @@ interface ITunerResourceManager { * <p><strong>Note:</strong> {@link #setLnbInfos(int[])} must be called before this release. * * @param lnbHandle the handle of the released Tuner Lnb. * @param clientId the id of the client that is releasing the lnb. */ void releaseLnb(in int lnbHandle); void releaseLnb(in int lnbHandle, int clientId); /* * Compare two clients' priority. Loading
media/java/android/media/tv/tunerresourcemanager/TunerResourceManager.java +19 −13 Original line number Diff line number Diff line Loading @@ -180,7 +180,8 @@ public class TunerResourceManager { * Updates the current TRM of the TunerHAL Frontend information. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestFrontend(TunerFrontendRequest, int[])} and {@link #releaseFrontend(int)} call. * {@link #requestFrontend(TunerFrontendRequest, int[])} and * {@link #releaseFrontend(int, int)} call. * * @param infos an array of the available {@link TunerFrontendInfo} information. */ Loading @@ -196,7 +197,7 @@ public class TunerResourceManager { * Updates the TRM of the current CAS information. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestCasSession(CasSessionRequest, int[])} and {@link #releaseCasSession(int)} * {@link #requestCasSession(CasSessionRequest, int[])} and {@link #releaseCasSession(int, int)} * call. * * @param casSystemId id of the updating CAS system. Loading @@ -214,7 +215,7 @@ public class TunerResourceManager { * Updates the TRM of the current Lnb information. * * <p><strong>Note:</strong> This update must happen before the first * {@link #requestLnb(TunerLnbRequest, int[])} and {@link #releaseLnb(int)} call. * {@link #requestLnb(TunerLnbRequest, int[])} and {@link #releaseLnb(int, int)} call. * * @param lnbIds ids of the updating lnbs. */ Loading Loading @@ -420,10 +421,11 @@ public class TunerResourceManager { * before this release. * * @param frontendHandle the handle of the released frontend. * @param clientId the id of the client that is releasing the frontend. */ public void releaseFrontend(int frontendHandle) { public void releaseFrontend(int frontendHandle, int clientId) { try { mService.releaseFrontend(frontendHandle); mService.releaseFrontend(frontendHandle, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -435,10 +437,11 @@ public class TunerResourceManager { * <p>Client must call this whenever it releases an Demux. * * @param demuxHandle the handle of the released Tuner Demux. * @param clientId the id of the client that is releasing the demux. */ public void releaseDemux(int demuxHandle) { public void releaseDemux(int demuxHandle, int clientId) { try { mService.releaseDemux(demuxHandle); mService.releaseDemux(demuxHandle, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -450,10 +453,11 @@ public class TunerResourceManager { * <p>Client must call this whenever it releases an Descrambler. * * @param descramblerHandle the handle of the released Tuner Descrambler. * @param clientId the id of the client that is releasing the descrambler. */ public void releaseDescrambler(int descramblerHandle) { public void releaseDescrambler(int descramblerHandle, int clientId) { try { mService.releaseDescrambler(descramblerHandle); mService.releaseDescrambler(descramblerHandle, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -468,10 +472,11 @@ public class TunerResourceManager { * release. * * @param sessionResourceId the id of the released CAS session. * @param clientId the id of the client that is releasing the cas session. */ public void releaseCasSession(int sessionResourceId) { public void releaseCasSession(int sessionResourceId, int clientId) { try { mService.releaseCasSession(sessionResourceId); mService.releaseCasSession(sessionResourceId, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -485,10 +490,11 @@ public class TunerResourceManager { * <p><strong>Note:</strong> {@link #setLnbInfoList(int[])} must be called before this release. * * @param lnbHandle the handle of the released Tuner Lnb. * @param clientId the id of the client that is releasing the lnb. */ public void releaseLnb(int lnbHandle) { public void releaseLnb(int lnbHandle, int clientId) { try { mService.releaseLnb(lnbHandle); mService.releaseLnb(lnbHandle, clientId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
services/core/java/com/android/server/tv/tunerresourcemanager/TunerResourceManagerService.java +37 −21 Original line number Diff line number Diff line Loading @@ -257,20 +257,28 @@ public class TunerResourceManagerService extends SystemService { } @Override public void releaseFrontend(int frontendHandle) throws RemoteException { public void releaseFrontend(int frontendHandle, int clientId) throws RemoteException { enforceTunerAccessPermission("releaseFrontend"); enforceTrmAccessPermission("releaseFrontend"); if (!validateResourceHandle(TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND, frontendHandle)) { throw new RemoteException("frontendHandle can't be invalid"); } int frontendId = getResourceIdFromHandle(frontendHandle); FrontendResource fe = getFrontendResource(frontendId); if (fe == null) { throw new RemoteException("Releasing frontend does not exist."); } if (fe.getOwnerClientId() != clientId) { throw new RemoteException("Client is not the current owner of the releasing fe."); } synchronized (mLock) { releaseFrontendInternal(getResourceIdFromHandle(frontendHandle)); releaseFrontendInternal(fe); } } @Override public void releaseDemux(int demuxHandle) { public void releaseDemux(int demuxHandle, int clientId) { enforceTunerAccessPermission("releaseDemux"); enforceTrmAccessPermission("releaseDemux"); if (DEBUG) { Loading @@ -279,7 +287,7 @@ public class TunerResourceManagerService extends SystemService { } @Override public void releaseDescrambler(int descramblerHandle) { public void releaseDescrambler(int descramblerHandle, int clientId) { enforceTunerAccessPermission("releaseDescrambler"); enforceTrmAccessPermission("releaseDescrambler"); if (DEBUG) { Loading @@ -288,7 +296,7 @@ public class TunerResourceManagerService extends SystemService { } @Override public void releaseCasSession(int sessionResourceId) { public void releaseCasSession(int sessionResourceId, int clientId) { enforceTrmAccessPermission("releaseCasSession"); if (DEBUG) { Slog.d(TAG, "releaseCasSession(sessionResourceId=" + sessionResourceId + ")"); Loading @@ -296,14 +304,22 @@ public class TunerResourceManagerService extends SystemService { } @Override public void releaseLnb(int lnbHandle) throws RemoteException { public void releaseLnb(int lnbHandle, int clientId) throws RemoteException { enforceTunerAccessPermission("releaseLnb"); enforceTrmAccessPermission("releaseLnb"); if (!validateResourceHandle(TunerResourceManager.TUNER_RESOURCE_TYPE_LNB, lnbHandle)) { throw new RemoteException("lnbHandle can't be invalid"); } int lnbId = getResourceIdFromHandle(lnbHandle); LnbResource lnb = getLnbResource(lnbId); if (lnb == null) { throw new RemoteException("Releasing lnb does not exist."); } if (lnb.getOwnerClientId() != clientId) { throw new RemoteException("Client is not the current owner of the releasing lnb."); } synchronized (mLock) { releaseLnbInternal(getResourceIdFromHandle(lnbHandle)); releaseLnbInternal(lnb); } } Loading Loading @@ -568,19 +584,19 @@ public class TunerResourceManagerService extends SystemService { } @VisibleForTesting void releaseFrontendInternal(int frontendId) { void releaseFrontendInternal(FrontendResource fe) { if (DEBUG) { Slog.d(TAG, "releaseFrontend(id=" + frontendId + ")"); Slog.d(TAG, "releaseFrontend(id=" + fe.getId() + ")"); } updateFrontendClientMappingOnRelease(frontendId); updateFrontendClientMappingOnRelease(fe); } @VisibleForTesting void releaseLnbInternal(int lnbId) { void releaseLnbInternal(LnbResource lnb) { if (DEBUG) { Slog.d(TAG, "releaseLnb(lnbId=" + lnbId + ")"); Slog.d(TAG, "releaseLnb(lnbId=" + lnb.getId() + ")"); } updateLnbClientMappingOnRelease(lnbId); updateLnbClientMappingOnRelease(lnb); } @VisibleForTesting Loading @@ -588,6 +604,7 @@ public class TunerResourceManagerService extends SystemService { if (DEBUG) { Slog.d(TAG, "requestDemux(request=" + request + ")"); } // There are enough Demux resources, so we don't manage Demux in R. demuxHandle[0] = generateResourceHandle(TunerResourceManager.TUNER_RESOURCE_TYPE_DEMUX, 0); return true; } Loading @@ -597,6 +614,7 @@ public class TunerResourceManagerService extends SystemService { if (DEBUG) { Slog.d(TAG, "requestDescrambler(request=" + request + ")"); } // There are enough Descrambler resources, so we don't manage Descrambler in R. descramblerHandle[0] = generateResourceHandle(TunerResourceManager.TUNER_RESOURCE_TYPE_DESCRAMBLER, 0); return true; Loading Loading @@ -694,11 +712,10 @@ public class TunerResourceManagerService extends SystemService { } } private void updateFrontendClientMappingOnRelease(int frontendId) { FrontendResource releasingFrontend = getFrontendResource(frontendId); private void updateFrontendClientMappingOnRelease(@NonNull FrontendResource releasingFrontend) { ClientProfile ownerProfile = getClientProfile(releasingFrontend.getOwnerClientId()); releasingFrontend.removeOwner(); ownerProfile.releaseFrontend(frontendId); ownerProfile.releaseFrontend(releasingFrontend.getId()); for (int exclusiveGroupMember : releasingFrontend.getExclusiveGroupMemberFeIds()) { getFrontendResource(exclusiveGroupMember).removeOwner(); ownerProfile.releaseFrontend(exclusiveGroupMember); Loading @@ -712,11 +729,10 @@ public class TunerResourceManagerService extends SystemService { ownerProfile.useLnb(grantingId); } private void updateLnbClientMappingOnRelease(int lnbId) { LnbResource releasingLnb = getLnbResource(lnbId); private void updateLnbClientMappingOnRelease(@NonNull LnbResource releasingLnb) { ClientProfile ownerProfile = getClientProfile(releasingLnb.getOwnerClientId()); releasingLnb.removeOwner(); ownerProfile.releaseLnb(lnbId); ownerProfile.releaseLnb(releasingLnb.getId()); } /** Loading Loading @@ -761,7 +777,7 @@ public class TunerResourceManagerService extends SystemService { private void removeFrontendResource(int removingId) { FrontendResource fe = getFrontendResource(removingId); if (fe.isInUse()) { releaseFrontendInternal(removingId); releaseFrontendInternal(fe); } for (int excGroupmemberFeId : fe.getExclusiveGroupMemberFeIds()) { getFrontendResource(excGroupmemberFeId) Loading Loading @@ -789,7 +805,7 @@ public class TunerResourceManagerService extends SystemService { private void removeLnbResource(int removingId) { LnbResource lnb = getLnbResource(removingId); if (lnb.isInUse()) { releaseLnbInternal(removingId); releaseLnbInternal(lnb); } mLnbResources.remove(removingId); } Loading