aboutsummaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothDevice.java
diff options
context:
space:
mode:
authorRahul Sabnis <rahulsabnis@google.com>2021-01-29 12:38:13 -0800
committerRahul Sabnis <rahulsabnis@google.com>2021-02-10 21:25:36 +0000
commit182e8c12f27517c7c11f535472c65fae6c17c500 (patch)
tree17e4635b5dc98a55be533160cc74e0af457abb18 /framework/java/android/bluetooth/BluetoothDevice.java
parent65b57adaa21dde636880ab8c133de2b1206d2a3b (diff)
Skips the consent pairing dialog for recently associated CDM app and device combos because they have already been shown the CDM prompt which implicitly provides consent to bond.
Tag: #feature Bug: 172006481 Test: Manual Change-Id: I541b720c6b8b6e55be10e04f202e0a58cf33715f
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothDevice.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index 3b8dec7bf9..e7661dbad7 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/java/android/bluetooth/BluetoothDevice.java
@@ -1236,7 +1236,8 @@ public final class BluetoothDevice implements Parcelable {
return false;
}
try {
- return service.createBond(this, transport, oobData);
+ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+ return service.createBond(this, transport, oobData, adapter.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "", e);
}
@@ -1394,6 +1395,31 @@ public final class BluetoothDevice implements Parcelable {
}
/**
+ * Checks whether this bluetooth device is associated with CDM and meets the criteria to skip
+ * the bluetooth pairing dialog because it has been already consented by the CDM prompt.
+ *
+ * @return true if we can bond without the dialog, false otherwise
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ public boolean canBondWithoutDialog() {
+ final IBluetooth service = sService;
+ if (service == null) {
+ Log.e(TAG, "BT not enabled. Cannot check if we can skip pairing dialog");
+ return false;
+ }
+ try {
+ if (DBG) Log.d(TAG, "canBondWithoutDialog, device: " + this);
+ return service.canBondWithoutDialog(this);
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
+ return false;
+ }
+
+ /**
* Returns whether there is an open connection to this device.
*
* @return True if there is at least one open connection to this device.