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

Commit ebc6e092 authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "Option to use volume keys to control media volume anytime (2/2)" into cm-10.1

parents 0d08baa1 aa1d684f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3122,6 +3122,13 @@ public final class Settings {
            "navigation_ring_targets_2",
        };

        /**
         * 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 −3
Original line number Diff line number Diff line
@@ -448,6 +448,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {

    private int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;

    private boolean mVolumeKeysControlRingStream;

    ///////////////////////////////////////////////////////////////////////////
    // Construction
    ///////////////////////////////////////////////////////////////////////////
@@ -768,6 +770,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
            readDockAudioSettings(cr);

            mSafeVolumeEnabled = new Boolean(safeVolumeEnabled(cr));

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

        mLinkNotificationWithVolume = Settings.System.getIntForUser(cr,
@@ -2538,9 +2543,15 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
                        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 setting");
                        return AudioSystem.STREAM_MUSIC;
                    }
                }
            } else if (AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0)) {
                if (DEBUG_VOL)
@@ -3544,6 +3555,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
                Settings.System.VOLUME_LINK_NOTIFICATION), false, this);
            mContentResolver.registerContentObserver(Settings.System.getUriFor(
                Settings.System.SAFE_HEADSET_VOLUME), false, this);
            mContentResolver.registerContentObserver(Settings.System.getUriFor(
                Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM), false, this);
        }

        @Override
@@ -3595,6 +3608,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished {

                } else if (uri.equals(Settings.System.getUriFor(Settings.System.SAFE_HEADSET_VOLUME))) {
                    mSafeVolumeEnabled = safeVolumeEnabled(mContentResolver);
                } else if (uri.equals(Settings.System.getUriFor(Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM))) {
                    mVolumeKeysControlRingStream = Settings.System.getIntForUser(mContentResolver,
                            Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM, 1, UserHandle.USER_CURRENT) == 1;
                }
            }
        }