From: Chris Manton Date: Thu, 29 Apr 2021 05:23:47 +0000 (-0700) Subject: Streamline stack/acl/btm_acl::BTM_SetLinkSuperTout X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d7d2251afa755b2d61311a4d8a8f8e8181185ea3;p=android-x86%2Fsystem-bt.git Streamline stack/acl/btm_acl::BTM_SetLinkSuperTout Bug: 163134718 Test: gd/cert/run Tag: #refactor Change-Id: Ib2a588236e98317ef14b619d6416379e7ff35e4c --- diff --git a/stack/acl/btm_acl.cc b/stack/acl/btm_acl.cc index 4722b4e0a..c921ed600 100644 --- a/stack/acl/btm_acl.cc +++ b/stack/acl/btm_acl.cc @@ -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; - - /* 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", - 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); - } else { - LOG_WARN( - "Role is peripheral so unable to set supervison timeout:%.2fms " - "bd_addr:%s", - supervision_timeout_to_seconds(timeout), PRIVATE_ADDRESS(remote_bda)); - return (BTM_SUCCESS); - } + 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; } - LOG_WARN("Unable to find active acl"); - /* If here, no BD Addr found */ - return (BTM_UNKNOWN_ADDR); + /* Only send if current role is Central; 2.0 spec requires this */ + 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)); + return BTM_CMD_STARTED; + } else { + LOG_WARN( + "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; + } } bool BTM_IsAclConnectionUp(const RawAddress& remote_bda,