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

Commit c34564d5 authored by Hemant Gupta's avatar Hemant Gupta Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: GAP: Update bondstatemachine to handle pairing scenarios

This patch updates BluetoothBondStateMachine to properly handle concurrency
scenarios of pairing while pairing is ongoing with some remote device.
Without this patch it was observed that DUT was getting stuck in pairing
when unpairing was done for some paired devices and pairing timed out with
device for which pairing was being initiated.

Change-Id: I07d2bc323aebbeada9c930eb36c9855da59dd677
CRs-Fixed: 586935
parent a172e99c
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ final class BondStateMachine extends StateMachine {
    private PendingCommandState mPendingCommandState = new PendingCommandState();
    private StableState mStableState = new StableState();

    private final ArrayList<BluetoothDevice> mDevices =
        new ArrayList<BluetoothDevice>();

    private BondStateMachine(AdapterService service,
            AdapterProperties prop, RemoteDevices remoteDevices) {
        super("BondStateMachine:");
@@ -118,6 +121,9 @@ final class BondStateMachine extends StateMachine {
                /* if incoming pairing, transition to pending state */
                if (newState == BluetoothDevice.BOND_BONDING)
                {
                    if(!mDevices.contains(dev)) {
                        mDevices.add(dev);
                    }
                    sendIntent(dev, newState, 0);
                    transitionTo(mPendingCommandState);
                }
@@ -138,8 +144,6 @@ final class BondStateMachine extends StateMachine {


    private class PendingCommandState extends State {
        private final ArrayList<BluetoothDevice> mDevices =
            new ArrayList<BluetoothDevice>();

        @Override
        public void enter() {
@@ -177,7 +181,9 @@ final class BondStateMachine extends StateMachine {
                        // check if bond none is received from device which
                        // was in pairing state otherwise don't transition to
                        // stable state.
                        if (newState == BluetoothDevice.BOND_NONE && !mDevices.contains(dev)) {
                        if (newState == BluetoothDevice.BOND_NONE &&
                            !mDevices.contains(dev) && mDevices.size() != 0) {
                            infoLog("not transitioning to stable state");
                            break;
                        }
                        /* this is either none/bonded, remove and transition */