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:
@@ -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);
|
||||||
|
|||||||
@@ -4146,19 +4146,8 @@ 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);
|
flags &= ~AudioManager.FLAG_SHOW_UI;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mVolumeController.postVolumeChanged(streamType, flags);
|
mVolumeController.postVolumeChanged(streamType, flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user