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

Commit f495bc1e authored by Jin Seok Park's avatar Jin Seok Park
Browse files

Remove using AudioManager.FLAG_ACTIVE_MEDIA_ONLY

FLAG_ACTIVE_MEDIA_ONLY is not used inside Audio Framework code, but
is only needed internally for MediaSessionService. Replace it with
boolean musicOnly value.

Bug: 160682430
Test: Manually test log when trying to change volume while no media
is playing

Change-Id: I6a1dee04e7aab0d7602096a257e0375e32d795dd
parent 65f41d56
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -1742,10 +1742,7 @@ public class MediaSessionService extends SystemService implements Monitor {
            }
            if (down || up) {
                int flags = AudioManager.FLAG_FROM_KEY;
                if (musicOnly) {
                    // This flag is used when the screen is off to only affect active media.
                    flags |= AudioManager.FLAG_ACTIVE_MEDIA_ONLY;
                } else {
                if (!musicOnly) {
                    // These flags are consistent with the home screen
                    if (up) {
                        flags |= AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_VIBRATE;
@@ -1759,11 +1756,12 @@ public class MediaSessionService extends SystemService implements Monitor {
                        direction = 0;
                    }
                    dispatchAdjustVolumeLocked(packageName, opPackageName, pid, uid,
                            asSystemService, stream, direction, flags);
                            asSystemService, stream, direction, flags, musicOnly);
                } else if (isMute) {
                    if (down && keyEvent.getRepeatCount() == 0) {
                        dispatchAdjustVolumeLocked(packageName, opPackageName, pid, uid,
                                asSystemService, stream, AudioManager.ADJUST_TOGGLE_MUTE, flags);
                                asSystemService, stream, AudioManager.ADJUST_TOGGLE_MUTE, flags,
                                musicOnly);
                    }
                }
            }
@@ -1846,7 +1844,7 @@ public class MediaSessionService extends SystemService implements Monitor {
            try {
                synchronized (mLock) {
                    dispatchAdjustVolumeLocked(packageName, opPackageName, pid, uid, false,
                            suggestedStream, delta, flags);
                            suggestedStream, delta, flags, false);
                }
            } finally {
                Binder.restoreCallingIdentity(token);
@@ -2028,7 +2026,8 @@ public class MediaSessionService extends SystemService implements Monitor {
        }

        private void dispatchAdjustVolumeLocked(String packageName, String opPackageName, int pid,
                int uid, boolean asSystemService, int suggestedStream, int direction, int flags) {
                int uid, boolean asSystemService, int suggestedStream, int direction, int flags,
                boolean musicOnly) {
            MediaSessionRecordImpl session = isGlobalPriorityActiveLocked() ? mGlobalPrioritySession
                    : mCurrentFullUserRecord.mPriorityStack.getDefaultVolumeSession();

@@ -2043,8 +2042,7 @@ public class MediaSessionService extends SystemService implements Monitor {
                            + ". flags=" + flags + ", preferSuggestedStream="
                            + preferSuggestedStream + ", session=" + session);
                }
                if ((flags & AudioManager.FLAG_ACTIVE_MEDIA_ONLY) != 0
                        && !AudioSystem.isStreamActive(AudioManager.STREAM_MUSIC, 0)) {
                if (musicOnly && !AudioSystem.isStreamActive(AudioManager.STREAM_MUSIC, 0)) {
                    if (DEBUG_KEY_EVENT) {
                        Log.d(TAG, "Nothing is playing on the music stream. Skipping volume event,"
                                + " flags=" + flags);