AudioService: fix cross deadlock
Commit 5bbcd44 introduced a cross deadlock between
AudioDeviceBrocker.mDeviceStateLock and VolumeStreamState.class
by locking VolumeStreamState.class before calling
mDeviceBroker.isAvrcpAbsoluteVolumeSupported().
Bug: 132098030
Test: make
Change-Id: Ia6e6e1e407a2ddcff7931d508fc142ee8ee652b9
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index d510912..9c3f156 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -4919,19 +4919,17 @@
}
private void onSetVolumeIndexOnDevice(@NonNull DeviceVolumeUpdate update) {
- synchronized (VolumeStreamState.class) {
- final VolumeStreamState streamState = mStreamStates[update.mStreamType];
- if (update.hasVolumeIndex()) {
- final int index = update.getVolumeIndex();
- streamState.setIndex(index, update.mDevice, update.mCaller);
- sVolumeLogger.log(new AudioEventLogger.StringEvent(update.mCaller + " dev:0x"
- + Integer.toHexString(update.mDevice) + " volIdx:" + index));
- } else {
- sVolumeLogger.log(new AudioEventLogger.StringEvent(update.mCaller
- + " update vol on dev:0x" + Integer.toHexString(update.mDevice)));
- }
- setDeviceVolume(streamState, update.mDevice);
+ final VolumeStreamState streamState = mStreamStates[update.mStreamType];
+ if (update.hasVolumeIndex()) {
+ final int index = update.getVolumeIndex();
+ streamState.setIndex(index, update.mDevice, update.mCaller);
+ sVolumeLogger.log(new AudioEventLogger.StringEvent(update.mCaller + " dev:0x"
+ + Integer.toHexString(update.mDevice) + " volIdx:" + index));
+ } else {
+ sVolumeLogger.log(new AudioEventLogger.StringEvent(update.mCaller
+ + " update vol on dev:0x" + Integer.toHexString(update.mDevice)));
}
+ setDeviceVolume(streamState, update.mDevice);
}
/*package*/ void setDeviceVolume(VolumeStreamState streamState, int device) {