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

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

Streamline stack/acl/btm_acl::BTM_SetLinkSuperTout

Bug: 163134718
Test: gd/cert/run
Tag: #refactor

Change-Id: Ib2a588236e98317ef14b619d6416379e7ff35e4c
parent f1c5e26a
Loading
Loading
Loading
Loading
+20 −23
Original line number Diff line number Diff line
@@ -1138,31 +1138,28 @@ tBTM_STATUS BTM_GetLinkSuperTout(const RawAddress& remote_bda,
 ******************************************************************************/
tBTM_STATUS BTM_SetLinkSuperTout(const RawAddress& remote_bda,
                                 uint16_t timeout) {
  tACL_CONN* p = internal_.btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
  if (p != (tACL_CONN*)NULL) {
    p->link_super_tout = timeout;
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
  if (p_acl == nullptr) {
    LOG_WARN("Unable to find active acl");
    return BTM_UNKNOWN_ADDR;
  }

  /* Only send if current role is Central; 2.0 spec requires this */
    if (p->link_role == HCI_ROLE_CENTRAL) {
      LOG_DEBUG("Setting supervison timeout:%.2fms bd_addr:%s",
  if (p_acl->link_role == HCI_ROLE_CENTRAL) {
    p_acl->link_super_tout = timeout;
    btsnd_hcic_write_link_super_tout(LOCAL_BR_EDR_CONTROLLER_ID,
                                     p_acl->hci_handle, timeout);
    LOG_DEBUG("Set supervision timeout:%.2fms bd_addr:%s",
              supervision_timeout_to_seconds(timeout),
              PRIVATE_ADDRESS(remote_bda));

      btsnd_hcic_write_link_super_tout(LOCAL_BR_EDR_CONTROLLER_ID,
                                       p->hci_handle, timeout);
      return (BTM_CMD_STARTED);
    return BTM_CMD_STARTED;
  } else {
    LOG_WARN(
          "Role is peripheral so unable to set supervison timeout:%.2fms "
        "Role is peripheral so unable to set supervision timeout:%.2fms "
        "bd_addr:%s",
        supervision_timeout_to_seconds(timeout), PRIVATE_ADDRESS(remote_bda));
      return (BTM_SUCCESS);
    }
    return BTM_SUCCESS;
  }
  LOG_WARN("Unable to find active acl");

  /* If here, no BD Addr found */
  return (BTM_UNKNOWN_ADDR);
}

bool BTM_IsAclConnectionUp(const RawAddress& remote_bda,