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

Commit ad37c2c4 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

AudioService: fix deadlock between readSettings() and VSS.setAllIndexes()

Locking order is mSettingsLock -> VolumeStreamState.class
Missing sync on mSettingsLock was causing deadlock between
  VolumeStreamState.setAllIndexes() and readSettings().
Mark that setAllIndexesToMax() is properly sync'd on mSettingsLock.

Bug: 72122435
Test: chance
Change-Id: I4bd4037fec290dd6ba586c7090e1b377543041ab
parent 1ebcf610
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -4503,6 +4503,7 @@ public class AudioService extends IAudioService.Stub
            if (mStreamType == srcStream.mStreamType) {
                return;
            }
            synchronized (mSettingsLock) {
                synchronized (VolumeStreamState.class) {
                    int srcStreamType = srcStream.getStreamType();
                    // apply default device volume from source stream to all devices first in case
@@ -4523,7 +4524,9 @@ public class AudioService extends IAudioService.Stub
                    }
                }
            }
        }

        @GuardedBy("mSettingsLock")
        public void setAllIndexesToMax() {
            synchronized (VolumeStreamState.class) {
                for (int i = 0; i < mIndexMap.size(); i++) {