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

Commit 2b6b89ca authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I241a2915,I4281a4f0,Id0847f16,I459e99c4,Ia8aec848, ...

* changes:
  Fix proper headers to stack/acl/btm_acl::btm_cont_rswitch
  Move btm_pm_find_acl_ind() into stack/btm/btm_acl
  Add stack/acl/btm_acl APIs
  Declare and define tACL_CONN variables together
  Internally link stack/acl/btm_acl btm_establish_continue
  Shift stack/l2cap/l2c_ble.cc to use new API
  Move BTM_ReadConnectionAddr from btm to acl
parents 39c7b56b a84998f8
Loading
Loading
Loading
Loading
+74 −1
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ tBTM_SEC_DEV_REC* btm_find_or_alloc_dev(const RawAddress& bd_addr);
tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec);
void btm_ble_refresh_local_resolvable_private_addr(
    const RawAddress& pseudo_addr, const RawAddress& local_rpa);
void btm_establish_continue(tACL_CONN* p_acl_cb);
void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec, uint8_t res,
                                 bool is_le_trasnport);
void btm_sec_set_peer_sec_caps(tACL_CONN* p_acl_cb,
@@ -66,6 +65,7 @@ void btm_sec_set_peer_sec_caps(tACL_CONN* p_acl_cb,

static void btm_acl_chk_peer_pkt_type_support(tACL_CONN* p,
                                              uint16_t* p_pkt_type);
static void btm_establish_continue(tACL_CONN* p_acl_cb);
static void btm_pm_sm_alloc(uint8_t ind);
static void btm_read_automatic_flush_timeout_timeout(void* data);
static void btm_read_failed_contact_counter_timeout(void* data);
@@ -2469,6 +2469,36 @@ bool acl_peer_supports_ble_connection_parameters_request(
  return HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl->peer_le_features);
}

/*******************************************************************************
 *
 * Function         BTM_ReadConnectionAddr
 *
 * Description      This function is called to get the local device address
 *                  information.
 *
 * Returns          void
 *
 ******************************************************************************/
void BTM_ReadConnectionAddr(const RawAddress& remote_bda,
                            RawAddress& local_conn_addr,
                            tBLE_ADDR_TYPE* p_addr_type) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_ReadConnectionAddr(remote_bda, local_conn_addr,
                                                   p_addr_type);
  }
  tACL_CONN* p_acl = btm_bda_to_acl(remote_bda, BT_TRANSPORT_LE);

  if (p_acl == NULL) {
    BTM_TRACE_ERROR("No connection exist!");
    return;
  }
  local_conn_addr = p_acl->conn_addr;
  *p_addr_type = p_acl->conn_addr_type;

  BTM_TRACE_DEBUG("BTM_ReadConnectionAddr address type: %d addr: 0x%02x",
                  p_acl->conn_addr_type, p_acl->conn_addr.address[0]);
}

/*******************************************************************************
 *
 * Function         BTM_IsBleConnection
@@ -2490,3 +2520,46 @@ bool BTM_IsBleConnection(uint16_t hci_handle) {
  tACL_CONN* p = &btm_cb.acl_cb_.acl_db[index];
  return (p->transport == BT_TRANSPORT_LE);
}

const RawAddress acl_address_from_handle(uint16_t hci_handle) {
  uint8_t index = btm_handle_to_acl_index(hci_handle);
  if (index >= MAX_L2CAP_LINKS) {
    return RawAddress::kEmpty;
  }
  return btm_cb.acl_cb_.acl_db[index].remote_addr;
}

tBTM_PM_MCB* acl_power_mode_from_handle(uint16_t hci_handle) {
  uint8_t index = btm_handle_to_acl_index(hci_handle);
  if (index >= MAX_L2CAP_LINKS) {
    return nullptr;
  }
  return &btm_cb.pm_mode_db[index];
}

/*******************************************************************************
 *
 * Function         btm_pm_find_acl_ind
 *
 * Description      This function initializes the control block of an ACL link.
 *                  It is called when an ACL connection is created.
 *
 * Returns          void
 *
 ******************************************************************************/
