GATT: Expose opportunistic client API to Java
* Allow Java based programs to create an opportunistic GATT client
* Such client does not hold a GATT connection. It automatically
disconnects when no other GATT connections are active for the
remote device.
Bug: 63347806
Test: make, run battery service
Change-Id: Ib9333817d7f17a1fa3ddacfa51c680890bac19ec
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java
index b12ff72..1307f07 100644
--- a/core/java/android/bluetooth/BluetoothGatt.java
+++ b/core/java/android/bluetooth/BluetoothGatt.java
@@ -53,6 +53,7 @@
private Boolean mDeviceBusy = false;
private int mTransport;
private int mPhy;
+ private boolean mOpportunistic;
private static final int AUTH_RETRY_STATE_IDLE = 0;
private static final int AUTH_RETRY_STATE_NO_MITM = 1;
@@ -172,7 +173,7 @@
}
try {
mService.clientConnect(mClientIf, mDevice.getAddress(),
- !mAutoConnect, mTransport, mPhy); // autoConnect is inverse of "isDirect"
+ !mAutoConnect, mTransport, mOpportunistic, mPhy); // autoConnect is inverse of "isDirect"
} catch (RemoteException e) {
Log.e(TAG,"",e);
}
@@ -628,11 +629,12 @@
};
/*package*/ BluetoothGatt(IBluetoothGatt iGatt, BluetoothDevice device,
- int transport, int phy) {
+ int transport, boolean opportunistic, int phy) {
mService = iGatt;
mDevice = device;
mTransport = transport;
mPhy = phy;
+ mOpportunistic = opportunistic;
mServices = new ArrayList<BluetoothGattService>();
mConnState = CONN_STATE_IDLE;
@@ -839,8 +841,8 @@
*/
public boolean connect() {
try {
- mService.clientConnect(mClientIf, mDevice.getAddress(),
- false, mTransport, mPhy); // autoConnect is inverse of "isDirect"
+ mService.clientConnect(mClientIf, mDevice.getAddress(), false, mTransport,
+ mOpportunistic, mPhy); // autoConnect is inverse of "isDirect"
return true;
} catch (RemoteException e) {
Log.e(TAG,"",e);