From 6aa213d77ef6c1001fca0c5f889dfcc831bd804e Mon Sep 17 00:00:00 2001 From: Jakub Tyszkowski Date: Wed, 22 Mar 2023 09:09:10 +0000 Subject: [PATCH] AS: Fix sometimes invalid volume set to LE Audio devices In some cases when LE headet is connected, Audio Service can adjust other devices volume level. We have to be sure that we use the right volume level for the right device. There seems to be a workaround for LE Audio devices, where the volume level was not set for the outgoing calls. This does not seem to be a problem anymore, and this workaround actually is the problem and ocassionally can set volume level stored for the default speaker device. This sometimes happens when rejecting the incoming call from the LE Audio earbuds. With this workaround removed, the issue with rejecting calls was not reproduced anymore, and the issue with outgoing calls which this workaround was suppose to prevent, was not observed as well. It could be that the original issue that this woraround was made for was already fixed. Bug: 273165066 Test: tested manually making outgoing calls, taking and rejecting incoming calls Change-Id: I97250c6cb2a7f3e59e51acbb9382bf03c26864ba --- .../java/com/android/server/audio/AudioService.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 5ca03b8e6f8ba..9b4fbd67bc8e0 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -4082,13 +4082,14 @@ public class AudioService extends IAudioService.Stub return; } - // Forcefully set LE audio volume as a workaround, since in some cases - // (like the outgoing call) the value of 'device' is not DEVICE_OUT_BLE_* - // even when BLE is connected. + // In some cases (like the outgoing or rejected call) the value of 'device' is not + // DEVICE_OUT_BLE_* even when BLE is connected. Changing the volume level in such case + // may cuase the other devices volume level leaking into the LeAudio device settings. if (!AudioSystem.isLeAudioDeviceType(device)) { - Log.w(TAG, "setLeAudioVolumeOnModeUpdate got unexpected device=" + device - + ", forcing to device=" + AudioSystem.DEVICE_OUT_BLE_HEADSET); - device = AudioSystem.DEVICE_OUT_BLE_HEADSET; + Log.w(TAG, "setLeAudioVolumeOnModeUpdate ignoring invalid device=" + + device + ", mode=" + mode + ", index=" + index + " maxIndex=" + maxIndex + + " streamType=" + streamType); + return; } if (DEBUG_VOL) {