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

Commit 61ad5ae9 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Remove "Couldn't pair" prompt on ACTION_PAIRING_CANCEL

ACTION_PAIRING_CANCEL is triggered as a result of an ACL connection
going down, causing a "Couldn't pair" prompt. This can happen on some
car kits, even if the pairing is successful and the car kit briefly
tearing down the ACL connection after pairing and resuming it
immediately afterwards.

If a connection gets disconnected during a normal bonding procedure, the
UNBOND_REASON_REMOTE_DEVICE_DOWN reason code for the
ACTION_BOND_STATE_CHANGED already indicates this issue and will inform
the user.

Bug: 63975046
Test: manual
Change-Id: I663d8b7700741927c72e38e30cd993c0b81511a9
parent 436b1e2f
Loading
Loading
Loading
Loading
+0 −19
Original line number Original line Diff line number Diff line
@@ -97,7 +97,6 @@ public class BluetoothEventManager {


        // Pairing broadcasts
        // Pairing broadcasts
        addHandler(BluetoothDevice.ACTION_BOND_STATE_CHANGED, new BondStateChangedHandler());
        addHandler(BluetoothDevice.ACTION_BOND_STATE_CHANGED, new BondStateChangedHandler());
        addHandler(BluetoothDevice.ACTION_PAIRING_CANCEL, new PairingCancelHandler());


        // Fine-grained state broadcasts
        // Fine-grained state broadcasts
        addHandler(BluetoothDevice.ACTION_CLASS_CHANGED, new ClassChangedHandler());
        addHandler(BluetoothDevice.ACTION_CLASS_CHANGED, new ClassChangedHandler());
@@ -344,24 +343,6 @@ public class BluetoothEventManager {
        }
        }
    }
    }


    private class PairingCancelHandler implements Handler {
        public void onReceive(Context context, Intent intent, BluetoothDevice device) {
            if (device == null) {
                Log.e(TAG, "ACTION_PAIRING_CANCEL with no EXTRA_DEVICE");
                return;
            }
            CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
            if (cachedDevice == null) {
                Log.e(TAG, "ACTION_PAIRING_CANCEL with no cached device");
                return;
            }
            int errorMsg = R.string.bluetooth_pairing_error_message;
            if (context != null && cachedDevice != null) {
                Utils.showError(context, cachedDevice.getName(), errorMsg);
            }
        }
    }

    private class DockEventHandler implements Handler {
    private class DockEventHandler implements Handler {
        public void onReceive(Context context, Intent intent, BluetoothDevice device) {
        public void onReceive(Context context, Intent intent, BluetoothDevice device) {
            // Remove if unpair device upon undocking
            // Remove if unpair device upon undocking