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();
}
} 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);

View File

@@ -4146,19 +4146,8 @@ public class AudioService extends IAudioService.Stub
{
streamType = mStreamVolumeAlias[streamType];
if (streamType == AudioSystem.STREAM_MUSIC) {
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;
}
}
if (isFullVolumeDevice(device)) {
flags &= ~AudioManager.FLAG_SHOW_UI;
}
if (streamType == AudioSystem.STREAM_MUSIC && isFullVolumeDevice(device)) {
flags &= ~AudioManager.FLAG_SHOW_UI;
}
mVolumeController.postVolumeChanged(streamType, flags);
}

View File

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