Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01cc0e4c authored by Hui Wang's avatar Hui Wang Committed by Android (Google) Code Review
Browse files

Merge "Keep the BT devices cache of BluetoothDeviceManager updated" into main

parents 682439a4 df2bb5b9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -8,3 +8,10 @@ flag {
  description: "Fix for Log.wtf in the BinderProxy"
  bug: "333417369"
}
# OWNER=huiwang TARGET=25Q1
flag {
  name: "keep_bt_devices_cache_updated"
  namespace: "telecom"
  description: "Fix the devices cache issue of BluetoothDeviceManager"
  bug: "380320985"
}
+8 −2
Original line number Diff line number Diff line
@@ -519,10 +519,13 @@ public class BluetoothDeviceManager {
                Log.i(this, "onDeviceConnected: Adding device with address: %s and devicetype=%s",
                        device, getDeviceTypeString(deviceType));
                targetDeviceMap.put(device.getAddress(), device);
                if (!mFeatureFlags.keepBtDevicesCacheUpdated()
                        || !mFeatureFlags.useRefactoredAudioRouteSwitching()) {
                    mBluetoothRouteManager.onDeviceAdded(device.getAddress());
                }
            }
        }
    }

    void clearDeviceFromDeviceMaps(String deviceAddress) {
        for (LinkedHashMap<String, BluetoothDevice> deviceMap : mDevicesByAddressMaps) {
@@ -551,10 +554,13 @@ public class BluetoothDeviceManager {
                Log.i(this, "onDeviceDisconnected: Removing device with address: %s, devicetype=%s",
                        device, getDeviceTypeString(deviceType));
                targetDeviceMap.remove(device.getAddress());
                if (!mFeatureFlags.keepBtDevicesCacheUpdated()
                        || !mFeatureFlags.useRefactoredAudioRouteSwitching()) {
                    mBluetoothRouteManager.onDeviceLost(device.getAddress());
                }
            }
        }
    }

    public void disconnectAudio() {
        if (mFeatureFlags.callAudioCommunicationDeviceRefactor()) {
+6 −0
Original line number Diff line number Diff line
@@ -211,6 +211,9 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
            if (mFeatureFlags.useRefactoredAudioRouteSwitching()) {
                mCallAudioRouteAdapter.sendMessageWithSessionInfo(BT_DEVICE_ADDED,
                        audioRouteType, device);
                if (mFeatureFlags.keepBtDevicesCacheUpdated()) {
                    mBluetoothDeviceManager.onDeviceConnected(device, deviceType);
                }
            } else {
                mBluetoothDeviceManager.onDeviceConnected(device, deviceType);
            }
@@ -219,6 +222,9 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
            if (mFeatureFlags.useRefactoredAudioRouteSwitching()) {
                mCallAudioRouteAdapter.sendMessageWithSessionInfo(BT_DEVICE_REMOVED,
                        audioRouteType, device);
                if (mFeatureFlags.keepBtDevicesCacheUpdated()) {
                    mBluetoothDeviceManager.onDeviceDisconnected(device, deviceType);
                }
            } else {
                mBluetoothDeviceManager.onDeviceDisconnected(device, deviceType);
            }