From faa36472574162c7e96ec4a5da4227afe50c1c12 Mon Sep 17 00:00:00 2001 From: Rahul Sabnis Date: Mon, 1 Feb 2021 14:22:00 -0800 Subject: [PATCH] Skips the bluetooth consent pairing dialog if the device has recently been associated with the companion app that requested the bond through CDM Bug: 172006481 Test: Manual Change-Id: I9a8ae1c3c7aed46295e7b0958b5c1b59960e3a26 --- .../bluetooth/BluetoothPairingRequest.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java index 0e4ed74f695..d7dad887fec 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java @@ -37,20 +37,26 @@ public final class BluetoothPairingRequest extends BroadcastReceiver { if (action == null || !action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) { return; } - PowerManager powerManager = - (PowerManager)context.getSystemService(Context.POWER_SERVICE); + PowerManager powerManager = context.getSystemService(PowerManager.class); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); + int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, + BluetoothDevice.ERROR); String deviceAddress = device != null ? device.getAddress() : null; String deviceName = device != null ? device.getName() : null; boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground( context, deviceAddress, deviceName); - if (powerManager.isInteractive() && shouldShowDialog) { + + // Skips consent pairing dialog if the device was recently associated with CDM + if (pairingVariant == BluetoothDevice.PAIRING_VARIANT_CONSENT + && device.canBondWithoutDialog()) { + device.setPairingConfirmation(true); + } else if (powerManager.isInteractive() && shouldShowDialog) { // Since the screen is on and the BT-related activity is in the foreground, // just open the dialog // convert broadcast intent into activity intent (same action string) Intent pairingIntent = BluetoothPairingService.getPairingDialogIntent(context, intent, - BluetoothDevice.EXTRA_PAIRING_INITIATOR_FOREGROUND); + BluetoothDevice.EXTRA_PAIRING_INITIATOR_FOREGROUND); context.startActivityAsUser(pairingIntent, UserHandle.CURRENT); } else {