int btm_pm_find_acl_ind(const RawAddress& remote_bda) {
  tACL_CONN* p = &btm_cb.acl_cb_.acl_db[0];
  uint8_t xx;

  for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p++) {
    if (p->in_use && p->remote_addr == remote_bda &&
        p->transport == BT_TRANSPORT_BR_EDR) {
#if (BTM_PM_DEBUG == TRUE)
      BTM_TRACE_DEBUG("btm_pm_find_acl_ind ind:%d, st:%d", xx,
                      btm_cb.pm_mode_db[xx].state);
#endif  // BTM_PM_DEBUG
      break;
    }
  }
  return xx;
}
+0 −30
Original line number Diff line number Diff line
@@ -229,36 +229,6 @@ const Octet16& BTM_GetDeviceDHK() {
  return btm_cb.devcb.id_keys.dhk;
}

/*******************************************************************************
 *
 * Function         BTM_ReadConnectionAddr
 *
 * Description      This function is called to get the local device address
 *                  information.
 *
 * Returns          void
 *
 ******************************************************************************/
void BTM_ReadConnectionAddr(const RawAddress& remote_bda,
                            RawAddress& local_conn_addr,
                            tBLE_ADDR_TYPE* p_addr_type) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_ReadConnectionAddr(remote_bda, local_conn_addr,
                                                   p_addr_type);
  }
  tACL_CONN* p_acl = btm_bda_to_acl(remote_bda, BT_TRANSPORT_LE);

  if (p_acl == NULL) {
    BTM_TRACE_ERROR("No connection exist!");
    return;
  }
  local_conn_addr = p_acl->conn_addr;
  *p_addr_type = p_acl->conn_addr_type;

  BTM_TRACE_DEBUG("BTM_ReadConnectionAddr address type: %d addr: 0x%02x",
                  p_acl->conn_addr_type, p_acl->conn_addr.address[0]);
}

/*******************************************************************************
 *
 * Function       BTM_ReadRemoteConnectionAddr
+0 −4
Original line number Diff line number Diff line
@@ -87,9 +87,6 @@ extern void btm_acl_device_down(void);
extern void btm_acl_set_paging(bool value);
extern void btm_acl_update_inquiry_status(uint8_t state);

extern void btm_cont_rswitch(tACL_CONN* p, tBTM_SEC_DEV_REC* p_dev_rec,
                             uint8_t hci_status);

extern uint8_t btm_handle_to_acl_index(uint16_t hci_handle);

extern void btm_read_rssi_complete(uint8_t* p);
@@ -116,7 +113,6 @@ extern void btm_read_remote_ext_features_complete(uint8_t* p, uint8_t evt_len);
extern void btm_read_remote_ext_features_failed(uint8_t status,
                                                uint16_t handle);
extern void btm_read_remote_version_complete(uint8_t* p);
extern void btm_establish_continue(tACL_CONN* p_acl_cb);

extern tACL_CONN* btm_bda_to_acl(const RawAddress& bda,
                                 tBT_TRANSPORT transport);
+6 −35
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ const uint8_t
        BTM_PM_GET_MD1,  BTM_PM_GET_MD2,  BTM_PM_GET_COMP};

/* function prototype */
static int btm_pm_find_acl_ind(const RawAddress& remote_bda);
static tBTM_STATUS btm_pm_snd_md_req(uint8_t pm_id, int link_ind,
                                     const tBTM_PM_PWR_MD* p_mode);
static const char* mode_to_string(const tBTM_PM_MODE mode);
@@ -365,33 +364,6 @@ void btm_pm_reset(void) {
  btm_cb.acl_cb_.pm_pend_link = MAX_L2CAP_LINKS;
}

/*******************************************************************************
 *
 * Function         btm_pm_find_acl_ind
 *
 * Description      This function initializes the control block of an ACL link.
 *                  It is called when an ACL connection is created.
 *
 * Returns          void
 *
 ******************************************************************************/
static int btm_pm_find_acl_ind(const RawAddress& remote_bda) {
  tACL_CONN* p = &btm_cb.acl_cb_.acl_db[0];
  uint8_t xx;

  for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p++) {
    if (p->in_use && p->remote_addr == remote_bda &&
        p->transport == BT_TRANSPORT_BR_EDR) {
#if (BTM_PM_DEBUG == TRUE)
      BTM_TRACE_DEBUG("btm_pm_find_acl_ind ind:%d, st:%d", xx,
                      btm_cb.pm_mode_db[xx].state);
#endif  // BTM_PM_DEBUG
      break;
    }
  }
  return xx;
}

