Fix device ordering

Should sort the devices before adding to the list.

Bug: 183690996
Test: atest LocalMediaManagerTest
Change-Id: I491d6e4218480ed112ed9f7b122a5673a6c8cf03
This commit is contained in:
Alan Huang
2021-10-05 15:56:38 +00:00
parent 9b9cca942e
commit 137acf7384

View File

@@ -479,9 +479,9 @@ public class LocalMediaManager implements BluetoothCallback {
@Override
public void onDeviceListAdded(List<MediaDevice> devices) {
synchronized (mMediaDevicesLock) {
Collections.sort(devices, COMPARATOR);
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();