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

Commit 217c7c51 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "AudioService: permission for volume adjustment to lowest values" into rvc-dev am: 962f6766

Change-Id: I3be2766d070e28787061a194edf704734908e32e
parents 3c0a4fa4 962f6766
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -29,13 +29,13 @@ import com.android.server.LocalServices;
public abstract class AudioManagerInternal {
public abstract class AudioManagerInternal {


    public abstract void adjustSuggestedStreamVolumeForUid(int streamType, int direction,
    public abstract void adjustSuggestedStreamVolumeForUid(int streamType, int direction,
            int flags, String callingPackage, int uid);
            int flags, String callingPackage, int uid, int pid);


    public abstract void adjustStreamVolumeForUid(int streamType, int direction, int flags,
    public abstract void adjustStreamVolumeForUid(int streamType, int direction, int flags,
            String callingPackage, int uid);
            String callingPackage, int uid, int pid);


    public abstract void setStreamVolumeForUid(int streamType, int direction, int flags,
    public abstract void setStreamVolumeForUid(int streamType, int direction, int flags,
            String callingPackage, int uid);
            String callingPackage, int uid, int pid);


    public abstract void setRingerModeDelegate(RingerModeDelegate delegate);
    public abstract void setRingerModeDelegate(RingerModeDelegate delegate);


+138 −40

File changed.

Preview size limit exceeded, changes collapsed.

+7 −4
Original line number Original line Diff line number Diff line
@@ -328,7 +328,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR
                public void run() {
                public void run() {
                    try {
                    try {
                        mAudioManagerInternal.setStreamVolumeForUid(stream, volumeValue, flags,
                        mAudioManagerInternal.setStreamVolumeForUid(stream, volumeValue, flags,
                                opPackageName, uid);
                                opPackageName, uid, pid);
                    } catch (IllegalArgumentException | SecurityException e) {
                    } catch (IllegalArgumentException | SecurityException e) {
                        Log.e(TAG, "Cannot set volume: stream=" + stream + ", value=" + volumeValue
                        Log.e(TAG, "Cannot set volume: stream=" + stream + ", value=" + volumeValue
                                + ", flags=" + flags, e);
                                + ", flags=" + flags, e);
@@ -501,12 +501,15 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR
        // Must use opPackageName for adjusting volumes with UID.
        // Must use opPackageName for adjusting volumes with UID.
        final String opPackageName;
        final String opPackageName;
        final int uid;
        final int uid;
        final int pid;
        if (asSystemService) {
        if (asSystemService) {
            opPackageName = mContext.getOpPackageName();
            opPackageName = mContext.getOpPackageName();
            uid = Process.SYSTEM_UID;
            uid = Process.SYSTEM_UID;
            pid = Process.myPid();
        } else {
        } else {
            opPackageName = callingOpPackageName;
            opPackageName = callingOpPackageName;
            uid = callingUid;
            uid = callingUid;
            pid = callingPid;
        }
        }
        mHandler.post(new Runnable() {
        mHandler.post(new Runnable() {
            @Override
            @Override
@@ -515,15 +518,15 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR
                    if (useSuggested) {
                    if (useSuggested) {
                        if (AudioSystem.isStreamActive(stream, 0)) {
                        if (AudioSystem.isStreamActive(stream, 0)) {
                            mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream,
                            mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream,
                                    direction, flags, opPackageName, uid);
                                    direction, flags, opPackageName, uid, pid);
                        } else {
                        } else {
                            mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(
                            mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(
                                    AudioManager.USE_DEFAULT_STREAM_TYPE, direction,
                                    AudioManager.USE_DEFAULT_STREAM_TYPE, direction,
                                    flags | previousFlagPlaySound, opPackageName, uid);
                                    flags | previousFlagPlaySound, opPackageName, uid, pid);
                        }
                        }
                    } else {
                    } else {
                        mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags,
                        mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags,
                                opPackageName, uid);
                                opPackageName, uid, pid);
                    }
                    }
                } catch (IllegalArgumentException | SecurityException e) {
                } catch (IllegalArgumentException | SecurityException e) {
                    Log.e(TAG, "Cannot adjust volume: direction=" + direction + ", stream="
                    Log.e(TAG, "Cannot adjust volume: direction=" + direction + ", stream="
+4 −1
Original line number Original line Diff line number Diff line
@@ -2107,16 +2107,19 @@ public class MediaSessionService extends SystemService implements Monitor {
                    public void run() {
                    public void run() {
                        final String callingOpPackageName;
                        final String callingOpPackageName;
                        final int callingUid;
                        final int callingUid;
                        final int callingPid;
                        if (asSystemService) {
                        if (asSystemService) {
                            callingOpPackageName = mContext.getOpPackageName();
                            callingOpPackageName = mContext.getOpPackageName();
                            callingUid = Process.myUid();
                            callingUid = Process.myUid();
                            callingPid = Process.myPid();
                        } else {
                        } else {
                            callingOpPackageName = opPackageName;
                            callingOpPackageName = opPackageName;
                            callingUid = uid;
                            callingUid = uid;
                            callingPid = pid;
                        }
                        }
                        try {
                        try {
                            mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(suggestedStream,
                            mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(suggestedStream,
                                    direction, flags, callingOpPackageName, callingUid);
                                    direction, flags, callingOpPackageName, callingUid, callingPid);
                        } catch (SecurityException | IllegalArgumentException e) {
                        } catch (SecurityException | IllegalArgumentException e) {
                            Log.e(TAG, "Cannot adjust volume: direction=" + direction
                            Log.e(TAG, "Cannot adjust volume: direction=" + direction
                                    + ", suggestedStream=" + suggestedStream + ", flags=" + flags
                                    + ", suggestedStream=" + suggestedStream + ", flags=" + flags