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

Commit c693386e authored by Chris Manton's avatar Chris Manton
Browse files

Encapsulate tL2C_CB::tL2C_LCB::disc_reason

Towards proper interfaces

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I475eb9127e50dc58b7a0bc8f6f269db9ab63a94a
parent 348a76c1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1446,7 +1446,7 @@ bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda,

  // Get a CCB and link the lcb to it
  if (!l2cu_initialize_fixed_ccb(p_lcb, fixed_cid)) {
    p_lcb->disc_reason = L2CAP_CONN_NO_RESOURCES;
    p_lcb->SetDisconnectReason(L2CAP_CONN_NO_RESOURCES);
    L2CAP_TRACE_WARNING("%s(0x%04x) - no CCB", __func__, fixed_cid);
    l2cu_release_lcb(p_lcb);
    return false;
@@ -1633,7 +1633,7 @@ bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
  p_ccb = p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL];

  p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] = NULL;
  p_lcb->disc_reason = HCI_ERR_CONN_CAUSE_LOCAL_HOST;
  p_lcb->SetDisconnectReason(HCI_ERR_CONN_CAUSE_LOCAL_HOST);

  // Retain the link for a few more seconds after SMP pairing is done, since
  // the Android platform always does service discovery after pairing is
+2 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ bool L2CA_CancelBleConnectReq(const RawAddress& rem_bda) {
  /* Do not remove lcb if an LE link is already up as a peripheral */
  if (p_lcb != NULL && !(p_lcb->IsLinkRoleSlave() &&
                         BTM_IsAclConnectionUp(rem_bda, BT_TRANSPORT_LE))) {
    p_lcb->disc_reason = L2CAP_CONN_CANCEL;
    p_lcb->SetDisconnectReason(L2CAP_CONN_CANCEL);
    l2cu_release_lcb(p_lcb);
  }
  return (true);
@@ -216,7 +216,7 @@ uint16_t L2CA_GetDisconnectReason(const RawAddress& remote_bda,
  uint16_t reason = 0;

  p_lcb = l2cu_find_lcb_by_bd_addr(remote_bda, transport);
  if (p_lcb != NULL) reason = p_lcb->disc_reason;
  if (p_lcb != NULL) reason = p_lcb->DisconnectReason();

  L2CAP_TRACE_DEBUG("L2CA_GetDisconnectReason=%d ", reason);

+7 −1
Original line number Diff line number Diff line
@@ -381,7 +381,13 @@ typedef struct t_l2c_linkcb {
  tL2CA_NOCP_CB* p_nocp_cb; /* Num Cmpl pkts callback */

  tL2C_CCB* p_fixed_ccbs[L2CAP_NUM_FIXED_CHNLS];
  uint16_t disc_reason;

 private:
  uint16_t disc_reason_;

 public:
  uint16_t DisconnectReason() const { return disc_reason_; }
  void SetDisconnectReason(uint16_t disc_reason) { disc_reason_ = disc_reason; }

  tBT_TRANSPORT transport;
  uint8_t initiating_phys;  // LE PHY used for connection initiation
+5 −5
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ void l2c_link_hci_conn_comp(uint8_t status, uint16_t handle,
      p_ccb = pn;
    }

    p_lcb->disc_reason = status;
    p_lcb->SetDisconnectReason(status);
    /* Release the LCB */
    if (p_lcb->ccb_queue.p_first_ccb == NULL)
      l2cu_release_lcb(p_lcb);
@@ -336,7 +336,7 @@ bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason) {
      acl_set_disconnect_reason(reason);
    }

    p_lcb->disc_reason = acl_get_disconnect_reason();
    p_lcb->SetDisconnectReason(acl_get_disconnect_reason());

    /* Just in case app decides to try again in the callback context */
    p_lcb->link_state = LST_DISCONNECTING;
@@ -395,7 +395,7 @@ bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason) {
              p_lcb->p_fixed_ccbs[xx] != p_lcb->p_pending_ccb) {
            (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(
                xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false,
                p_lcb->disc_reason, p_lcb->transport);
                p_lcb->DisconnectReason(), p_lcb->transport);
            if (p_lcb->p_fixed_ccbs[xx] == NULL) {
              L2CAP_TRACE_ERROR(
                  "%s: unexpected p_fixed_ccbs[%d] is NULL remote_bd_addr = %s "
@@ -404,8 +404,8 @@ bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason) {
                  "%d",
                  __func__, xx, p_lcb->remote_bd_addr.ToString().c_str(), p_lcb,
                  p_lcb->in_use, p_lcb->link_state, p_lcb->handle,
                  p_lcb->LinkRole(), p_lcb->IsBonding(), p_lcb->disc_reason,
                  p_lcb->transport);
                  p_lcb->LinkRole(), p_lcb->IsBonding(),
                  p_lcb->DisconnectReason(), p_lcb->transport);
            }
            CHECK(p_lcb->p_fixed_ccbs[xx] != NULL);
            l2cu_release_ccb(p_lcb->p_fixed_ccbs[xx]);
+3 −3
Original line number Diff line number Diff line
@@ -2539,7 +2539,7 @@ void l2cu_process_fixed_chnl_resp(tL2C_LCB* p_lcb) {
          channel_id, p_lcb->remote_bd_addr, true, 0, p_lcb->transport);
    } else {
      (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(
          channel_id, p_lcb->remote_bd_addr, false, p_lcb->disc_reason,
          channel_id, p_lcb->remote_bd_addr, false, p_lcb->DisconnectReason(),
          p_lcb->transport);

      if (p_lcb->p_fixed_ccbs[xx]) {
@@ -2577,13 +2577,13 @@ void l2cu_process_fixed_disc_cback(tL2C_LCB* p_lcb) {
        l2cu_release_ccb(p_l2c_chnl_ctrl_block);
        (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(
            xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false,
            p_lcb->disc_reason, p_lcb->transport);
            p_lcb->DisconnectReason(), p_lcb->transport);
      }
    } else if ((peer_channel_mask & (1 << (xx + L2CAP_FIRST_FIXED_CHNL))) &&
               (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL))
      (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(
          xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false,
          p_lcb->disc_reason, p_lcb->transport);
          p_lcb->DisconnectReason(), p_lcb->transport);
  }
}