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

Commit d0cd8cb6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add check if controller supports write link supervision timeout" am: 4c738515

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1966162

Change-Id: Ibbd7fafe9c2f3936afae73063fd1f30c702b138d
parents 63a97507 4c738515
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -423,3 +423,8 @@ const controller_t* bluetooth::shim::controller_get_interface() {
void bluetooth::shim::controller_clear_event_mask() {
  bluetooth::shim::GetController()->SetEventMask(0);
}

bool bluetooth::shim::controller_is_write_link_supervision_timeout_supported() {
  return bluetooth::shim::GetController()->IsSupported(
      bluetooth::hci::OpCode::WRITE_LINK_SUPERVISION_TIMEOUT);
}
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ namespace shim {
const controller_t* controller_get_interface();

void controller_clear_event_mask();
bool controller_is_write_link_supervision_timeout_supported();

}  // namespace shim
}  // namespace bluetooth
+20 −2
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@

#define LOG_TAG "btm_acl"

#include <base/logging.h>

#include <cstdint>

#include "bta/include/bta_dm_acl.h"
@@ -44,6 +46,7 @@
#include "include/l2cap_hci_link_interface.h"
#include "main/shim/acl_api.h"
#include "main/shim/btm_api.h"
#include "main/shim/controller.h"
#include "main/shim/dumpsys.h"
#include "main/shim/l2c_api.h"
#include "main/shim/shim.h"
@@ -69,8 +72,6 @@
#include "types/hci_role.h"
#include "types/raw_address.h"

#include <base/logging.h>

void BTM_update_version_info(const RawAddress& bd_addr,
                             const remote_version_info& remote_version_info);

@@ -207,6 +208,15 @@ void hci_btm_set_link_supervision_timeout(tACL_CONN& link, uint16_t timeout) {
    return;
  }

  if (!bluetooth::shim::
          controller_is_write_link_supervision_timeout_supported()) {
    LOG_WARN(
        "UNSUPPORTED by controller write link supervision timeout:%.2fms "
        "bd_addr:%s",
        supervision_timeout_to_seconds(timeout),
        PRIVATE_ADDRESS(link.RemoteAddress()));
    return;
  }
  LOG_DEBUG("Setting link supervision timeout:%.2fs peer:%s",
            double(timeout) * 0.01, PRIVATE_ADDRESS(link.RemoteAddress()));
  link.link_super_tout = timeout;
@@ -1176,6 +1186,14 @@ tBTM_STATUS BTM_SetLinkSuperTout(const RawAddress& remote_bda,

  /* Only send if current role is Central; 2.0 spec requires this */
  if (p_acl->link_role == HCI_ROLE_CENTRAL) {
    if (!bluetooth::shim::
            controller_is_write_link_supervision_timeout_supported()) {
      LOG_WARN(
          "UNSUPPORTED by controller write link supervision timeout:%.2fms "
          "bd_addr:%s",
          supervision_timeout_to_seconds(timeout), PRIVATE_ADDRESS(remote_bda));
      return BTM_MODE_UNSUPPORTED;
    }
    p_acl->link_super_tout = timeout;
    btsnd_hcic_write_link_super_tout(p_acl->hci_handle, timeout);
    LOG_DEBUG("Set supervision timeout:%.2fms bd_addr:%s",
+5 −0
Original line number Diff line number Diff line
@@ -39,3 +39,8 @@ const controller_t* bluetooth::shim::controller_get_interface() {
void bluetooth::shim::controller_clear_event_mask() {
  mock_function_count_map[__func__]++;
}

bool bluetooth::shim::controller_is_write_link_supervision_timeout_supported() {
  mock_function_count_map[__func__]++;
  return false;
}