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

Commit 7790355f authored by Hansong Zhang's avatar Hansong Zhang
Browse files

AVDT: Move L2cap disconnect logic together

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ice0c606bbaf3467cbbf7cedd266765874d760e66
parent ed128230
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -603,6 +603,7 @@ void avdt_ad_close_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb) {
      tcid = avdt_ad_type_to_tcid(type, p_scb);

      /* call l2cap disconnect req */
      L2CA_DisconnectReq(avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid);
      avdt_l2c_disconnect(
          avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid);
  }
}
+2 −0
Original line number Diff line number Diff line
@@ -1003,4 +1003,6 @@ extern const tL2CAP_APPL_INFO avdt_l2c_appl;
/* reject message event lookup table */
extern const uint8_t avdt_msg_rej_2_evt[];

void avdt_l2c_disconnect(uint16_t lcid);

#endif /* AVDT_INT_H */
+6 −17
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ void avdt_l2c_connect_cfm_cback(uint16_t lcid, uint16_t result);
void avdt_l2c_config_cfm_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg);
void avdt_l2c_config_ind_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg);
void avdt_l2c_disconnect_ind_cback(uint16_t lcid, bool ack_needed);
void avdt_l2c_disconnect_cfm_cback(uint16_t lcid, uint16_t result);
void avdt_l2c_congestion_ind_cback(uint16_t lcid, bool is_congested);
void avdt_l2c_data_ind_cback(uint16_t lcid, BT_HDR* p_buf);

@@ -53,7 +52,7 @@ const tL2CAP_APPL_INFO avdt_l2c_appl = {avdt_l2c_connect_ind_cback,
                                        avdt_l2c_config_ind_cback,
                                        avdt_l2c_config_cfm_cback,
                                        avdt_l2c_disconnect_ind_cback,
                                        avdt_l2c_disconnect_cfm_cback,
                                        NULL,
                                        avdt_l2c_data_ind_cback,
                                        avdt_l2c_congestion_ind_cback,
                                        NULL,
@@ -145,7 +144,7 @@ static void avdt_sec_check_complete_orig(const RawAddress* bd_addr,
    cfg.flush_to = p_tbl->my_flush_to;
    L2CA_ConfigReq(p_tbl->lcid, &cfg);
  } else {
    L2CA_DisconnectReq(p_tbl->lcid);
    avdt_l2c_disconnect(p_tbl->lcid);
    avdt_ad_tc_close_ind(p_tbl);
  }
}
@@ -361,7 +360,7 @@ void avdt_l2c_config_cfm_cback(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) {
      /* else failure */
      else {
        /* Send L2CAP disconnect req */
        L2CA_DisconnectReq(lcid);
        avdt_l2c_disconnect(lcid);
      }
    }
  }
@@ -434,21 +433,11 @@ void avdt_l2c_disconnect_ind_cback(uint16_t lcid, bool ack_needed) {
  }
}

/*******************************************************************************
 *
 * Function         avdt_l2c_disconnect_cfm_cback
 *
 * Description      This is the L2CAP disconnect confirm callback function.
 *
 *
 * Returns          void
 *
 ******************************************************************************/
void avdt_l2c_disconnect_cfm_cback(uint16_t lcid, uint16_t result) {
void avdt_l2c_disconnect(uint16_t lcid) {
  L2CA_DisconnectReq(lcid);
  AvdtpTransportChannel* p_tbl;

  AVDT_TRACE_DEBUG("avdt_l2c_disconnect_cfm_cback lcid: %d, result: %d", lcid,
                   result);
  AVDT_TRACE_DEBUG("avdt_l2c_disconnect_cfm_cback lcid: %d", lcid);
  /* look up info for this channel */
  p_tbl = avdt_ad_tc_tbl_by_lcid(lcid);
  if (p_tbl != NULL) {