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

Commit 39fe476d authored by Evan Anderson's avatar Evan Anderson Committed by slickrick
Browse files

MediaFocusControl: Deny audio focus if notification stream is 0



Previously audio focus would be granted regardless of notification
volume, meaning that if notifications are muted the media stream would
still be dimished for focus. By checking if STREAM_NOTIFICATION is 0 and
if a notification stream is requesting focus, this is no longer an issue.

Change-Id: Ie10a64e58ce77174a3bbdeaa936646d40c24404f
Signed-off-by: default avatarEvan Anderson <evan1124@gmail.com>
parent 470406db
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -642,6 +642,12 @@ public class MediaFocusControl implements OnFinished {
            return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
        }

        AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
        if (am.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0
                && mainStreamType == AudioManager.STREAM_NOTIFICATION) {
            return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
        }

        synchronized(mAudioFocusLock) {
            if (!canReassignAudioFocus()) {
                return AudioManager.AUDIOFOCUS_REQUEST_FAILED;