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

Commit 57aef4b5 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Prevent bonded device from being removed from the property map

Bug: 31947953
Test: Manual
Change-Id: Ia2d25b305c07949a9251af83e855db4511ff887f
parent ba93b586
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);
                }
            }