summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Eisenbach <eisenbach@google.com>2014-08-04 17:51:43 -0700
committerAndre Eisenbach <eisenbach@google.com>2014-08-05 17:01:13 +0000
commit57210c7a1aebb86d091dee0af49b45649ca47f87 (patch)
tree3c5feb0d4b5e8ed4fa0a6ef19cf948c004c3d26e
parent62a7c831d54d0a552f059e70176ccf7ac77e57f4 (diff)
downloadframeworks_base-57210c7a1aebb86d091dee0af49b45649ca47f87.zip
frameworks_base-57210c7a1aebb86d091dee0af49b45649ca47f87.tar.gz
frameworks_base-57210c7a1aebb86d091dee0af49b45649ca47f87.tar.bz2
Add transport parameter to createBond() function (4/4)
Bug: 14063256 Change-Id: I096248b60752992aa23ce5bfbfc47fda95773db2
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java33
-rw-r--r--core/java/android/bluetooth/IBluetooth.aidl2
2 files changed, 33 insertions, 2 deletions
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index a94bc41..860512b 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -760,7 +760,38 @@ public final class BluetoothDevice implements Parcelable {
return false;
}
try {
- return sService.createBond(this);
+ return sService.createBond(this, TRANSPORT_AUTO);
+ } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return false;
+ }
+
+ /**
+ * Start the bonding (pairing) process with the remote device using the
+ * specified transport.
+ *
+ * <p>This is an asynchronous call, it will return immediately. Register
+ * for {@link #ACTION_BOND_STATE_CHANGED} intents to be notified when
+ * the bonding process completes, and its result.
+ * <p>Android system services will handle the necessary user interactions
+ * to confirm and complete the bonding process.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
+ *
+ * @param transport The transport to use for the pairing procedure.
+ * @return false on immediate error, true if bonding will begin
+ * @throws IllegalArgumentException if an invalid transport was specified
+ * @hide
+ */
+ public boolean createBond(int transport) {
+ if (sService == 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 {
+ return sService.createBond(this, transport);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index ca55803..19c600c 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -55,7 +55,7 @@ interface IBluetooth
int getProfileConnectionState(int profile);
BluetoothDevice[] getBondedDevices();
- boolean createBond(in BluetoothDevice device);
+ boolean createBond(in BluetoothDevice device, in int transport);
boolean cancelBondProcess(in BluetoothDevice device);
boolean removeBond(in BluetoothDevice device);
int getBondState(in BluetoothDevice device);