Merge changes I0579b3af,If7ecd588 into tm-dev

* changes:
  Enable volume UI for TVs using Absolute Volume Control.
  Clear listeners when adding a new one in AudioDeviceVolumeManager
This commit is contained in:
Yan Han
2022-05-11 14:16:54 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 23 deletions

View File

@@ -235,13 +235,7 @@ public class AudioDeviceVolumeManager {
mDeviceVolumeDispatcherStub = new DeviceVolumeDispatcherStub(); mDeviceVolumeDispatcherStub = new DeviceVolumeDispatcherStub();
} }
} else { } else {
for (ListenerInfo info : mDeviceVolumeListeners) { mDeviceVolumeListeners.removeIf(info -> info.mDevice.equalTypeAddress(device));
if (info.mListener == vclistener) {
throw new IllegalArgumentException(
"attempt to call setDeviceAbsoluteMultiVolumeBehavior() "
+ "on a previously registered listener");
}
}
} }
mDeviceVolumeListeners.add(listenerInfo); mDeviceVolumeListeners.add(listenerInfo);
mDeviceVolumeDispatcherStub.register(true, device, volumes, handlesVolumeAdjustment); mDeviceVolumeDispatcherStub.register(true, device, volumes, handlesVolumeAdjustment);

View File

@@ -4146,20 +4146,9 @@ public class AudioService extends IAudioService.Stub
{ {
streamType = mStreamVolumeAlias[streamType]; streamType = mStreamVolumeAlias[streamType];
if (streamType == AudioSystem.STREAM_MUSIC) { if (streamType == AudioSystem.STREAM_MUSIC && isFullVolumeDevice(device)) {
flags = updateFlagsForTvPlatform(flags);
synchronized (mHdmiClientLock) {
// Don't display volume UI on a TV Playback device when using absolute volume
if (mHdmiCecVolumeControlEnabled && mHdmiPlaybackClient != null
&& (isAbsoluteVolumeDevice(device)
|| isA2dpAbsoluteVolumeDevice(device))) {
flags &= ~AudioManager.FLAG_SHOW_UI; flags &= ~AudioManager.FLAG_SHOW_UI;
} }
}
if (isFullVolumeDevice(device)) {
flags &= ~AudioManager.FLAG_SHOW_UI;
}
}
mVolumeController.postVolumeChanged(streamType, flags); mVolumeController.postVolumeChanged(streamType, flags);
} }

View File

@@ -4176,7 +4176,11 @@ public class HdmiControlService extends SystemService {
List<AudioDeviceAttributes> streamMusicDevices = List<AudioDeviceAttributes> streamMusicDevices =
getAudioManager().getDevicesForAttributes(STREAM_MUSIC_ATTRIBUTES); getAudioManager().getDevicesForAttributes(STREAM_MUSIC_ATTRIBUTES);
if (streamMusicDevices.contains(getAvcAudioOutputDevice())) { if (streamMusicDevices.contains(getAvcAudioOutputDevice())) {
setStreamMusicVolume(volume, AudioManager.FLAG_ABSOLUTE_VOLUME); int flags = AudioManager.FLAG_ABSOLUTE_VOLUME;
if (isTvDevice()) {
flags |= AudioManager.FLAG_SHOW_UI;
}
setStreamMusicVolume(volume, flags);
} }
} }
@@ -4190,8 +4194,11 @@ public class HdmiControlService extends SystemService {
getAudioManager().getDevicesForAttributes(STREAM_MUSIC_ATTRIBUTES); getAudioManager().getDevicesForAttributes(STREAM_MUSIC_ATTRIBUTES);
if (streamMusicDevices.contains(getAvcAudioOutputDevice())) { if (streamMusicDevices.contains(getAvcAudioOutputDevice())) {
int direction = mute ? AudioManager.ADJUST_MUTE : AudioManager.ADJUST_UNMUTE; int direction = mute ? AudioManager.ADJUST_MUTE : AudioManager.ADJUST_UNMUTE;
getAudioManager().adjustStreamVolume(AudioManager.STREAM_MUSIC, direction, int flags = AudioManager.FLAG_ABSOLUTE_VOLUME;
AudioManager.FLAG_ABSOLUTE_VOLUME); if (isTvDevice()) {
flags |= AudioManager.FLAG_SHOW_UI;
}
getAudioManager().adjustStreamVolume(AudioManager.STREAM_MUSIC, direction, flags);
} }
} }