GATT: Expose opportunistic client API to Java
* Opportunistic GATT connection allows system service to subscribe to
characteristic notifications without holding the BLE connection
* Exposing this flag to Java allows Android applications to use it
Bug: 35874078
Test: make, test on Android App
Change-Id: Ic470acd63bf45d1c33696abed1e93b30746fb7a2
diff --git a/btif/src/btif_gatt_client.cc b/btif/src/btif_gatt_client.cc
index 59b8bab..69a1665 100644
--- a/btif/src/btif_gatt_client.cc
+++ b/btif/src/btif_gatt_client.cc
@@ -250,7 +250,8 @@
}
void btif_gattc_open_impl(int client_if, RawAddress address, bool is_direct,
- int transport_p, int initiating_phys) {
+ int transport_p, bool opportunistic,
+ int initiating_phys) {
// Ensure device is in inquiry database
int addr_type = 0;
int device_type = 0;
@@ -305,17 +306,18 @@
// Connect!
BTIF_TRACE_DEBUG("%s Transport=%d, device type=%d, phy=%d", __func__,
transport, device_type, initiating_phys);
- BTA_GATTC_Open(client_if, address, is_direct, transport, false,
+ BTA_GATTC_Open(client_if, address, is_direct, transport, opportunistic,
initiating_phys);
}
bt_status_t btif_gattc_open(int client_if, const RawAddress& bd_addr,
- bool is_direct, int transport,
+ bool is_direct, int transport, bool opportunistic,
int initiating_phys) {
CHECK_BTGATT_INIT();
// Closure will own this value and free it.
return do_in_jni_thread(Bind(&btif_gattc_open_impl, client_if, bd_addr,
- is_direct, transport, initiating_phys));
+ is_direct, transport, opportunistic,
+ initiating_phys));
}
void btif_gattc_close_impl(int client_if, RawAddress address, int conn_id) {
diff --git a/service/hal/fake_bluetooth_gatt_interface.cc b/service/hal/fake_bluetooth_gatt_interface.cc
index f6f521b..42ccb51 100644
--- a/service/hal/fake_bluetooth_gatt_interface.cc
+++ b/service/hal/fake_bluetooth_gatt_interface.cc
@@ -41,7 +41,8 @@
}
bt_status_t FakeConnect(int client_if, const RawAddress& bd_addr,
- bool is_direct, int transport, int phy) {
+ bool is_direct, int transport, bool opportunistic,
+ int phy) {
if (g_client_handler)
return g_client_handler->Connect(client_if, bd_addr, is_direct, transport);
diff --git a/service/low_energy_client.cc b/service/low_energy_client.cc
index 5894676..97f3ca6 100644
--- a/service/low_energy_client.cc
+++ b/service/low_energy_client.cc
@@ -58,7 +58,7 @@
bt_status_t status =
hal::BluetoothGattInterface::Get()->GetClientHALInterface()->connect(
- client_id_, bda, is_direct, BT_TRANSPORT_LE, PHY_LE_1M_MASK);
+ client_id_, bda, is_direct, BT_TRANSPORT_LE, false, PHY_LE_1M_MASK);
if (status != BT_STATUS_SUCCESS) {
LOG(ERROR) << "HAL call to connect failed";
return false;