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

Commit 9d54dc77 authored by Ajay Panicker's avatar Ajay Panicker Committed by android-build-merger
Browse files

Prevent bonded device from being removed from the property map

am: 57aef4b5

Change-Id: I9d41d8834a5524c98bcb1e1d1ff2e67deb0a9501
parents 63f2f3bf 57aef4b5
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import java.util.LinkedList;
import java.util.Queue;

final class RemoteDevices {
    private static final boolean DBG = true;
    private static final boolean DBG = false;
    private static final String TAG = "BluetoothRemoteDevices";

    // Maximum number of device properties to remember
@@ -96,10 +96,15 @@ final class RemoteDevices {
            prop.mAddress = address;
            String key = Utils.getAddressStringFromByte(address);
            DeviceProperties pv = mDevices.put(key, prop);

            if (pv == null) {
                mDeviceQueue.offer(key);
                if (mDeviceQueue.size() > MAX_DEVICE_QUEUE_SIZE) {
                    String deleteKey = mDeviceQueue.poll();
                    for (BluetoothDevice device : mAdapterService.getBondedDevices()) {
                        if (device.getAddress().equals(deleteKey)) return prop;
                    }
                    debugLog("Removing device " + deleteKey + " from property map");
                    mDevices.remove(deleteKey);
                }
            }