From aa1950fd801afc9502cbd482981d34079065e743 Mon Sep 17 00:00:00 2001 From: Himanshu Rawat Date: Tue, 19 Jul 2022 06:08:44 +0000 Subject: [PATCH] Don't cancel passkey entry pairing autonomously Bluetooth pairing is cancelled if the pairing popup is closed without explicitly accepting the pairing. However there is no way to explicitly accept the pairing when the local device displays for the passkey entry or pin key entry pairing method. As a result all passkey entry and pin key entry pairings, where the local device is displaying the value, are cancelled after the pairing is successful. If the BT stack has not completed the SDP search when the pairing is cancelled after successful pairing, it may result in removal of the bond information. Bug: 237757124 Test: Pair with BT HID keyboard; adb logcat | grep "BTPairingController: Pairing dialog canceled" Change-Id: Ifdb98c16084dd811eed68469e7df5d1913c6ace8 --- .../bluetooth/BluetoothPairingDialogFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java index 650267a4757..8dd00b389ed 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java @@ -86,8 +86,12 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i @Override public void onDestroy() { super.onDestroy(); - if (!mPositiveClicked) { - mPairingController.onCancel(); + if (mPairingController.getDialogType() + != BluetoothPairingController.DISPLAY_PASSKEY_DIALOG) { + /* Cancel pairing unless explicitly accepted by user */ + if (!mPositiveClicked) { + mPairingController.onCancel(); + } } }