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

Commit 8517e46f authored by Mike Lockwood's avatar Mike Lockwood Committed by Mike Lockwood
Browse files

Save and restore master volume in the settings provider

parent cbdb49dc
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1498,6 +1498,12 @@ public final class Settings {
         */
        public static final String VOLUME_BLUETOOTH_SCO = "volume_bluetooth_sco";

        /**
         * Master volume (float in the range 0.0f to 1.0f).
         * @hide
         */
        public static final String VOLUME_MASTER = "volume_master";

        /**
         * Whether the notifications should use the ring volume (value of 1) or a separate
         * notification volume (value of 0). In most cases, users will have this enabled so the
+12 −0
Original line number Diff line number Diff line
@@ -404,6 +404,15 @@ public class AudioService extends IAudioService.Stub {
        TelephonyManager tmgr = (TelephonyManager)
                context.getSystemService(Context.TELEPHONY_SERVICE);
        tmgr.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);

        if (context.getResources().getBoolean(
                com.android.internal.R.bool.config_useMasterVolume)) {
            float volume = Settings.System.getFloat(mContentResolver,
                    Settings.System.VOLUME_MASTER, -1.0f);
            if (volume >= 0.0f) {
                AudioSystem.setMasterVolume(volume);
            }
        }
    }

    private void createAudioSystemThread() {
@@ -619,6 +628,9 @@ public class AudioService extends IAudioService.Stub {
                if (volume < 0.0f) volume = 0.0f;
            }
            AudioSystem.setMasterVolume(volume);
            long origCallerIdentityToken = Binder.clearCallingIdentity();
            Settings.System.putFloat(mContentResolver, Settings.System.VOLUME_MASTER, volume);
            Binder.restoreCallingIdentity(origCallerIdentityToken);
        }
    }