[Fix] Bluetooth device ordering

-Caused by sorting whole list
-It should sort connected devices, and then, to add all disconnected
devices from getMostRecentlyConnectedDevices()

Bug: 176850941
Test: atest LocalMediaManagerTest
Change-Id: I123e70d0616d3fab0a29658e29421ee94aec3094
(cherry picked from commit a4cf89aa16)
This commit is contained in:
Tim Peng
2021-02-22 11:24:21 +08:00
committed by tim peng
parent 27ea4217af
commit 1bc02694ea

View File

@@ -205,7 +205,6 @@ public class LocalMediaManager implements BluetoothCallback {
void dispatchDeviceListUpdate() {
final List<MediaDevice> mediaDevices = new ArrayList<>(mMediaDevices);
Collections.sort(mediaDevices, COMPARATOR);
for (DeviceCallback callback : getCallbacks()) {
callback.onDeviceListUpdate(mediaDevices);
}
@@ -465,6 +464,7 @@ public class LocalMediaManager implements BluetoothCallback {
synchronized (mMediaDevicesLock) {
mMediaDevices.clear();
mMediaDevices.addAll(devices);
Collections.sort(devices, COMPARATOR);
// Add disconnected bluetooth devices only when phone output device is available.
for (MediaDevice device : devices) {
final int type = device.getDeviceType();