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

Commit 9e070715 authored by RoboErik's avatar RoboErik Committed by Android Git Automerger
Browse files

am f338fcba: Merge "Use the suggested stream if it\'s currently active" into lmp-mr1-dev

* commit 'f338fcba':
  Use the suggested stream if it's currently active
parents 01816640 f338fcba
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -805,7 +805,12 @@ public class MediaSessionService extends SystemService implements Monitor {
                        + flags + ", suggestedStream=" + suggestedStream);

            }
            if (session == null) {
            boolean preferSuggestedStream = false;
            if (isValidLocalStreamType(suggestedStream)
                    && AudioSystem.isStreamActive(suggestedStream, 0)) {
                preferSuggestedStream = true;
            }
            if (session == null || preferSuggestedStream) {
                if ((flags & AudioManager.FLAG_ACTIVE_MEDIA_ONLY) != 0
                        && !AudioSystem.isStreamActive(AudioManager.STREAM_MUSIC, 0)) {
                    if (DEBUG) {
@@ -959,6 +964,12 @@ public class MediaSessionService extends SystemService implements Monitor {
            return keyCode == KeyEvent.KEYCODE_HEADSETHOOK;
        }

        // we only handle public stream types, which are 0-5
        private boolean isValidLocalStreamType(int streamType) {
            return streamType >= AudioManager.STREAM_VOICE_CALL
                    && streamType <= AudioManager.STREAM_NOTIFICATION;
        }

        private KeyEventWakeLockReceiver mKeyEventReceiver = new KeyEventWakeLockReceiver(mHandler);

        class KeyEventWakeLockReceiver extends ResultReceiver implements Runnable,