Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be19ed0b authored by John Spurlock's avatar John Spurlock
Browse files

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
parent 0dfc9015
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -338,6 +338,7 @@ public class MediaSessionService extends SystemService implements Monitor {
     */
     */
    private void enforceMediaPermissions(ComponentName compName, int pid, int uid,
    private void enforceMediaPermissions(ComponentName compName, int pid, int uid,
            int resolvedUserId) {
            int resolvedUserId) {
        if (isCurrentVolumeController(uid)) return;
        if (getContext()
        if (getContext()
                .checkPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL, pid, uid)
                .checkPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL, pid, uid)
                    != PackageManager.PERMISSION_GRANTED
                    != PackageManager.PERMISSION_GRANTED
@@ -347,13 +348,18 @@ public class MediaSessionService extends SystemService implements Monitor {
        }
        }
    }
    }


    private void enforceSystemUiPermission(String action, int pid, int uid) {
    private boolean isCurrentVolumeController(int uid) {
        if (mAudioManagerInternal != null) {
        if (mAudioManagerInternal != null) {
            final int vcuid = mAudioManagerInternal.getVolumeControllerUid();
            final int vcuid = mAudioManagerInternal.getVolumeControllerUid();
            if (vcuid > 0 && uid == vcuid) {
            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,
        if (getContext().checkPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
                pid, uid) != PackageManager.PERMISSION_GRANTED) {
                pid, uid) != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Only system ui may " + action);
            throw new SecurityException("Only system ui may " + action);