VolumePrototypes: Allow current controller to access sessions.
Allow the currently blessed volume controller delegate to access
media session manager to support multiple remote sessions.
Bug: 19260237
Change-Id: I53120f0852c69a7ea08b7b4a9f61902b961dbc70
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index 06c154e..a5efc83 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -338,6 +338,7 @@
*/
private void enforceMediaPermissions(ComponentName compName, int pid, int uid,
int resolvedUserId) {
+ if (isCurrentVolumeController(uid)) return;
if (getContext()
.checkPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL, pid, uid)
!= PackageManager.PERMISSION_GRANTED
@@ -347,13 +348,18 @@
}
}
- private void enforceSystemUiPermission(String action, int pid, int uid) {
+ private boolean isCurrentVolumeController(int uid) {
if (mAudioManagerInternal != null) {
final int vcuid = mAudioManagerInternal.getVolumeControllerUid();
if (vcuid > 0 && uid == vcuid) {
- return;
+ return true;
}
}
+ return false;
+ }
+
+ private void enforceSystemUiPermission(String action, int pid, int uid) {
+ if (isCurrentVolumeController(uid)) return;
if (getContext().checkPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
pid, uid) != PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Only system ui may " + action);