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

Commit da392904 authored by Wally Yau's avatar Wally Yau
Browse files

Set stream volume to max when userMasterVolume is set to true.

When useMasterVolume is set, we don't want to apply the volume
attenuation twice, once at the stream mixer and once at the master
volume control. It should only be applied once at the master volume
control.

Change-Id: Id5b1cf97571733515b5680c638f11cde8824cfc0
Fixed: b/18460548
parent 07b4a291
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -608,6 +608,10 @@ public class AudioService extends IAudioService.Stub {

        mUseFixedVolume = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_useFixedVolume);
        mUseMasterVolume = context.getResources().getBoolean(
                com.android.internal.R.bool.config_useMasterVolume);
        mMasterVolumeRamp = context.getResources().getIntArray(
                com.android.internal.R.array.config_masterVolumeRamp);

        // must be called before readPersistedSettings() which needs a valid mStreamVolumeAlias[]
        // array initialized by updateStreamVolumeAlias()
@@ -658,13 +662,8 @@ public class AudioService extends IAudioService.Stub {

        context.registerReceiver(mReceiver, intentFilter);

        mUseMasterVolume = context.getResources().getBoolean(
                com.android.internal.R.bool.config_useMasterVolume);
        restoreMasterVolume();

        mMasterVolumeRamp = context.getResources().getIntArray(
                com.android.internal.R.array.config_masterVolumeRamp);

        LocalServices.addService(AudioManagerInternal.class, new AudioServiceInternal());
    }

@@ -3446,8 +3445,9 @@ public class AudioService extends IAudioService.Stub {

        public void readSettings() {
            synchronized (VolumeStreamState.class) {
                // force maximum volume on all streams if fixed volume property is set
                if (mUseFixedVolume) {
                // force maximum volume on all streams if fixed volume property
                // or master volume property is set
                if (mUseFixedVolume || mUseMasterVolume) {
                    mIndex.put(AudioSystem.DEVICE_OUT_DEFAULT, mIndexMax);
                    return;
                }
@@ -3672,7 +3672,7 @@ public class AudioService extends IAudioService.Stub {
        private int getValidIndex(int index) {
            if (index < 0) {
                return 0;
            } else if (mUseFixedVolume || index > mIndexMax) {
            } else if (mUseFixedVolume || mUseMasterVolume || index > mIndexMax) {
                return mIndexMax;
            }