summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zach Johnson <zachoverflow@google.com> 2019-11-26 21:55:15 -0800
committer Zach Johnson <zachoverflow@google.com> 2019-11-26 21:55:15 -0800
commitae98cec967519ccac21c6977a72cdbf5278eb34e (patch)
tree511e0db283229b8ee753a193e30741b81f1e25a4
parent1c86ed1ec4fd3290f699e44c3a9b1f891c1b3f82 (diff)
Collapse the implementations of BluetoothDevice.createBond
The backend is now a single function. Remove duplicate code/ Bug: 145171640 Test: compile, and try pairing Change-Id: I04e8f95430d0de245926e849ea71eff030294bc1
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java35
1 files changed, 3 insertions, 32 deletions
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 0be3eca8239e..49187dcde342 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -1131,20 +1131,7 @@ public final class BluetoothDevice implements Parcelable {
*/
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean createBond() {
- final IBluetooth service = sService;
- if (service == null) {
- Log.e(TAG, "BT not enabled. Cannot create bond to Remote Device");
- return false;
- }
- try {
- Log.i(TAG, "createBond() for device " + getAddress()
- + " called by pid: " + Process.myPid()
- + " tid: " + Process.myTid());
- return service.createBond(this, TRANSPORT_AUTO);
- } catch (RemoteException e) {
- Log.e(TAG, "", e);
- }
- return false;
+ return createBond(TRANSPORT_AUTO);
}
/**
@@ -1165,23 +1152,7 @@ public final class BluetoothDevice implements Parcelable {
*/
@UnsupportedAppUsage
public boolean createBond(int transport) {
- final IBluetooth service = sService;
- if (service == null) {
- Log.e(TAG, "BT not enabled. Cannot create bond to Remote Device");
- return false;
- }
- if (TRANSPORT_AUTO > transport || transport > TRANSPORT_LE) {
- throw new IllegalArgumentException(transport + " is not a valid Bluetooth transport");
- }
- try {
- Log.i(TAG, "createBond() for device " + getAddress()
- + " called by pid: " + Process.myPid()
- + " tid: " + Process.myTid());
- return service.createBond(this, transport);
- } catch (RemoteException e) {
- Log.e(TAG, "", e);
- }
- return false;
+ return createBondOutOfBand(transport, null);
}
/**
@@ -1209,7 +1180,7 @@ public final class BluetoothDevice implements Parcelable {
return false;
}
try {
- return service.createBondOutOfBand(this, transport, oobData);
+ return service.createBond(this, transport, oobData);
} catch (RemoteException e) {
Log.e(TAG, "", e);
}