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

Commit aefe4a54 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio service: do not persist system enforced stream volume

Persisting STREAM_SYSTEM_ENFORCED index is not needed as its alias (STREAM_RING)
is persisted. This can also be problematic when the enforcement is active as it will
override current SYSTEM_RING persisted value given they share the same settings name
(due to aliasing).

Bug: 317938475
Test: repro steps in the bug
Change-Id: Id6cf47407bd81da45d39762cceeb4f10cf76476b
parent c796e8e9
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -8835,6 +8835,8 @@ public class AudioService extends IAudioService.Stub
                synchronized (VolumeStreamState.class) {
                    oldIndex = getIndex(device);
                    index = getValidIndex(index, hasModifyAudioSettings);
                    // for STREAM_SYSTEM_ENFORCED, do not sync aliased streams on the enforced index
                    int aliasIndex = index;
                    if ((mStreamType == AudioSystem.STREAM_SYSTEM_ENFORCED) && mCameraSoundForced) {
                        index = mIndexMax;
                    }
@@ -8853,7 +8855,8 @@ public class AudioService extends IAudioService.Stub
                        if (streamType != mStreamType &&
                                mStreamVolumeAlias[streamType] == mStreamType &&
                                (changed || !aliasStreamState.hasIndexForDevice(device))) {
                            final int scaledIndex = rescaleIndex(index, mStreamType, streamType);
                            final int scaledIndex =
                                    rescaleIndex(aliasIndex, mStreamType, streamType);
                            aliasStreamState.setIndex(scaledIndex, device, caller,
                                    hasModifyAudioSettings);
                            if (isCurrentDevice) {
@@ -9375,6 +9378,14 @@ public class AudioService extends IAudioService.Stub
            if (mIsSingleVolume && (streamState.mStreamType != AudioSystem.STREAM_MUSIC)) {
                return;
            }
            // Persisting STREAM_SYSTEM_ENFORCED index is not needed as its alias (STREAM_RING)
            // is persisted. This can also be problematic when the enforcement is active as it will
            // override current SYSTEM_RING persisted value given they share the same settings name
            // (due to aliasing).
            if (streamState.mStreamType == AudioSystem.STREAM_SYSTEM_ENFORCED) {
                return;
            }
            if (streamState.hasValidSettingsName()) {
                mSettings.putSystemIntForUser(mContentResolver,
                        streamState.getSettingNameForDevice(device),