diff options
| author | Jack He <siyuanh@google.com> | 2017-07-11 20:23:53 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2017-07-11 20:23:53 +0000 |
| commit | d3ff37db60156c45f2cced8224a8529011027159 (patch) | |
| tree | 1629d16e31e78cfcb6a8dcf72f3cd50ebf2405f9 /framework/java/android/bluetooth/BluetoothDevice.java | |
| parent | a249f99fb1891c5b06b0742c4b21f0c95240a2d4 (diff) | |
| parent | 13bfc3676625419a854f0ee394ef3746d2b93cf0 (diff) | |
Merge "GATT: Expose opportunistic client API to Java"
am: 13bfc36766
Change-Id: If29bc145c1947f2e10472565ae753696e8057dd1
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothDevice.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java index 27b802e59c..a206b53b53 100644 --- a/framework/java/android/bluetooth/BluetoothDevice.java +++ b/framework/java/android/bluetooth/BluetoothDevice.java @@ -1758,6 +1758,38 @@ public final class BluetoothDevice implements Parcelable { public BluetoothGatt connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback, int transport, int phy, Handler handler) { + return connectGatt(context, autoConnect, callback, transport, false, phy, handler); + } + + /** + * Connect to GATT Server hosted by this device. Caller acts as GATT client. + * The callback is used to deliver results to Caller, such as connection status as well + * as any further GATT client operations. + * The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct + * GATT client operations. + * @param callback GATT callback handler that will receive asynchronous callbacks. + * @param autoConnect Whether to directly connect to the remote device (false) + * or to automatically connect as soon as the remote + * device becomes available (true). + * @param transport preferred transport for GATT connections to remote dual-mode devices + * {@link BluetoothDevice#TRANSPORT_AUTO} or + * {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE} + * @param opportunistic Whether this GATT client is opportunistic. An opportunistic GATT client + * does not hold a GATT connection. It automatically disconnects when no + * other GATT connections are active for the remote device. + * @param phy preferred PHY for connections to remote LE device. Bitwise OR of any of + * {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK}, + * an d{@link BluetoothDevice#PHY_LE_CODED_MASK}. This option does not take effect + * if {@code autoConnect} is set to true. + * @param handler The handler to use for the callback. If {@code null}, callbacks will happen + * on an un-specified background thread. + * @return A BluetoothGatt instance. You can use BluetoothGatt to conduct GATT client + * operations. + * @hide + */ + public BluetoothGatt connectGatt(Context context, boolean autoConnect, + BluetoothGattCallback callback, int transport, + boolean opportunistic, int phy, Handler handler) { if (callback == null) throw new NullPointerException("callback is null"); @@ -1771,7 +1803,7 @@ public final class BluetoothDevice implements Parcelable { // BLE is not supported return null; } - BluetoothGatt gatt = new BluetoothGatt(iGatt, this, transport, phy); + BluetoothGatt gatt = new BluetoothGatt(iGatt, this, transport, opportunistic, phy); gatt.connect(autoConnect, callback, handler); return gatt; } catch (RemoteException e) {Log.e(TAG, "", e);} |
