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

Commit 43ebd8c8 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Refactor L2CA_SetFixedChannelTout

It's always used by LE GATT, so let's change it to
L2CA_SetLeGattTimeout.

Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: Ib838426e2fb75a130d7f3d4cfc6f3d32f3e58423
parent 27c08e65
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -1077,12 +1077,7 @@ bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) {
  return false;
}

bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda, uint16_t fixed_cid,
                              uint16_t idle_tout) {
  if (fixed_cid != kLeAttributeCid) {
    LOG_INFO("UNIMPLEMENTED %s", __func__);
    return false;
  }
bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout) {
  if (idle_tout == 0xffff) {
    bluetooth::shim::L2CA_ConnectFixedChnl(kLeAttributeCid, rem_bda);
  } else {
+2 −3
Original line number Diff line number Diff line
@@ -407,7 +407,7 @@ bool L2CA_EnableUpdateBleConnParams(const RawAddress& rem_bda, bool enable);

/*******************************************************************************
 *
 * Function         L2CA_SetFixedChannelTout
 * Function         L2CA_SetLeGattTimeout
 *
 * Description      Higher layers call this function to set the idle timeout for
 *                  a fixed channel. The "idle timeout" is the amount of time
@@ -422,8 +422,7 @@ bool L2CA_EnableUpdateBleConnParams(const RawAddress& rem_bda, bool enable);
 * Returns          true if command succeeded, false if failed
 *
 ******************************************************************************/
bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda, uint16_t fixed_cid,
                              uint16_t idle_tout);
bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout);

bool L2CA_UpdateBleConnParams(const RawAddress& rem_bda, uint16_t min_int,
                              uint16_t max_int, uint16_t latency,
+1 −1
Original line number Diff line number Diff line
@@ -959,7 +959,7 @@ void GATT_SetIdleTimeout(const RawAddress& bd_addr, uint16_t idle_tout,

  tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bd_addr, transport);
  if (p_tcb != NULL) {
    status = L2CA_SetFixedChannelTout(bd_addr, L2CAP_ATT_CID, idle_tout);
    status = L2CA_SetLeGattTimeout(bd_addr, idle_tout);

    if (idle_tout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP)
      L2CA_SetIdleTimeoutByBdAddr(
+3 −3
Original line number Diff line number Diff line
@@ -741,7 +741,7 @@ extern bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda);

/*******************************************************************************
 *
 * Function         L2CA_SetFixedChannelTout
 * Function         L2CA_SetLeGattTimeout
 *
 * Description      Higher layers call this function to set the idle timeout for
 *                  a fixed channel. The "idle timeout" is the amount of time
@@ -756,8 +756,8 @@ extern bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda);
 * Returns          true if command succeeded, false if failed
 *
 ******************************************************************************/
extern bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda,
                                     uint16_t fixed_cid, uint16_t idle_tout);
extern bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda,
                                  uint16_t idle_tout);

extern bool L2CA_UpdateBleConnParams(const RawAddress& rem_bda,
                                     uint16_t min_int, uint16_t max_int,
+9 −15
Original line number Diff line number Diff line
@@ -1421,7 +1421,7 @@ bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {

/*******************************************************************************
 *
 * Function         L2CA_SetFixedChannelTout
 * Function         L2CA_SetLeGattTimeout
 *
 * Description      Higher layers call this function to set the idle timeout for
 *                  a fixed channel. The "idle timeout" is the amount of time
@@ -1434,30 +1434,24 @@ bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
 * Returns          true if command succeeded, false if failed
 *
 ******************************************************************************/
bool L2CA_SetFixedChannelTout(const RawAddress& rem_bda, uint16_t fixed_cid,
                              uint16_t idle_tout) {
bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return bluetooth::shim::L2CA_SetFixedChannelTout(rem_bda, fixed_cid,
                                                     idle_tout);
    return bluetooth::shim::L2CA_SetLeGattTimeout(rem_bda, idle_tout);
  }

  tL2C_LCB* p_lcb;
  tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;

  if (fixed_cid >= L2CAP_ATT_CID && fixed_cid <= L2CAP_SMP_CID)
    transport = BT_TRANSPORT_LE;
  constexpr uint16_t kAttCid = 4;

  /* Is a fixed channel connected to the remote BDA ?*/
  p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, transport);
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);
  if (((p_lcb) == NULL) ||
      (!p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL])) {
      (!p_lcb->p_fixed_ccbs[kAttCid - L2CAP_FIRST_FIXED_CHNL])) {
    LOG(WARNING) << __func__ << " BDA: " << rem_bda
                 << StringPrintf(" CID: 0x%04x not connected", fixed_cid);
                 << StringPrintf(" CID: 0x%04x not connected", kAttCid);
    return (false);
  }

  p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]
      ->fixed_chnl_idle_tout = idle_tout;
  p_lcb->p_fixed_ccbs[kAttCid - L2CAP_FIRST_FIXED_CHNL]->fixed_chnl_idle_tout =
      idle_tout;

  if (p_lcb->in_use && p_lcb->link_state == LST_CONNECTED &&
      !p_lcb->ccb_queue.p_first_ccb) {
Loading