From ae98cec967519ccac21c6977a72cdbf5278eb34e Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Tue, 26 Nov 2019 21:55:15 -0800 Subject: 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 --- core/java/android/bluetooth/BluetoothDevice.java | 35 ++---------------------- 1 file 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); } -- cgit v1.2.3-59-g8ed1b