From 83e5cd004f542ac80bd1c4ca1ee289d050c21be4 Mon Sep 17 00:00:00 2001 From: Yuyang Huang Date: Fri, 16 Jun 2023 06:22:42 +0000 Subject: [PATCH] Enable/Disable ASHA profile with LE audio toggle LE audio has more capability and better quality than ASHA has. When LE audio turned on, ASHA should be off to avoid media streaming profile conflict. Bug: 287525854 Test: manual (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f79e084bd0a3f9cd332d8218ac040d8c6c60f658) Merged-In: I3c5c9012c167b920e484b39374fe8174191b094d Change-Id: I3c5c9012c167b920e484b39374fe8174191b094d --- .../BluetoothDetailsProfilesController.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java index 00f18e8a87a..d2446f15ea5 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java @@ -319,11 +319,16 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll return; } + LocalBluetoothProfile asha = mProfileManager.getHearingAidProfile(); + for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) { Log.d(TAG, "device:" + leAudioDevice.getDevice().getAnonymizedAddress() + "disable LE profile"); profile.setEnabled(leAudioDevice.getDevice(), false); + if (asha != null) { + asha.setEnabled(leAudioDevice.getDevice(), true); + } } if (!SystemProperties.getBoolean(ENABLE_DUAL_MODE_AUDIO, false)) { @@ -349,12 +354,16 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll disableProfileBeforeUserEnablesLeAudio(mProfileManager.getA2dpProfile()); disableProfileBeforeUserEnablesLeAudio(mProfileManager.getHeadsetProfile()); } + LocalBluetoothProfile asha = mProfileManager.getHearingAidProfile(); for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) { Log.d(TAG, "device:" + leAudioDevice.getDevice().getAnonymizedAddress() + "enable LE profile"); profile.setEnabled(leAudioDevice.getDevice(), true); + if (asha != null) { + asha.setEnabled(leAudioDevice.getDevice(), false); + } } } @@ -371,6 +380,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll + profile.toString() + " profile is disabled. Do nothing."); } } + } else { + if (profile == null) { + Log.w(TAG, "profile is null"); + } else { + Log.w(TAG, profile.toString() + " is not in " + mProfileDeviceMap); + } } } @@ -387,6 +402,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll + profile.toString() + " profile is enabled. Do nothing."); } } + } else { + if (profile == null) { + Log.w(TAG, "profile is null"); + } else { + Log.w(TAG, profile.toString() + " is not in " + mProfileDeviceMap); + } } }