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
This commit is contained in:
Eric Laurent
2019-05-07 18:13:26 -07:00
parent 35231f7fc5
commit 02facb908e

View File

@@ -4919,19 +4919,17 @@ public class AudioService extends IAudioService.Stub
}
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) {