From 92bfccd9021506f02d128fb7b0a5ef9e5e09338c Mon Sep 17 00:00:00 2001 From: "daren.liao" Date: Tue, 27 Sep 2022 16:52:19 +0800 Subject: [PATCH] Change sendVolumeKeyEvent condition [Description] In 5c03084e32d521c485d2e657f036a786f1f3b74c CEC volume control is changed to use full volume control However, if ARC is not connected due to : - AVR connecting to non-ARC port of TV - Specific AVR configuration System audio mode is on, but volume control feature doesn't work We should check system audio and volume control status instead of check whether current device is a full volume device when trying to notify CEC framework about the volume change event [Test Report] Test with TV connecting AVR : Denon 2400/ SR6013 - connected to non ARC port, volume control PASS - connected to ARC port, volume control PASS Run CTS PASS - android.hdmicec.cts.common.HdmiCecSystemAudioControlTest - android.hdmicec.cts.tv.HdmiCecRemoteControlPassThroughTest (#cect_11_1_13_4_RemoteControlMessagesToAudioSystem) Bug: 253189182 Change-Id: If4b3ad7b1af6246e0ff935e1eb1401f1736e5ff2 --- .../android/server/audio/AudioService.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 66682cceb3f0a..a54b59c4a2d33 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -3409,16 +3409,15 @@ public class AudioService extends IAudioService.Stub synchronized (mHdmiClientLock) { if (mHdmiManager != null) { // At most one of mHdmiPlaybackClient and mHdmiTvClient should be non-null - HdmiClient fullVolumeHdmiClient = mHdmiPlaybackClient; + HdmiClient hdmiClient = mHdmiPlaybackClient; if (mHdmiTvClient != null) { - fullVolumeHdmiClient = mHdmiTvClient; + hdmiClient = mHdmiTvClient; } - if (fullVolumeHdmiClient != null + if (((mHdmiPlaybackClient != null && isFullVolumeDevice(device)) + || (mHdmiTvClient != null && mHdmiSystemAudioSupported)) && mHdmiCecVolumeControlEnabled - && streamTypeAlias == AudioSystem.STREAM_MUSIC - // vol change on a full volume device - && isFullVolumeDevice(device)) { + && streamTypeAlias == AudioSystem.STREAM_MUSIC) { int keyCode = KeyEvent.KEYCODE_UNKNOWN; switch (direction) { case AudioManager.ADJUST_RAISE: @@ -3442,14 +3441,14 @@ public class AudioService extends IAudioService.Stub try { switch (keyEventMode) { case AudioDeviceVolumeManager.ADJUST_MODE_NORMAL: - fullVolumeHdmiClient.sendVolumeKeyEvent(keyCode, true); - fullVolumeHdmiClient.sendVolumeKeyEvent(keyCode, false); + hdmiClient.sendVolumeKeyEvent(keyCode, true); + hdmiClient.sendVolumeKeyEvent(keyCode, false); break; case AudioDeviceVolumeManager.ADJUST_MODE_START: - fullVolumeHdmiClient.sendVolumeKeyEvent(keyCode, true); + hdmiClient.sendVolumeKeyEvent(keyCode, true); break; case AudioDeviceVolumeManager.ADJUST_MODE_END: - fullVolumeHdmiClient.sendVolumeKeyEvent(keyCode, false); + hdmiClient.sendVolumeKeyEvent(keyCode, false); break; default: Log.e(TAG, "Invalid keyEventMode " + keyEventMode);