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

Commit 728209a5 authored by Chris Manton's avatar Chris Manton
Browse files

Wrap l2c::IsBonding in API

Towards proper interfaces

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I8363716501145101ea025bd44aa35fa7f870b2eb
parent 6c7f941f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -346,7 +346,12 @@ typedef struct t_l2c_linkcb {
  uint8_t id;
  uint8_t cur_echo_id;              /* Current id value for echo request */
  uint16_t idle_timeout;            /* Idle timeout */
  bool is_bonding;                  /* True - link active only for bonding */
 private:
  bool is_bonding_{false};          /* True - link active only for bonding */
 public:
  bool IsBonding() const { return is_bonding_; }
  void SetBonding() { is_bonding_ = true; }
  void ResetBonding() { is_bonding_ = false; }

  uint16_t link_flush_tout; /* Flush timeout used */

+4 −4
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ void l2c_link_hci_conn_comp(uint8_t status, uint16_t handle,
    BTM_SetLinkSuperTout(ci.bd_addr, acl_get_link_supervision_timeout());

    /* If dedicated bonding do not process any further */
    if (p_lcb->is_bonding) {
    if (p_lcb->IsBonding()) {
      if (l2cu_start_post_bond_timer(handle)) return;
    }

@@ -405,7 +405,7 @@ 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->link_role, p_lcb->is_bonding, p_lcb->disc_reason,
                  p_lcb->link_role, p_lcb->IsBonding(), p_lcb->disc_reason,
                  p_lcb->transport);
            }
            CHECK(p_lcb->p_fixed_ccbs[xx] != NULL);
@@ -455,7 +455,7 @@ void l2c_link_timeout(tL2C_LCB* p_lcb) {

  L2CAP_TRACE_EVENT(
      "L2CAP - l2c_link_timeout() link state %d first CCB %p is_bonding:%d",
      p_lcb->link_state, p_lcb->ccb_queue.p_first_ccb, p_lcb->is_bonding);
      p_lcb->link_state, p_lcb->ccb_queue.p_first_ccb, p_lcb->IsBonding());

  /* If link was connecting or disconnecting, clear all channels and drop the
   * LCB */
@@ -504,7 +504,7 @@ void l2c_link_timeout(tL2C_LCB* p_lcb) {
      } else if (rc == BTM_BUSY) {
        /* BTM is still executing security process. Let lcb stay as connected */
        start_timeout = false;
      } else if (p_lcb->is_bonding) {
      } else if (p_lcb->IsBonding()) {
        btsnd_hcic_disconnect(p_lcb->handle, HCI_ERR_PEER_USER);
        l2cu_process_fixed_disc_cback(p_lcb);
        p_lcb->link_state = LST_DISCONNECTING;
+15 −7
Original line number Diff line number Diff line
@@ -71,7 +71,11 @@ tL2C_LCB* l2cu_allocate_lcb(const RawAddress& p_bd_addr, bool is_bonding,
      p_lcb->info_resp_timer = alarm_new("l2c_lcb.info_resp_timer");
      p_lcb->idle_timeout = l2cb.idle_timeout;
      p_lcb->id = 1; /* spec does not allow '0' */
      p_lcb->is_bonding = is_bonding;
      if (is_bonding) {
        p_lcb->SetBonding();
      } else {
        p_lcb->ResetBonding();
      }
      p_lcb->transport = transport;
      p_lcb->tx_data_len =
          controller_get_interface()->get_ble_default_data_packet_length();
@@ -109,7 +113,11 @@ void l2cu_update_lcb_4_bonding(const RawAddress& p_bd_addr, bool is_bonding) {
  if (p_lcb) {
    VLOG(1) << __func__ << " BDA: " << p_bd_addr
            << " is_bonding: " << is_bonding;
    p_lcb->is_bonding = is_bonding;
    if (is_bonding) {
      p_lcb->SetBonding();
    } else {
      p_lcb->ResetBonding();
    }
  }
}

@@ -127,7 +135,7 @@ void l2cu_release_lcb(tL2C_LCB* p_lcb) {
  tL2C_CCB* p_ccb;

  p_lcb->in_use = false;
  p_lcb->is_bonding = false;
  p_lcb->ResetBonding();

  /* Stop and free timers */
  alarm_free(p_lcb->l2c_lcb_timer);
@@ -1429,7 +1437,7 @@ bool l2cu_start_post_bond_timer(uint16_t handle) {

  if (!p_lcb) return (true);

  p_lcb->is_bonding = false;
  p_lcb->ResetBonding();

  /* Only start timer if no control blocks allocated */
  if (p_lcb->ccb_queue.p_first_ccb != NULL) return (false);
@@ -2117,7 +2125,7 @@ void l2cu_create_conn_after_switch(tL2C_LCB* p_lcb) {

  acl_create_classic_connection(p_lcb->remote_bd_addr,
                                there_are_high_priority_channels,
                                p_lcb->is_bonding);
                                p_lcb->IsBonding());

  alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_TIMEOUT_MS,
                     l2c_lcb_timer_timeout, p_lcb);
@@ -2452,7 +2460,7 @@ void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) {
  }

  /* If the link is pairing, do not mess with the timeouts */
  if (p_lcb->is_bonding) return;
  if (p_lcb->IsBonding()) return;

  if (timeout_ms == 0) {
    L2CAP_TRACE_DEBUG(
@@ -2469,7 +2477,7 @@ void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) {
       * done) */
      p_lcb->link_state = LST_DISCONNECTING;
      start_timeout = false;
    } else if (p_lcb->is_bonding) {
    } else if (p_lcb->IsBonding()) {
      btsnd_hcic_disconnect(p_lcb->handle, HCI_ERR_PEER_USER);
      l2cu_process_fixed_disc_cback(p_lcb);
      p_lcb->link_state = LST_DISCONNECTING;