Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7b504ce authored by Yan Han's avatar Yan Han Committed by Android (Google) Code Review
Browse files

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
parents 98040763 a8bff8e0
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -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);
+2 −13
Original line number Diff line number Diff line
@@ -4146,20 +4146,9 @@ 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)) {
        if (streamType == AudioSystem.STREAM_MUSIC && isFullVolumeDevice(device)) {
            flags &= ~AudioManager.FLAG_SHOW_UI;
        }
        }
        mVolumeController.postVolumeChanged(streamType, flags);
    }

+10 −3
Original line number Diff line number Diff line
@@ -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);
        }
    }