Merge "Fix LE Audio toggle missing issue for dual mode hearing device" into main

This commit is contained in:
Angela Wang
2024-08-06 09:31:28 +00:00
committed by Android (Google) Code Review
2 changed files with 50 additions and 9 deletions

View File

@@ -308,7 +308,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;
@@ -319,8 +319,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);
@@ -356,6 +355,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;
}