Fix LE Audio toggle missing issue for dual mode hearing device

After the code change of ag/28283226, they hide the LE Audio toggle for
LE Audio only device since turning off the profile may cause this device
no functioning. But the dual mode hearing devices(LE Audio + Asha) are
wrongly recognized as LE Audio only devices since
HearingAidProfile.accessProfileEnabled() return false. This make the
users lost the ability to switch between profiles they preferred.

Make HearingAidProfile.accessProfileEnabled() return true and hide the
Hearing Aid toggle by default since it's also meaningless to turn off
the Asha profile for Asha-only devices.

Flag: com.android.settingslib.flags.asha_profile_access_profile_enabled_true
Bug: 356530795
Test: manual checking the UI
Test: atest BluetoothDetailsProfilesControllerTest
Change-Id: Ica350b4c16c1b07945399bfee1038f7b0824baed
This commit is contained in:
Angela Wang
2024-08-02 03:52:03 +00:00
parent b6e0cd99c1
commit a8297a313b
2 changed files with 50 additions and 9 deletions

View File

@@ -309,7 +309,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
* Helper to get the list of connectable and special profiles.
*/
private List<LocalBluetoothProfile> getProfiles() {
List<LocalBluetoothProfile> result = new ArrayList<LocalBluetoothProfile>();
List<LocalBluetoothProfile> result = new ArrayList<>();
mProfileDeviceMap.clear();
if (mAllOfCachedDevices == null || mAllOfCachedDevices.isEmpty()) {
return result;
@@ -320,8 +320,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
if (mProfileDeviceMap.containsKey(profile.toString())) {
mProfileDeviceMap.get(profile.toString()).add(cachedItem);
} else {
List<CachedBluetoothDevice> tmpCachedDeviceList =
new ArrayList<CachedBluetoothDevice>();
List<CachedBluetoothDevice> tmpCachedDeviceList = new ArrayList<>();
tmpCachedDeviceList.add(cachedItem);
mProfileDeviceMap.put(profile.toString(), tmpCachedDeviceList);
result.add(profile);
@@ -357,6 +356,10 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
}
boolean hearingAidSupported = result.contains(
mManager.getProfileManager().getHearingAidProfile());
// Remove hearing aids toggle anyway since showing the toggle will confuse users
if (hearingAidSupported) {
result.remove(mManager.getProfileManager().getHearingAidProfile());
}
if (leAudioSupported && !classicAudioSupported && !hearingAidSupported) {
mIsLeAudioOnlyDevice = true;
}