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

Commit f1c903b8 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Refactor btm_remove_acl

Use ACL handle instead.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I4447134f80f39e4afaf051e49c10a55ea68f9f5b
parent b63453c2
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -456,8 +456,13 @@ void btm_acl_update_conn_addr(uint16_t conn_handle, const RawAddress& address) {
 * Returns          void
 *
 ******************************************************************************/
void btm_acl_removed(const RawAddress& bda, tBT_TRANSPORT transport) {
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(bda, transport);
void btm_acl_removed(uint16_t handle) {
  tACL_CONN* p_acl = internal_.acl_get_connection_from_handle(handle);
  RawAddress bda = p_acl->remote_addr;
  tBT_TRANSPORT transport = p_acl->transport;
  if (transport == BT_TRANSPORT_LE) {
    bda = p_acl->conn_addr;
  }
  if (p_acl == nullptr) {
    LOG_WARN("Unable to find active acl");
    return;
+1 −1
Original line number Diff line number Diff line
@@ -333,7 +333,7 @@ bool BTM_ReadPowerMode(const RawAddress& remote_bda, tBTM_PM_MODE* p_mode);
void btm_acl_created(const RawAddress& bda, uint16_t hci_handle,
                     uint8_t link_role, tBT_TRANSPORT transport);

void btm_acl_removed(const RawAddress& bda, tBT_TRANSPORT transport);
void btm_acl_removed(uint16_t handle);

void acl_disconnect(const RawAddress& bd_addr, tBT_TRANSPORT transport,
                    uint8_t reason);
+2 −7
Original line number Diff line number Diff line
@@ -316,14 +316,10 @@ void l2c_link_sec_comp2(const RawAddress& p_bda,
 *
 ******************************************************************************/
bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason) {
  tL2C_LCB* p_lcb;
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle);
  tL2C_CCB* p_ccb;
  bool status = true;
  bool lcb_is_free = true;
  tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;

  /* See if we have a link control block for the connection */
  p_lcb = l2cu_find_lcb_by_handle(handle);

  /* If we don't have one, maybe an SCO link. Send to MM */
  if (!p_lcb) {
@@ -378,11 +374,10 @@ bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason) {
        list_remove(p_lcb->link_xmit_data_q, p_buf);
        osi_free(p_buf);
      }
      transport = p_lcb->transport;
      /* for LE link, always drop and re-open to ensure to get LE remote feature
       */
      if (p_lcb->transport == BT_TRANSPORT_LE) {
        btm_acl_removed(p_lcb->remote_bd_addr, p_lcb->transport);
        btm_acl_removed(handle);
      } else {
        /* If we are going to re-use the LCB without dropping it, release all
        fixed channels
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ void l2cu_release_lcb(tL2C_LCB* p_lcb) {
  /* Tell BTM Acl management the link was removed */
  if ((p_lcb->link_state == LST_CONNECTED) ||
      (p_lcb->link_state == LST_DISCONNECTING))
    btm_acl_removed(p_lcb->remote_bd_addr, p_lcb->transport);
    btm_acl_removed(p_lcb->Handle());

  /* Release any held buffers */
  if (p_lcb->link_xmit_data_q) {