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

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

Streamline stack/l2cap/l2c_link::l2c_link_check_power_mode

Towards readable code

Bug: 163134718
Tag: #refactor
Test: acts -tc BleCocTest
Test: ble paired 2 phones
Change-Id: Ie696eafbc080777850b71ac5fad846ffcfc2ec8c
parent 3037ef21
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -815,31 +815,30 @@ void l2c_pin_code_request(const RawAddress& bd_addr) {
 *
 ******************************************************************************/
static bool l2c_link_check_power_mode(tL2C_LCB* p_lcb) {
  tBTM_PM_MODE mode;
  tL2C_CCB* p_ccb;
  bool need_to_active = false;

  /*
   * We only switch park to active only if we have unsent packets
   */
  if (list_is_empty(p_lcb->link_xmit_data_q)) {
    for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb;
    for (tL2C_CCB* p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb;
         p_ccb = p_ccb->p_next_ccb) {
      if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) {
        need_to_active = true;
        break;
      }
    }
  } else
  } else {
    need_to_active = true;
  }

  /* if we have packets to send */
  if (need_to_active) {
    /* check power mode */
    tBTM_PM_MODE mode;
    if (BTM_ReadPowerMode(p_lcb->remote_bd_addr, &mode)) {
      if (mode == BTM_PM_STS_PENDING) {
        L2CAP_TRACE_DEBUG("LCB(0x%x) is in PM pending state", p_lcb->Handle());

        return true;
      }
    }