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

Commit eb04fcc1 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge changes Id69b2c8d,I6dc89d7c,I61ffc69a,Ib46f2106,I9b2f1b15, ...

* changes:
  bta/test: Extend gatt queue mock
  bta/test: Improve gatt mock api
  bt: Minor clang-format
  bt: Minor log fix
  bta/test: Add CSIS mocks
  bta/test: Add group mocks for unit tests
  gatt: Notify all gatt clients about encryption change
parents 244948e1 46ad9758
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -850,9 +850,8 @@ static bool in_state_transition_timeout(BluetoothStreamIn* in,

    /* Don't block AF forever */
    if (--timeout_ms <= 0) {
      LOG(WARNING) << __func__
                   << ", can't suspend - stucked in suspending"
                      " state";
      LOG(WARNING) << __func__ << ", can't suspend - stucked in: "
                   << static_cast<int>(state) << " state";
      return false;
    }
  }
+0 −8
Original line number Diff line number Diff line
@@ -1151,14 +1151,6 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, const RawAddress& bda) {

  if (p_clcb == NULL) return;

  /* filter this event just for BTA HH LE GATT client,
   * In the future, if we want to enable encryption complete event
   * for all GATT clients, we can remove this code
   */
  if (!bta_hh_le_is_hh_gatt_if(gattc_if)) {
    return;
  }

  VLOG(1) << __func__ << ": cif:" << +gattc_if;

  do_in_main_thread(FROM_HERE,
+23 −4
Original line number Diff line number Diff line
@@ -26,54 +26,72 @@ void gatt::SetMockBtaGattInterface(

void BTA_GATTC_AppRegister(tBTA_GATTC_CBACK* p_client_cb,
                           BtaAppRegisterCallback cb, bool eatt_support) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  gatt_interface->AppRegister(p_client_cb, cb, eatt_support);
}

void BTA_GATTC_AppDeregister(tGATT_IF client_if) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  gatt_interface->AppDeregister(client_if);
}

void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
                    bool is_direct, tBT_TRANSPORT transport,
                    bool opportunistic) {
                    bool is_direct, tBT_TRANSPORT transport, bool opportunistic,
                    uint8_t initiating_phys) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  gatt_interface->Open(client_if, remote_bda, is_direct, transport,
                       opportunistic);
                       opportunistic, initiating_phys);
}

void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
                    bool is_direct, bool opportunistic) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  gatt_interface->Open(client_if, remote_bda, is_direct, opportunistic);
}

void BTA_GATTC_CancelOpen(tGATT_IF client_if, const RawAddress& remote_bda,
                          bool is_direct) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  gatt_interface->CancelOpen(client_if, remote_bda, is_direct);
}

void BTA_GATTC_Close(uint16_t conn_id) { gatt_interface->Close(conn_id); }
void BTA_GATTC_Close(uint16_t conn_id) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  gatt_interface->Close(conn_id);
}

void BTA_GATTC_ServiceSearchRequest(uint16_t conn_id,
                                    const bluetooth::Uuid* p_srvc_uuid) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  gatt_interface->ServiceSearchRequest(conn_id, p_srvc_uuid);
}

void BTA_GATTC_SendIndConfirm(uint16_t conn_id, uint16_t cid) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  gatt_interface->SendIndConfirm(conn_id, cid);
}

const std::list<gatt::Service>* BTA_GATTC_GetServices(uint16_t conn_id) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  return gatt_interface->GetServices(conn_id);
}

const gatt::Characteristic* BTA_GATTC_GetCharacteristic(uint16_t conn_id,
                                                        uint16_t handle) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  return gatt_interface->GetCharacteristic(conn_id, handle);
}

const gatt::Service* BTA_GATTC_GetOwningService(uint16_t conn_id,
                                                uint16_t handle) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  return gatt_interface->GetOwningService(conn_id, handle);
}

