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

Commit fc46524b authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Gerrit Code Review
Browse files

Merge "Wait for disconnection to remove properties of temporarily paired device" into main

parents 4ec78c6f f85caecd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -489,7 +489,7 @@ final class BondStateMachine extends StateMachine {
            return;
        }

        mRemoteDevices.onBondStateChange(device, newState);
        mRemoteDevices.onBondStateChange(device, oldState, newState);

        if (devProp != null) {
            oldState = devProp.getBondState();
+16 −2
Original line number Diff line number Diff line
@@ -1243,9 +1243,23 @@ public class RemoteDevices {
        }
    }

    void onBondStateChange(BluetoothDevice device, int newState) {
    void onBondStateChange(BluetoothDevice device, int oldState, int newState) {
        String address = device.getAddress();
        if (Flags.temporaryPairingDeviceProperties() && oldState != BluetoothDevice.BOND_BONDED) {
            DeviceProperties deviceProperties = mDevices.get(address);
            int leConnectionHandle =
                    deviceProperties.getConnectionHandle(BluetoothDevice.TRANSPORT_LE);
            int bredrConnectionHandle =
                    deviceProperties.getConnectionHandle(BluetoothDevice.TRANSPORT_BREDR);
            if (leConnectionHandle != BluetoothDevice.ERROR
                    || bredrConnectionHandle != BluetoothDevice.ERROR) {
                // Device still connected, wait for disconnection to remove the properties
                return;
            }
        }

        if (Flags.removeAddressMapOnUnbond() && newState == BluetoothDevice.BOND_NONE) {
            removeAddressMapping(device.getAddress());
            removeAddressMapping(address);
        }
    }