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

Commit 0a09d568 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Clean up BTA_GATTC_Open

Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: I12263c05acd4ba04e09544b95388a13461dc4e93
parent 301b6036
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -3716,11 +3716,9 @@ void btm_dm_start_gatt_discovery(const RawAddress& bd_addr) {
    BTA_GATTC_ServiceSearchRequest(bta_dm_search_cb.conn_id, nullptr);
  } else {
    if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
      BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true, BT_TRANSPORT_LE,
                     true);
      BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true, true);
    } else {
      BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true, BT_TRANSPORT_LE,
                     false);
      BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true, false);
    }
  }
}
+3 −4
Original line number Diff line number Diff line
@@ -119,11 +119,10 @@ void BTA_GATTC_AppDeregister(tGATT_IF 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, bool opportunistic) {
  uint8_t phy = controller_get_interface()->get_le_all_initiating_phys();
  BTA_GATTC_Open(client_if, remote_bda, is_direct, transport, opportunistic,
                 phy);
  BTA_GATTC_Open(client_if, remote_bda, is_direct, BT_TRANSPORT_LE,
                 opportunistic, phy);
}

void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
+4 −5
Original line number Diff line number Diff line
@@ -314,13 +314,13 @@ class HearingAidImpl : public HearingAid {
  void Connect(const RawAddress& address) override {
    DVLOG(2) << __func__ << " " << address;
    hearingDevices.Add(HearingDevice(address, true));
    BTA_GATTC_Open(gatt_if, address, true, BT_TRANSPORT_LE, false);
    BTA_GATTC_Open(gatt_if, address, true, false);
  }

  void AddToAcceptlist(const RawAddress& address) override {
    VLOG(2) << __func__ << " address: " << address;
    hearingDevices.Add(HearingDevice(address, true));
    BTA_GATTC_Open(gatt_if, address, false, BT_TRANSPORT_LE, false);
    BTA_GATTC_Open(gatt_if, address, false, false);
  }

  void AddFromStorage(const HearingDevice& dev_info, uint16_t is_acceptlisted) {
@@ -335,7 +335,7 @@ class HearingAidImpl : public HearingAid {
      // BTM_BleSetConnScanParams(2048, 1024);

      /* add device into BG connection to accept remote initiated connection */
      BTA_GATTC_Open(gatt_if, dev_info.address, false, BT_TRANSPORT_LE, false);
      BTA_GATTC_Open(gatt_if, dev_info.address, false, false);
    }

    callbacks->OnDeviceAvailable(dev_info.capabilities, dev_info.hi_sync_id,
@@ -1487,8 +1487,7 @@ class HearingAidImpl : public HearingAid {

    // This is needed just for the first connection. After stack is restarted,
    // code that loads device will add them to acceptlist.
    BTA_GATTC_Open(gatt_if, hearingDevice->address, false, BT_TRANSPORT_LE,
                   false);
    BTA_GATTC_Open(gatt_if, hearingDevice->address, false, false);

    callbacks->OnConnectionState(ConnectionState::DISCONNECTED, remote_bda);

+2 −3
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda) {
  bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index;
  p_cb->in_use = true;

  BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, true, BT_TRANSPORT_LE, false);
  BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, true, false);
}

/*******************************************************************************
@@ -1965,8 +1965,7 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB* p_cb, bool check_bond) {

  if (!p_cb->in_bg_conn && to_add) {
    /* add device into BG connection to accept remote initiated connection */
    BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, false, BT_TRANSPORT_LE,
                   false);
    BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, false, false);
    p_cb->in_bg_conn = true;
  }
  return;
+1 −2
Original line number Diff line number Diff line
@@ -463,8 +463,7 @@ extern void BTA_GATTC_AppDeregister(tGATT_IF client_if);
 *
 ******************************************************************************/
extern void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
                           bool is_direct, tBT_TRANSPORT transport,
                           bool opportunistic);
                           bool is_direct, bool opportunistic);
extern void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
                           bool is_direct, tBT_TRANSPORT transport,
                           bool opportunistic, uint8_t initiating_phys);