Clear listeners when adding a new one in AudioDeviceVolumeManager
Currently, multiple absolute volume listeners from the same controller can be notified of volume change events because old ones are not removed from AudioDeviceVolumeManager. This CL removes existing listeners for a device when a new one is added. We also no longer forbid re-adding a listener currently in AudioDeviceVolumeManager's list, as it might have been removed from AudioService. Bug: 231433390 Test: manual; atest android.hdmicec.cts.playback.HdmiCecAvcToTvTest Change-Id: If7ecd58880001b955565e0f65ede9f0787e1be49
This commit is contained in:
@@ -235,13 +235,7 @@ public class AudioDeviceVolumeManager {
|
||||
mDeviceVolumeDispatcherStub = new DeviceVolumeDispatcherStub();
|
||||
}
|
||||
} else {
|
||||
for (ListenerInfo info : mDeviceVolumeListeners) {
|
||||
if (info.mListener == vclistener) {
|
||||
throw new IllegalArgumentException(
|
||||
"attempt to call setDeviceAbsoluteMultiVolumeBehavior() "
|
||||
+ "on a previously registered listener");
|
||||
}
|
||||
}
|
||||
mDeviceVolumeListeners.removeIf(info -> info.mDevice.equalTypeAddress(device));
|
||||
}
|
||||
mDeviceVolumeListeners.add(listenerInfo);
|
||||
mDeviceVolumeDispatcherStub.register(true, device, volumes, handlesVolumeAdjustment);
|
||||
|
||||
Reference in New Issue
Block a user