[LE Audio] Only add main device for LE Audio devices in Take call on

list

Bug: 254212589
Test: manual test
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AudioOutputSwitchPreferenceControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=HandsFreeProfileOutputPreferenceControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=MediaOutputPreferenceControllerTest
Change-Id: I7831f12ca259aac3d60f4370ffc659a32fed3296
This commit is contained in:
changbetty
2022-10-23 16:17:54 +00:00
parent 062b18c736
commit abc69c34de
4 changed files with 100 additions and 8 deletions

View File

@@ -53,6 +53,7 @@ import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
@@ -227,13 +228,29 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
}
final List<BluetoothDevice> devices = leAudioProfile.getConnectedDevices();
for (BluetoothDevice device : devices) {
if (device.isConnected()) {
if (device.isConnected() && isDeviceInCachedList(device)) {
connectedDevices.add(device);
}
}
return connectedDevices;
}
/**
* Confirm if the device exists in the cached devices list. If return true, it means
* the device is main device in the LE Audio device group. Otherwise, the device is the member
* device in the group.
*/
protected boolean isDeviceInCachedList(BluetoothDevice device) {
Collection<CachedBluetoothDevice> cachedDevices =
mLocalBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();
for (CachedBluetoothDevice cachedDevice : cachedDevices) {
if (cachedDevice.getDevice().equals(device)) {
return true;
}
}
return false;
}
/**
* get hearing aid profile connected device, exclude other devices with same hiSyncId.
*/