Only cancel bonding if pair button is not pressed

aosp/2093046 cancels bonding unconditionally in onDestroy(), this
results in the user not being able to pair when the pair button is
pressed because onDestroy() is also called in that case.

Only cancel bonding if the user did not press the pair button.

Bug: 231554812
Test: Changed settings app is able to scan after dismissing the dialog
and is also able to pair when the pair button is pressed

Change-Id: I868af9b795f1bb0766656e4619bd06dc8028008a
Merged-In: I868af9b795f1bb0766656e4619bd06dc8028008a
This commit is contained in:
Qasim Javed
2022-05-10 11:19:27 -07:00
parent fbbd1f1109
commit 29b7f1d5fa

View File

@@ -55,6 +55,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
private BluetoothPairingController mPairingController; private BluetoothPairingController mPairingController;
private BluetoothPairingDialog mPairingDialogActivity; private BluetoothPairingDialog mPairingDialogActivity;
private EditText mPairingView; private EditText mPairingView;
private boolean mPositiveClicked = false;
/** /**
* The interface we expect a listener to implement. Typically this should be done by * The interface we expect a listener to implement. Typically this should be done by
* the controller. * the controller.
@@ -85,7 +86,9 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
mPairingController.onCancel(); if (!mPositiveClicked) {
mPairingController.onCancel();
}
} }
@Override @Override
@@ -110,6 +113,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) { if (which == DialogInterface.BUTTON_POSITIVE) {
mPositiveClicked = true;
mPairingController.onDialogPositiveClick(this); mPairingController.onDialogPositiveClick(this);
} else if (which == DialogInterface.BUTTON_NEGATIVE) { } else if (which == DialogInterface.BUTTON_NEGATIVE) {
mPairingController.onDialogNegativeClick(this); mPairingController.onDialogNegativeClick(this);