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

Commit 0672c64e authored by Thomas Girardier's avatar Thomas Girardier Committed by Automerger Merge Worker
Browse files

Merge "Remove device address mapping on device removal" into main am: 440325e0

parents a7162d96 440325e0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.bluetooth.btservice;
import android.bluetooth.OobData;
import android.bluetooth.UidTraffic;

import com.android.bluetooth.flags.Flags;

class JniCallbacks {

    private RemoteDevices mRemoteDevices;
@@ -66,6 +68,9 @@ class JniCallbacks {

    void bondStateChangeCallback(int status, byte[] address, int newState, int hciReason) {
        mBondStateMachine.bondStateChangeCallback(status, address, newState, hciReason);
        if (Flags.removeBondWithAddressMap()) {
            mRemoteDevices.onBondStateChange(address, newState);
        }
    }

    void addressConsolidateCallback(byte[] mainAddress, byte[] secondaryAddress) {
+19 −9
Original line number Diff line number Diff line
@@ -1155,15 +1155,7 @@ public class RemoteDevices {
                Utils.sendBroadcast(mAdapterService, intent, BLUETOOTH_CONNECT,
                        Utils.getTempAllowlistBroadcastOptions());
            } else if (device.getBondState() == BluetoothDevice.BOND_NONE) {
                String key = Utils.getAddressStringFromByte(address);
                synchronized (mDevices) {
                    mDevices.remove(key);
                    mDeviceQueue.remove(key); // Remove from LRU cache

                    // Remove from dual mode device mappings
                    mDualDevicesMap.values().remove(key);
                    mDualDevicesMap.remove(key);
                }
                removeAddressMapping(address);
            }
            if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_TURNING_OFF) {
                mAdapterService.notifyAclDisconnected(device, transportLinkType);
@@ -1246,6 +1238,24 @@ public class RemoteDevices {
        }
    }

    private void removeAddressMapping(byte[] address) {
        String key = Utils.getAddressStringFromByte(address);
        synchronized (mDevices) {
            mDevices.remove(key);
            mDeviceQueue.remove(key); // Remove from LRU cache

            // Remove from dual mode device mappings
            mDualDevicesMap.values().remove(key);
            mDualDevicesMap.remove(key);
        }
    }

    void onBondStateChange(byte[] address, int newState) {
        if (newState == BluetoothDevice.BOND_NONE) {
            removeAddressMapping(address);
        }
    }

    void keyMissingCallback(byte[] address) {
        BluetoothDevice bluetoothDevice = getDevice(address);
        if (bluetoothDevice == null) {