Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc2d0edc authored by Jack He's avatar Jack He
Browse files

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
parent 8dc2e50c
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -250,7 +250,8 @@ bt_status_t btif_gattc_unregister_app(int client_if) {
}

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 @@ void btif_gattc_open_impl(int client_if, RawAddress address, bool is_direct,
  // 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) {
+2 −1
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ bt_status_t FakeUnregisterClient(int client_if) {
}

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);

+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ bool LowEnergyClient::Connect(const std::string& address, bool is_direct) {

  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;