/*******************************************************************************
 *
 * Function     btm_pm_compare_modes
@@ -724,7 +696,6 @@ void btm_pm_proc_cmd_status(uint8_t status) {
 ******************************************************************************/
void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
                             uint8_t mode, uint16_t interval) {
  tACL_CONN* p;
  tBTM_PM_MCB* p_cb = NULL;
  int xx, yy, zz;
  tBTM_PM_STATE old_state;
@@ -733,7 +704,7 @@ void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
  xx = btm_handle_to_acl_index(hci_handle);
  if (xx >= MAX_L2CAP_LINKS) return;

  p = &btm_cb.acl_cb_.acl_db[xx];
  tACL_CONN* p_acl = &btm_cb.acl_cb_.acl_db[xx];

  /* update control block */
  p_cb = &(btm_cb.pm_mode_db[xx]);
@@ -745,7 +716,7 @@ void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
                  mode_to_string(old_state), mode_to_string(p_cb->state));

  if ((p_cb->state == BTM_PM_ST_ACTIVE) || (p_cb->state == BTM_PM_ST_SNIFF)) {
    l2c_OnHciModeChangeSendPendingPackets(p->remote_addr);
    l2c_OnHciModeChangeSendPendingPackets(p_acl->remote_addr);
  }

  /* notify registered parties */
@@ -777,14 +748,15 @@ void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
  /* notify registered parties */
  for (yy = 0; yy < BTM_MAX_PM_RECORDS; yy++) {
    if (btm_cb.pm_reg_db[yy].mask & BTM_PM_REG_NOTIF) {
      (*btm_cb.pm_reg_db[yy].cback)(p->remote_addr, mode, interval, hci_status);
      (*btm_cb.pm_reg_db[yy].cback)(p_acl->remote_addr, mode, interval,
                                    hci_status);
    }
  }
  /*check if sco disconnect  is waiting for the mode change */
  btm_sco_disc_chk_pend_for_modechange(hci_handle);

  /* If mode change was because of an active role switch or change link key */
  btm_cont_rswitch(p, btm_find_dev(p->remote_addr), hci_status);
  btm_cont_rswitch(p_acl, btm_find_dev(p_acl->remote_addr), hci_status);
}

/*******************************************************************************
@@ -804,7 +776,6 @@ void btm_pm_proc_ssr_evt(uint8_t* p, UNUSED_ATTR uint16_t evt_len) {
  uint16_t max_rx_lat;
  int xx, yy;
  tBTM_PM_MCB* p_cb;
  tACL_CONN* p_acl = NULL;
  uint16_t use_ssr = true;

  STREAM_TO_UINT8(status, p);
@@ -818,7 +789,7 @@ void btm_pm_proc_ssr_evt(uint8_t* p, UNUSED_ATTR uint16_t evt_len) {
  STREAM_TO_UINT16(max_rx_lat, p);
  p_cb = &(btm_cb.pm_mode_db[xx]);

  p_acl = &btm_cb.acl_cb_.acl_db[xx];
  tACL_CONN* p_acl = &btm_cb.acl_cb_.acl_db[xx];
  if (p_cb->interval == max_rx_lat) {
    /* using legacy sniff */
    use_ssr = false;
+7 −0
Original line number Diff line number Diff line
@@ -267,3 +267,10 @@ void BTM_ReadConnectionAddr(const RawAddress& remote_bda,
 *
 ******************************************************************************/
bool BTM_IsBleConnection(uint16_t hci_handle);

const RawAddress acl_address_from_handle(uint16_t hci_handle);
tBTM_PM_MCB* acl_power_mode_from_handle(uint16_t hci_handle);
int btm_pm_find_acl_ind(const RawAddress& remote_bda);

void btm_cont_rswitch(tACL_CONN* p, tBTM_SEC_DEV_REC* p_dev_rec,
                      uint8_t hci_status);
Loading