diff options
author | Eric Laurent <elaurent@google.com> | 2023-08-18 12:14:55 +0200 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-09-15 21:18:14 +0000 |
commit | 562084ac0a60e5777f2b29cb7e8e463d9b1b88b9 (patch) | |
tree | 41a1cff2dad733dbb243ce6fd63c4d27b9d651fc | |
parent | f8d5e3701589c2c9fa37a0d60c8be8dec92f8846 (diff) | |
download | base-562084ac0a60e5777f2b29cb7e8e463d9b1b88b9.tar.gz |
AudioDeviceBroker: restore use of hearing aids by default for VoIP calls
Remove the target SDK gating policy for the selection of hearing aids during
VoIP calls: this could break legacy apps that did not adopt new APIs to
manage hearing aids.
Bug: 295220577
Test: Meets, Skype, Zoom and Celluar calls with hearing aids.
(cherry picked from commit 97014effc039f44910f86a1151a3af375c944926)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6db4ead48e50356918e28594b13c31defdf009a1)
Merged-In: I9e4abfe6d22ac48f50bdec362597a028359dcc9f
Change-Id: I9e4abfe6d22ac48f50bdec362597a028359dcc9f
-rw-r--r-- | services/core/java/com/android/server/audio/AudioDeviceBroker.java | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java index 29a19417b8fd..32c033230a16 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java +++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java @@ -2305,7 +2305,11 @@ import java.util.concurrent.atomic.AtomicBoolean; } @GuardedBy("mDeviceStateLock") - private boolean communnicationDeviceCompatOn() { + // LE Audio: For system server (Telecom) and APKs targeting S and above, we let the audio + // policy routing rules select the default communication device. + // For older APKs, we force LE Audio headset when connected as those APKs cannot select a LE + // Audiodevice explicitly. + private boolean communnicationDeviceLeAudioCompatOn() { return mAudioModeOwner.mMode == AudioSystem.MODE_IN_COMMUNICATION && !(CompatChanges.isChangeEnabled( USE_SET_COMMUNICATION_DEVICE, mAudioModeOwner.mUid) @@ -2313,19 +2317,25 @@ import java.util.concurrent.atomic.AtomicBoolean; } @GuardedBy("mDeviceStateLock") + // Hearing Aid: For system server (Telecom) and IN_CALL mode we let the audio + // policy routing rules select the default communication device. + // For 3p apps and IN_COMMUNICATION mode we force Hearing aid when connected to maintain + // backwards compatibility + private boolean communnicationDeviceHaCompatOn() { + return mAudioModeOwner.mMode == AudioSystem.MODE_IN_COMMUNICATION + && !(mAudioModeOwner.mUid == android.os.Process.SYSTEM_UID); + } + + @GuardedBy("mDeviceStateLock") AudioDeviceAttributes getDefaultCommunicationDevice() { - // For system server (Telecom) and APKs targeting S and above, we let the audio - // policy routing rules select the default communication device. - // For older APKs, we force Hearing Aid or LE Audio headset when connected as - // those APKs cannot select a LE Audio or Hearing Aid device explicitly. AudioDeviceAttributes device = null; - if (communnicationDeviceCompatOn()) { - // If both LE and Hearing Aid are active (thie should not happen), - // priority to Hearing Aid. + // If both LE and Hearing Aid are active (thie should not happen), + // priority to Hearing Aid. + if (communnicationDeviceHaCompatOn()) { device = mDeviceInventory.getDeviceOfType(AudioSystem.DEVICE_OUT_HEARING_AID); - if (device == null) { - device = mDeviceInventory.getDeviceOfType(AudioSystem.DEVICE_OUT_BLE_HEADSET); - } + } + if (device == null && communnicationDeviceLeAudioCompatOn()) { + device = mDeviceInventory.getDeviceOfType(AudioSystem.DEVICE_OUT_BLE_HEADSET); } return device; } |