Use internal volume controller and status bar.
Remove code that let these components be replaced by external
processes.
Bug: 33006669
Bug: 34106436
Test: manual. reboot device, play music, change volume,
view notifications
Change-Id: I458f11537ab9db6f23735487513815553004613f
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index 4c58ffd..9b37f12 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -351,7 +351,7 @@
*/
private void enforceMediaPermissions(ComponentName compName, int pid, int uid,
int resolvedUserId) {
- if (isCurrentVolumeController(uid)) return;
+ if (isCurrentVolumeController(uid, pid)) return;
if (getContext()
.checkPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL, pid, uid)
!= PackageManager.PERMISSION_GRANTED
@@ -361,20 +361,13 @@
}
}
- private boolean isCurrentVolumeController(int uid) {
- if (mAudioManagerInternal != null) {
- final int vcuid = mAudioManagerInternal.getVolumeControllerUid();
- if (vcuid > 0 && uid == vcuid) {
- return true;
- }
- }
- return false;
+ private boolean isCurrentVolumeController(int uid, int pid) {
+ return getContext().checkPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
+ pid, uid) == PackageManager.PERMISSION_GRANTED;
}
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) {
+ if (!isCurrentVolumeController(uid, pid)) {
throw new SecurityException("Only system ui may " + action);
}
}