Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,7 @@ filegroup { ":libcamera_client_aidl", ":libcamera_client_framework_aidl", ":libupdate_engine_aidl", ":resourcemanager_aidl", ":storaged_aidl", ":vold_aidl", Loading core/res/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -3534,6 +3534,8 @@ @hide --> <permission android:name="android.permission.MEDIA_RESOURCE_OVERRIDE_PID" android:protectionLevel="signature" /> <uses-permission android:name="android.permission.MEDIA_RESOURCE_OVERRIDE_PID" /> <!-- Must be required by a {@link android.media.routing.MediaRouteService} to ensure that only the system can interact with it. Loading services/core/java/com/android/server/tv/tunerresourcemanager/TunerResourceManagerService.java +51 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityManager.RunningAppProcessInfo; import android.content.Context; import android.media.IResourceManagerService; import android.media.tv.TvInputManager; import android.media.tv.tunerresourcemanager.CasSessionRequest; import android.media.tv.tunerresourcemanager.IResourcesReclaimListener; Loading Loading @@ -53,7 +54,7 @@ import java.util.Set; * * @hide */ public class TunerResourceManagerService extends SystemService { public class TunerResourceManagerService extends SystemService implements IBinder.DeathRecipient { private static final String TAG = "TunerResourceManagerService"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); Loading @@ -76,6 +77,7 @@ public class TunerResourceManagerService extends SystemService { private TvInputManager mTvInputManager; private ActivityManager mActivityManager; private IResourceManagerService mMediaResourceManager; private UseCasePriorityHints mPriorityCongfig = new UseCasePriorityHints(); // An internal resource request count to help generate resource handle. Loading @@ -102,6 +104,22 @@ public class TunerResourceManagerService extends SystemService { mActivityManager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE); mPriorityCongfig.parse(); if (mMediaResourceManager == null) { IBinder mediaResourceManagerBinder = getBinderService("media.resource_manager"); if (mediaResourceManagerBinder == null) { Slog.w(TAG, "Resource Manager Service not available."); return; } try { mediaResourceManagerBinder.linkToDeath(this, /*flags*/ 0); } catch (RemoteException e) { Slog.w(TAG, "Could not link to death of native resource manager service."); return; } mMediaResourceManager = IResourceManagerService.Stub.asInterface( mediaResourceManagerBinder); } } private final class BinderService extends ITunerResourceManager.Stub { Loading Loading @@ -380,6 +398,19 @@ public class TunerResourceManagerService extends SystemService { } } /** * Handle the death of the native resource manager service */ @Override public void binderDied() { if (DEBUG) { Slog.w(TAG, "Native media resource manager service has died"); } synchronized (mLock) { mMediaResourceManager = null; } } @VisibleForTesting protected void registerClientProfileInternal(ResourceClientProfile profile, IResourcesReclaimListener listener, int[] clientId) { Loading @@ -399,6 +430,16 @@ public class TunerResourceManagerService extends SystemService { ? Binder.getCallingPid() /*callingPid*/ : mTvInputManager.getClientPid(profile.getTvInputSessionId()); /*tvAppId*/ // Update Media Resource Manager with the tvAppId if (profile.getTvInputSessionId() != null && mMediaResourceManager != null) { try { mMediaResourceManager.overridePid(Binder.getCallingPid(), pid); } catch (RemoteException e) { Slog.e(TAG, "Could not overridePid in resourceManagerSercice," + " remote exception: " + e); } } ClientProfile clientProfile = new ClientProfile.Builder(clientId[0]) .tvInputSessionId(profile.getTvInputSessionId()) .useCase(profile.getUseCase()) Loading @@ -415,6 +456,15 @@ public class TunerResourceManagerService extends SystemService { Slog.d(TAG, "unregisterClientProfile(clientId=" + clientId + ")"); } removeClientProfile(clientId); // Remove the Media Resource Manager callingPid to tvAppId mapping if (mMediaResourceManager != null) { try { mMediaResourceManager.overridePid(Binder.getCallingPid(), -1); } catch (RemoteException e) { Slog.e(TAG, "Could not overridePid in resourceManagerSercice when unregister," + " remote exception: " + e); } } } @VisibleForTesting Loading services/tests/servicestests/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ <uses-permission android:name="android.permission.WRITE_DREAM_STATE"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> <uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE"/> <uses-permission android:name="android.permission.MEDIA_RESOURCE_OVERRIDE_PID"/> <!-- Uses API introduced in O (26) --> <uses-sdk android:minSdkVersion="1" Loading Loading
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,7 @@ filegroup { ":libcamera_client_aidl", ":libcamera_client_framework_aidl", ":libupdate_engine_aidl", ":resourcemanager_aidl", ":storaged_aidl", ":vold_aidl", Loading
core/res/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -3534,6 +3534,8 @@ @hide --> <permission android:name="android.permission.MEDIA_RESOURCE_OVERRIDE_PID" android:protectionLevel="signature" /> <uses-permission android:name="android.permission.MEDIA_RESOURCE_OVERRIDE_PID" /> <!-- Must be required by a {@link android.media.routing.MediaRouteService} to ensure that only the system can interact with it. Loading
services/core/java/com/android/server/tv/tunerresourcemanager/TunerResourceManagerService.java +51 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityManager.RunningAppProcessInfo; import android.content.Context; import android.media.IResourceManagerService; import android.media.tv.TvInputManager; import android.media.tv.tunerresourcemanager.CasSessionRequest; import android.media.tv.tunerresourcemanager.IResourcesReclaimListener; Loading Loading @@ -53,7 +54,7 @@ import java.util.Set; * * @hide */ public class TunerResourceManagerService extends SystemService { public class TunerResourceManagerService extends SystemService implements IBinder.DeathRecipient { private static final String TAG = "TunerResourceManagerService"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); Loading @@ -76,6 +77,7 @@ public class TunerResourceManagerService extends SystemService { private TvInputManager mTvInputManager; private ActivityManager mActivityManager; private IResourceManagerService mMediaResourceManager; private UseCasePriorityHints mPriorityCongfig = new UseCasePriorityHints(); // An internal resource request count to help generate resource handle. Loading @@ -102,6 +104,22 @@ public class TunerResourceManagerService extends SystemService { mActivityManager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE); mPriorityCongfig.parse(); if (mMediaResourceManager == null) { IBinder mediaResourceManagerBinder = getBinderService("media.resource_manager"); if (mediaResourceManagerBinder == null) { Slog.w(TAG, "Resource Manager Service not available."); return; } try { mediaResourceManagerBinder.linkToDeath(this, /*flags*/ 0); } catch (RemoteException e) { Slog.w(TAG, "Could not link to death of native resource manager service."); return; } mMediaResourceManager = IResourceManagerService.Stub.asInterface( mediaResourceManagerBinder); } } private final class BinderService extends ITunerResourceManager.Stub { Loading Loading @@ -380,6 +398,19 @@ public class TunerResourceManagerService extends SystemService { } } /** * Handle the death of the native resource manager service */ @Override public void binderDied() { if (DEBUG) { Slog.w(TAG, "Native media resource manager service has died"); } synchronized (mLock) { mMediaResourceManager = null; } } @VisibleForTesting protected void registerClientProfileInternal(ResourceClientProfile profile, IResourcesReclaimListener listener, int[] clientId) { Loading @@ -399,6 +430,16 @@ public class TunerResourceManagerService extends SystemService { ? Binder.getCallingPid() /*callingPid*/ : mTvInputManager.getClientPid(profile.getTvInputSessionId()); /*tvAppId*/ // Update Media Resource Manager with the tvAppId if (profile.getTvInputSessionId() != null && mMediaResourceManager != null) { try { mMediaResourceManager.overridePid(Binder.getCallingPid(), pid); } catch (RemoteException e) { Slog.e(TAG, "Could not overridePid in resourceManagerSercice," + " remote exception: " + e); } } ClientProfile clientProfile = new ClientProfile.Builder(clientId[0]) .tvInputSessionId(profile.getTvInputSessionId()) .useCase(profile.getUseCase()) Loading @@ -415,6 +456,15 @@ public class TunerResourceManagerService extends SystemService { Slog.d(TAG, "unregisterClientProfile(clientId=" + clientId + ")"); } removeClientProfile(clientId); // Remove the Media Resource Manager callingPid to tvAppId mapping if (mMediaResourceManager != null) { try { mMediaResourceManager.overridePid(Binder.getCallingPid(), -1); } catch (RemoteException e) { Slog.e(TAG, "Could not overridePid in resourceManagerSercice when unregister," + " remote exception: " + e); } } } @VisibleForTesting Loading
services/tests/servicestests/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ <uses-permission android:name="android.permission.WRITE_DREAM_STATE"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> <uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE"/> <uses-permission android:name="android.permission.MEDIA_RESOURCE_OVERRIDE_PID"/> <!-- Uses API introduced in O (26) --> <uses-sdk android:minSdkVersion="1" Loading