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

Commit ea8eac25 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2CA_SetFlushTimeout does nothing.

Since LinkFlushTimeout is always 0 and we always set it to 0.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ia6a87f45f59b4bb429aba98f921785b3e9e0d309
parent 4e1d592d
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -1882,7 +1882,6 @@ void bta_av_str_stopped(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
    p_scb->co_started = false;

    p_scb->p_cos->stop(p_scb->hndl, p_scb->PeerAddress());
    L2CA_SetFlushTimeout(p_scb->PeerAddress(), L2CAP_NO_AUTOMATIC_FLUSH);
  }

  /* if q_info.a2dp_list is not empty, drop it now */
@@ -2272,9 +2271,7 @@ void bta_av_start_ok(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
     * to be changed
     */
    p_scb->co_started = bta_av_cb.audio_open_cnt;
  } else {
  }
  L2CA_SetFlushTimeout(p_scb->PeerAddress(), 0);

  /* clear the congestion flag */
  p_scb->cong = false;
@@ -2513,7 +2510,6 @@ void bta_av_suspend_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
      p_scb->co_started = false;
      p_scb->p_cos->stop(p_scb->hndl, p_scb->PeerAddress());
    }
    L2CA_SetFlushTimeout(p_scb->PeerAddress(), L2CAP_NO_AUTOMATIC_FLUSH);
  }

  {
@@ -2874,7 +2870,6 @@ void bta_av_chk_2nd_start(tBTA_AV_SCB* p_scb,
          // May need to update the flush timeout of this already started stream
          if (p_scbi->co_started != bta_av_cb.audio_open_cnt) {
            p_scbi->co_started = bta_av_cb.audio_open_cnt;
            L2CA_SetFlushTimeout(p_scbi->PeerAddress(), 0);
          }
        }
      }
+0 −1
Original line number Diff line number Diff line
@@ -1280,7 +1280,6 @@ void bta_av_conn_chg(tBTA_AV_DATA* p_data) {
           */
          if (p_scbi->co_started != bta_av_cb.audio_open_cnt) {
            p_scbi->co_started = bta_av_cb.audio_open_cnt;
            L2CA_SetFlushTimeout(p_scbi->PeerAddress(), 0);
          }
        }
      }
+0 −1
Original line number Diff line number Diff line
@@ -756,7 +756,6 @@ bool bta_av_chk_start(tBTA_AV_SCB* p_scb) {
        // May need to update the flush timeout of this already started stream
        if (p_scbi->co_started != bta_av_cb.audio_open_cnt) {
          p_scbi->co_started = bta_av_cb.audio_open_cnt;
          L2CA_SetFlushTimeout(p_scbi->PeerAddress(), 0);
        }
      }
    }
+0 −27
Original line number Diff line number Diff line
@@ -543,33 +543,6 @@ extern bool L2CA_SetAclPriority(const RawAddress& bd_addr, uint8_t priority);
 ******************************************************************************/
extern bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority);

/*******************************************************************************
 *
 * Function         L2CA_SetFlushTimeout
 *
 * Description      This function set the automatic flush time out in Baseband
 *                  for ACL-U packets.
 *                  BdAddr : the remote BD address of ACL link. If it is
 *                           BT_DB_ANY then the flush time out will be applied
 *                           to all ACL link.
 *                  FlushTimeout: flush time out in ms
 *                           0x0000 : No automatic flush
 *                           L2CAP_NO_RETRANSMISSION : No retransmission
 *                           0x0002 - 0xFFFE : flush time out, if
 *                                             (flush_tout * 8) + 3 / 5) <=
 *                                             HCI_MAX_AUTOMATIC_FLUSH_TIMEOUT
 *                                             (in 625us slot).
 *                                    Otherwise, return false.
 *                           L2CAP_NO_AUTOMATIC_FLUSH : No automatic flush
 *
 * Returns          true if command succeeded, false if failed
 *
 * NOTE             This flush timeout applies to all logical channels active on
 *                  the ACL link.
 ******************************************************************************/
extern bool L2CA_SetFlushTimeout(const RawAddress& bd_addr,
                                 uint16_t flush_tout);

/*******************************************************************************
 *
 * Function         L2CA_SetChnlFlushability
+0 −78
Original line number Diff line number Diff line
@@ -866,84 +866,6 @@ bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) {
  return (true);
}

/*******************************************************************************
 *
 * Function         L2CA_SetFlushTimeout
 *
 * Description      This function set the automatic flush time out in Baseband
 *                  for ACL-U packets.
 *                  BdAddr : the remote BD address of ACL link. If it is
 *                          BT_DB_ANY then the flush time out will be applied to
 *                          all ACL links.
 *                  FlushTimeout: flush time out in ms
 *                           0x0000 : No automatic flush
 *                           0x0001 : No retransmission
 *                           0x0002 - 0x0500 : flush time out in ms
 *                           0xffff : DEPRECATED No automatic flush (0x0000)
 *                           >0x0500 : Illegal value
 *
 * Returns          true if command succeeded, false if failed
 *
 * NOTE             This flush timeout applies to all logical channels active on
 *                  the ACL link.
 ******************************************************************************/
constexpr uint32_t ConvertMillisecondsToBasebandSlots(uint32_t milliseconds) {
  return ((milliseconds * 8) + 3) / 5;
}

bool L2CA_SetFlushTimeout(const RawAddress& bd_addr,
                          const uint16_t flush_timeout_in_ms) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_SetFlushTimeout(bd_addr, flush_timeout_in_ms);
  }

  if (flush_timeout_in_ms == L2CAP_NO_AUTOMATIC_FLUSH) {
    LOG_WARN(
        "%s Parameter deprecated for no automatic flush; please use 0x0000",
        __func__);
  } else if (ConvertMillisecondsToBasebandSlots(flush_timeout_in_ms) >
             HCI_MAX_AUTOMATIC_FLUSH_TIMEOUT) {
    LOG_WARN(
        "%s Unable to set flush timeout larger then controller capability:%dms",
        __func__, flush_timeout_in_ms);
    return false;
  }

  uint16_t flush_timeout_in_slots = 0;

  /* no automatic flush (infinite timeout) */
  if (flush_timeout_in_ms == 0x0000 ||
      flush_timeout_in_ms == L2CAP_NO_AUTOMATIC_FLUSH) {
    flush_timeout_in_slots = 0x0;
  }

  if (RawAddress::kAny != bd_addr) {
    tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR);

    if ((p_lcb) && (p_lcb->in_use) && (p_lcb->link_state == LST_CONNECTED)) {
      if (p_lcb->LinkFlushTimeout() != flush_timeout_in_ms) {
        p_lcb->SetLinkFlushTimeout(flush_timeout_in_ms);
        acl_write_automatic_flush_timeout(bd_addr, flush_timeout_in_slots);
      }
    } else {
      LOG(WARNING) << __func__ << " No lcb for bd_addr " << bd_addr;
      return false;
    }
  } else {
    tL2C_LCB* p_lcb = &l2cb.lcb_pool[0];
    for (int xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) {
      if ((p_lcb->in_use) && (p_lcb->link_state == LST_CONNECTED)) {
        if (p_lcb->LinkFlushTimeout() != flush_timeout_in_ms) {
          p_lcb->SetLinkFlushTimeout(flush_timeout_in_ms);
          acl_write_automatic_flush_timeout(p_lcb->remote_bd_addr,
                                            flush_timeout_in_slots);
        }
      }
    }
  }
  return true;
}

/*******************************************************************************
 *
 *  Function         L2CA_GetPeerFeatures