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

Commit 8fd5d5e8 authored by jiabin's avatar jiabin
Browse files

Add lock when adjusting suggested stream volume.

When adjusting suggested stream volume, we may set the stream type
according to mVolumeControlStream, which could be changed by other
thread. To avoid getting stream type -1, which cause crash when checking
stream type, add a lock request in adjustSuggestedStreamVolume.

Bug: 71333271
Test: Manually test
Change-Id: If98f50f4f2389818b7ac3b0f33bdc7e27f3ad3f8
parent 32ca41d0
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -1411,6 +1411,8 @@ public class AudioService extends IAudioService.Stub
                direction/*val1*/, flags/*val2*/, new StringBuilder(callingPackage)
                        .append("/").append(caller).append(" uid:").append(uid).toString()));
        final int streamType;
        synchronized (mForceControlStreamLock) {
            // Request lock in case mVolumeControlStream is changed by other thread.
            if (mUserSelectedVolumeControlStream) { // implies mVolumeControlStream != -1
                streamType = mVolumeControlStream;
            } else {
@@ -1428,6 +1430,7 @@ public class AudioService extends IAudioService.Stub
                    streamType = mVolumeControlStream;
                }
            }
        }

        final boolean isMute = isMuteAdjust(direction);