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

Commit c1daf3d8 authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Gerrit Code Review
Browse files

Option to use volume keys to control media volume anytime (2/2)

See Settings part for description

Change-Id: I78d26b0bd41f5b58514ae9c68208a8c950396823
parent 5acc23d4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3514,6 +3514,13 @@ public final class Settings {
         */
        public static final String ALLOW_LIGHTS = "allow_lights";

        /**
         * Volume key controls ringtone or media sound stream
         * @hide
         */
        public static final String VOLUME_KEYS_CONTROL_RING_STREAM =
                "volume_keys_control_ring_stream";

        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
+19 −2
Original line number Diff line number Diff line
@@ -560,6 +560,8 @@ public class AudioService extends IAudioService.Stub {

    private AudioManagerInternal.RingerModeDelegate mRingerModeDelegate;

    private boolean mVolumeKeysControlRingStream;

    ///////////////////////////////////////////////////////////////////////////
    // Construction
    ///////////////////////////////////////////////////////////////////////////
@@ -1029,6 +1031,10 @@ public class AudioService extends IAudioService.Stub {

            updateRingerModeAffectedStreams();
            readDockAudioSettings(cr);

            mVolumeKeysControlRingStream = Settings.System.getIntForUser(cr,
                    Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM, 1,
                    UserHandle.USER_CURRENT) == 1;
        }

        mLinkNotificationWithVolume = Settings.Secure.getInt(cr,
@@ -3433,9 +3439,15 @@ public class AudioService extends IAudioService.Stub {
                        Log.v(TAG, "getActiveStreamType: Forcing STREAM_MUSIC stream active");
                    return AudioSystem.STREAM_MUSIC;
                } else {
                    if (mVolumeKeysControlRingStream) {
                        if (DEBUG_VOL)
                            Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING b/c default");
                        return AudioSystem.STREAM_RING;
                    } else {
                        if (DEBUG_VOL)
                            Log.v(TAG, "getActiveStreamType: Forcing STREAM_MUSIC b/c default");
                        return AudioSystem.STREAM_MUSIC;
                    }
                }
            } else if (isAfMusicActiveRecently(0)) {
                if (DEBUG_VOL)
@@ -4600,6 +4612,8 @@ public class AudioService extends IAudioService.Stub {
                    Settings.Secure.VOLUME_LINK_NOTIFICATION), false, this);
            mContentResolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.DOCK_AUDIO_MEDIA_ENABLED), false, this);
            mContentResolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM), false, this);
        }

        @Override
@@ -4626,6 +4640,9 @@ public class AudioService extends IAudioService.Stub {
                    updateStreamVolumeAlias(true);
                    createStreamStates();
                }
                mVolumeKeysControlRingStream = Settings.System.getIntForUser(mContentResolver,
                        Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM, 1,
                        UserHandle.USER_CURRENT) == 1;
            }
        }
    }