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

Commit 3a425f65 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Expand logging stack/l2cap/l2c_utils::l2cu_start_post_bond_timer" am:...

Merge "Expand logging stack/l2cap/l2c_utils::l2cu_start_post_bond_timer" am: 109c1567 am: 603fa8f7

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2065508



Change-Id: If10a6149660393f525c3e61dedf3fad8a1149c05
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e2237ee2 603fa8f7
Loading
Loading
Loading
Loading
+34 −23
Original line number Diff line number Diff line
@@ -1487,18 +1487,23 @@ bool l2cu_start_post_bond_timer(uint16_t handle) {
  }

  tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle);

  if (!p_lcb) return (true);

  if (p_lcb == nullptr) {
    LOG_WARN("Unable to find link control block for handle:0x%04x", handle);
    return true;
  }
  p_lcb->ResetBonding();

  /* Only start timer if no control blocks allocated */
  if (p_lcb->ccb_queue.p_first_ccb != NULL) return (false);
  if (p_lcb->ccb_queue.p_first_ccb != nullptr) {
    LOG_DEBUG("Unable to start post bond timer with existing dynamic channels");
    return false;
  }

  switch (p_lcb->link_state) {
    case LST_CONNECTED:
    case LST_CONNECTING:
    case LST_DISCONNECTING: {
      /* If no channels on the connection, start idle timeout */
  if ((p_lcb->link_state == LST_CONNECTED) ||
      (p_lcb->link_state == LST_CONNECTING) ||
      (p_lcb->link_state == LST_DISCONNECTING)) {
      uint64_t timeout_ms = L2CAP_BONDING_TIMEOUT * 1000;

      if (p_lcb->idle_timeout == 0) {
@@ -1508,12 +1513,18 @@ bool l2cu_start_post_bond_timer(uint16_t handle) {
        p_lcb->link_state = LST_DISCONNECTING;
        timeout_ms = L2CAP_LINK_DISCONNECT_TIMEOUT_MS;
      }
    alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout,
                       p_lcb);
    return (true);
  }
      alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms,
                         l2c_lcb_timer_timeout, p_lcb);
      LOG_DEBUG("Started link IDLE timeout_ms:%lu", (unsigned long)timeout_ms);
      return true;
    } break;

  return (false);
    default:
      LOG_DEBUG("Will not start post bond timer with link state:%s",
                link_state_text(p_lcb->link_state).c_str());
      break;
  }
  return false;
}

/*******************************************************************************
@@ -2506,9 +2517,9 @@ void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) {
  }

  if (start_timeout) {
    L2CAP_TRACE_DEBUG("%s starting IDLE timeout: %d ms", __func__, timeout_ms);
    alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout,
                       p_lcb);
    LOG_DEBUG("Started link IDLE timeout_ms:%lu", (unsigned long)timeout_ms);
  } else {
    alarm_cancel(p_lcb->l2c_lcb_timer);
  }