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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user