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

Commit 70a8e0a5 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Use BTM_GetHCIConnHandle

Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: I3b56b3d12a67556cd1d4148b1f08042b3dd18a3e
parent 0ec2aec0
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -2507,16 +2507,6 @@ uint8_t acl_link_role_from_handle(uint16_t handle) {
  return p_acl->link_role;
}

uint16_t acl_get_hci_handle_for_hcif(const RawAddress& bd_addr,
                                     tBT_TRANSPORT transport) {
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(bd_addr, transport);
  if (p_acl == nullptr) {
    LOG_WARN("Unable to find active acl");
    return HCI_INVALID_HANDLE;
  }
  return p_acl->hci_handle;
}

bool acl_peer_supports_ble_packet_extension(uint16_t hci_handle) {
  tACL_CONN* p_acl = internal_.acl_get_connection_from_handle(hci_handle);
  if (p_acl == nullptr) {
+7 −6
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <base/bind.h>

#include "acl_api.h"
#include "btm_api.h"
#include "device/include/controller.h"
#include "hcidefs.h"
#include "hcimsgs.h"
@@ -143,7 +144,7 @@ class BleScannerImplBase : public BleScannerHciInterface {
      const RawAddress& bd_addr, uint16_t service_data, uint16_t sync_handle,
      BleScannerHciInterface::handle_cb command_complete) override {
    VLOG(1) << __func__;
    uint16_t acl_handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
    uint16_t acl_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

    if (acl_handle == HCI_INVALID_HANDLE) {
      LOG(ERROR) << __func__
@@ -160,7 +161,7 @@ class BleScannerImplBase : public BleScannerHciInterface {
                                  uint16_t service_data, uint8_t adv_handle,
                                  handle_cb command_complete) override {
    VLOG(1) << __func__;
    uint16_t acl_handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
    uint16_t acl_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

    if (acl_handle == HCI_INVALID_HANDLE) {
      LOG(ERROR) << __func__
@@ -178,7 +179,7 @@ class BleScannerImplBase : public BleScannerHciInterface {
                                        uint8_t cte_type, bool set_defaults,
                                        status_cb command_complete) override {
    VLOG(1) << __func__;
    uint16_t acl_handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
    uint16_t acl_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

    if (acl_handle == HCI_INVALID_HANDLE) {
      LOG(ERROR) << __func__
@@ -259,7 +260,7 @@ class BleScannerSyncTransferImpl : public virtual BleScannerImplBase {
  void PeriodicAdvSyncTransfer(
      const RawAddress& bd_addr, uint16_t service_data, uint16_t sync_handle,
      BleScannerHciInterface::handle_cb command_complete) override {
    uint16_t acl_handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
    uint16_t acl_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

    if (acl_handle == HCI_INVALID_HANDLE) {
      LOG(ERROR) << __func__
@@ -275,7 +276,7 @@ class BleScannerSyncTransferImpl : public virtual BleScannerImplBase {
  void PeriodicAdvSetInfoTransfer(const RawAddress& bd_addr,
                                  uint16_t service_data, uint8_t adv_handle,
                                  handle_cb command_complete) override {
    uint16_t acl_handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
    uint16_t acl_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

    if (acl_handle == HCI_INVALID_HANDLE) {
      LOG(ERROR) << __func__
@@ -292,7 +293,7 @@ class BleScannerSyncTransferImpl : public virtual BleScannerImplBase {
                                        uint16_t skip, uint16_t sync_timeout,
                                        uint8_t cte_type, bool set_defaults,
                                        status_cb command_complete) override {
    uint16_t acl_handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
    uint16_t acl_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

    if (acl_handle == HCI_INVALID_HANDLE) {
      LOG(ERROR) << __func__
+3 −3
Original line number Diff line number Diff line
@@ -678,7 +678,7 @@ tBTM_STATUS BTM_SetBleDataLength(const RawAddress& bd_addr,
    return BTM_SUCCESS;
  }

  uint16_t hci_handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
  uint16_t hci_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

  if (!acl_peer_supports_ble_packet_extension(hci_handle)) {
    LOG_INFO("Remote device unable to support le packet extension");
@@ -745,7 +745,7 @@ void BTM_BleReadPhy(
    return;
  }

  uint16_t handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
  uint16_t handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

  const uint8_t len = HCIC_PARAM_SIZE_BLE_READ_PHY;
  uint8_t data[len];
@@ -775,7 +775,7 @@ void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys,
  if (tx_phys == 0) all_phys &= 0x01;
  if (rx_phys == 0) all_phys &= 0x02;

  uint16_t handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
  uint16_t handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_LE);

  // checking if local controller supports it!
  if (!controller_get_interface()->supports_ble_2m_phy() &&