Merge "Skips the bluetooth consent pairing dialog if the device has recently been associated with the companion app that requested the bond through CDM" into sc-dev am: 9b6ce3e0db

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/13534591

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I93fccd03b41e86f1e68b0868c57c2ead5a4bc97b
This commit is contained in:
Rahul Sabnis
2021-02-16 23:58:45 +00:00
committed by Automerger Merge Worker

View File

@@ -37,20 +37,26 @@ public final class BluetoothPairingRequest extends BroadcastReceiver {
if (action == null || !action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) { if (action == null || !action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
return; return;
} }
PowerManager powerManager = PowerManager powerManager = context.getSystemService(PowerManager.class);
(PowerManager)context.getSystemService(Context.POWER_SERVICE);
BluetoothDevice device = BluetoothDevice device =
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.ERROR);
String deviceAddress = device != null ? device.getAddress() : null; String deviceAddress = device != null ? device.getAddress() : null;
String deviceName = device != null ? device.getName() : null; String deviceName = device != null ? device.getName() : null;
boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground( boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground(
context, deviceAddress, deviceName); 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, // Since the screen is on and the BT-related activity is in the foreground,
// just open the dialog // just open the dialog
// convert broadcast intent into activity intent (same action string) // convert broadcast intent into activity intent (same action string)
Intent pairingIntent = BluetoothPairingService.getPairingDialogIntent(context, intent, Intent pairingIntent = BluetoothPairingService.getPairingDialogIntent(context, intent,
BluetoothDevice.EXTRA_PAIRING_INITIATOR_FOREGROUND); BluetoothDevice.EXTRA_PAIRING_INITIATOR_FOREGROUND);
context.startActivityAsUser(pairingIntent, UserHandle.CURRENT); context.startActivityAsUser(pairingIntent, UserHandle.CURRENT);
} else { } else {