tGATT_STATUS BTA_GATTC_RegisterForNotifications(tGATT_IF client_if,
                                                const RawAddress& remote_bda,
                                                uint16_t handle) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  return gatt_interface->RegisterForNotifications(client_if, remote_bda,
                                                  handle);
}
@@ -81,6 +99,7 @@ tGATT_STATUS BTA_GATTC_RegisterForNotifications(tGATT_IF client_if,
tGATT_STATUS BTA_GATTC_DeregisterForNotifications(tGATT_IF client_if,
                                                  const RawAddress& remote_bda,
                                                  uint16_t handle) {
  LOG_ASSERT(gatt_interface) << "Mock GATT interface not set!";
  return gatt_interface->DeregisterForNotifications(client_if, remote_bda,
                                                    handle);
}
+8 −3
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ class BtaGattInterface {
                           BtaAppRegisterCallback cb, bool eatt_support) = 0;
  virtual void AppDeregister(tGATT_IF client_if) = 0;
  virtual void Open(tGATT_IF client_if, const RawAddress& remote_bda,
                    bool is_direct, tBT_TRANSPORT transport,
                    bool opportunistic) = 0;
                    bool is_direct, tBT_TRANSPORT transport, bool opportunistic,
                    uint8_t initiating_phys) = 0;
  virtual void Open(tGATT_IF client_if, const RawAddress& remote_bda,
                    bool is_direct, bool opportunistic) = 0;
  virtual void CancelOpen(tGATT_IF client_if, const RawAddress& remote_bda,
@@ -38,6 +38,7 @@ class BtaGattInterface {
  virtual void Close(uint16_t conn_id) = 0;
  virtual void ServiceSearchRequest(uint16_t conn_id,
                                    const bluetooth::Uuid* p_srvc_uuid) = 0;
  virtual void SendIndConfirm(uint16_t conn_id, uint16_t cid) = 0;
  virtual const std::list<Service>* GetServices(uint16_t conn_id) = 0;
  virtual const Characteristic* GetCharacteristic(uint16_t conn_id,
                                                  uint16_t handle) = 0;
@@ -61,7 +62,9 @@ class MockBtaGattInterface : public BtaGattInterface {
  MOCK_METHOD((void), AppDeregister, (tGATT_IF client_if), (override));
  MOCK_METHOD((void), Open,
              (tGATT_IF client_if, const RawAddress& remote_bda, bool is_direct,
               tBT_TRANSPORT transport, bool opportunistic));
               tBT_TRANSPORT transport, bool opportunistic,
               uint8_t initiating_phys),
              (override));
  MOCK_METHOD((void), Open,
              (tGATT_IF client_if, const RawAddress& remote_bda, bool is_direct,
               bool opportunistic));
@@ -71,6 +74,8 @@ class MockBtaGattInterface : public BtaGattInterface {
  MOCK_METHOD((void), Close, (uint16_t conn_id));
  MOCK_METHOD((void), ServiceSearchRequest,
              (uint16_t conn_id, const bluetooth::Uuid* p_srvc_uuid));
  MOCK_METHOD((void), SendIndConfirm, (uint16_t conn_id, uint16_t cid),
              (override));
  MOCK_METHOD((std::list<Service>*), GetServices, (uint16_t conn_id));
  MOCK_METHOD((const Characteristic*), GetCharacteristic,
              (uint16_t conn_id, uint16_t handle));
+5 −0
Original line number Diff line number Diff line
@@ -44,3 +44,8 @@ void BtaGattQueue::WriteDescriptor(uint16_t conn_id, uint16_t handle,
                                   GATT_WRITE_OP_CB cb, void* cb_data) {
  gatt_queue->WriteDescriptor(conn_id, handle, value, write_type, cb, cb_data);
}

void BtaGattQueue::ConfigureMtu(uint16_t conn_id, uint16_t mtu) {
  LOG_ASSERT(gatt_queue) << "Mock GATT queue not set!";
  gatt_queue->ConfigureMtu(conn_id, mtu);
}
Loading