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

Commit 267fed4b authored by Hyundo Moon's avatar Hyundo Moon Committed by Android (Google) Code Review
Browse files

Merge "Prevent system crash when adjusting volume with illegal direction"

parents 5a873bc1 15361326
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -462,10 +462,11 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                try {
                    if (useSuggested) {
                        if (AudioSystem.isStreamActive(stream, 0)) {
                        mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction,
                                flags, packageName, uid);
                            mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream,
                                    direction, flags, packageName, uid);
                        } else {
                            mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(
                                    AudioManager.USE_DEFAULT_STREAM_TYPE, direction,
@@ -475,6 +476,12 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
                        mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags,
                                packageName, uid);
                    }
                } catch (IllegalArgumentException e) {
                    Log.e(TAG, "Cannot adjust volume: direction=" + direction + ", stream="
                            + stream + ", flags=" + flags + ", packageName=" + packageName
                            + ", uid=" + uid + ", useSuggested=" + useSuggested
                            + ", previousFlagPlaySound=" + previousFlagPlaySound, e);
                }
            }
        });
    }
+4 −0
Original line number Diff line number Diff line
@@ -1363,6 +1363,10 @@ public class MediaSessionService extends SystemService implements Monitor {
                                    flags, packageName, TAG);
                        } catch (RemoteException e) {
                            Log.e(TAG, "Error adjusting default volume.", e);
                        } catch (IllegalArgumentException e) {
                            Log.e(TAG, "Cannot adjust volume: direction=" + direction
                                    + ", suggestedStream=" + suggestedStream + ", flags=" + flags,
                                    e);
                        }
                    }
                });