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

Commit 19021b42 authored by Chris Manton's avatar Chris Manton
Browse files

mock: [24/63] Remove BTM_GetRole

Use get_btm_client_interface() instead

Bug: 352129816
Test: m .
Flag: EXEMPT, Test infrastructure

Change-Id: I6040e3b1f5680b210ff8e7fa70cabe1a8a00393f
parent 22cd4e8d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1852,7 +1852,8 @@ void bta_av_do_start(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
   * It would not hurt us, if the peer device wants us to be central
   * disable sniff mode unconditionally during streaming */
  tHCI_ROLE cur_role;
  if ((BTM_GetRole(p_scb->PeerAddress(), &cur_role) == BTM_SUCCESS) &&
  if ((get_btm_client_interface().link_policy.BTM_GetRole(p_scb->PeerAddress(), &cur_role) ==
       BTM_SUCCESS) &&
      (cur_role == HCI_ROLE_CENTRAL)) {
    BTM_block_role_switch_and_sniff_mode_for(p_scb->PeerAddress());
  } else {
@@ -2323,7 +2324,8 @@ void bta_av_start_ok(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
       * Because it would not hurt source, if the peer device wants source to be
       * central.
       * disable sniff mode unconditionally during streaming */
      if ((BTM_GetRole(p_scb->PeerAddress(), &cur_role) == BTM_SUCCESS) &&
      if ((get_btm_client_interface().link_policy.BTM_GetRole(p_scb->PeerAddress(), &cur_role) ==
           BTM_SUCCESS) &&
          (cur_role == HCI_ROLE_CENTRAL)) {
        BTM_block_role_switch_and_sniff_mode_for(p_scb->PeerAddress());
      } else {
+6 −4
Original line number Diff line number Diff line
@@ -39,11 +39,11 @@
#include "btif/include/btif_av_co.h"
#include "btif/include/btif_config.h"
#include "internal_include/bt_target.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "stack/include/acl_api.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/hci_error_code.h"
#include "stack/include/sdp_api.h"
#include "storage/config_keys.h"
@@ -919,7 +919,8 @@ static void bta_av_sys_rs_cback(tBTA_SYS_CONN_STATUS /* status */, tHCI_ROLE new
  }

  /* restore role switch policy, if role switch failed */
  if ((HCI_SUCCESS != hci_status) && (BTM_GetRole(peer_addr, &cur_role) == BTM_SUCCESS) &&
  if ((HCI_SUCCESS != hci_status) &&
      (get_btm_client_interface().link_policy.BTM_GetRole(peer_addr, &cur_role) == BTM_SUCCESS) &&
      (cur_role == HCI_ROLE_PERIPHERAL)) {
    BTM_unblock_role_switch_for(peer_addr);
  }
@@ -1039,7 +1040,7 @@ bool bta_av_switch_if_needed(tBTA_AV_SCB* p_scb) {
    if (p_scbi && (p_scb->hdi != i) &&   /* not the original channel */
        ((bta_av_cb.conn_audio & mask))) /* connected audio */
    {
      BTM_GetRole(p_scbi->PeerAddress(), &role);
      get_btm_client_interface().link_policy.BTM_GetRole(p_scbi->PeerAddress(), &role);
      /* this channel is open - clear the role switch link policy for this link
       */
      if (HCI_ROLE_CENTRAL != role) {
@@ -1076,7 +1077,8 @@ bool bta_av_switch_if_needed(tBTA_AV_SCB* p_scb) {
 ******************************************************************************/
bool bta_av_link_role_ok(tBTA_AV_SCB* p_scb, uint8_t bits) {
  tHCI_ROLE role;
  if (BTM_GetRole(p_scb->PeerAddress(), &role) != BTM_SUCCESS) {
  if (get_btm_client_interface().link_policy.BTM_GetRole(p_scb->PeerAddress(), &role) !=
      BTM_SUCCESS) {
    log::warn("Unable to find link role for device:{}", p_scb->PeerAddress());
    return true;
  }
+8 −2
Original line number Diff line number Diff line
@@ -3052,7 +3052,10 @@ void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status) {
                     hci_error_code_text(status));

      tHCI_ROLE role = HCI_ROLE_UNKNOWN;
      BTM_GetRole(p_dev_rec->bd_addr, &role);
      if (get_btm_client_interface().link_policy.BTM_GetRole(p_dev_rec->bd_addr, &role) !=
          BTM_SUCCESS) {
        log::warn("Unable to get link role peer:{}", p_dev_rec->bd_addr);
      }
      if (role == HCI_ROLE_CENTRAL) {
        // Encryption is required to start SM over BR/EDR
        // indicate that this is encryption after authentication
@@ -3228,7 +3231,10 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status, uint8_t encr_en
      log::verbose("BR key is temporary, skip derivation of LE LTK");
    }
    tHCI_ROLE role = HCI_ROLE_UNKNOWN;
    BTM_GetRole(p_dev_rec->bd_addr, &role);
    if (get_btm_client_interface().link_policy.BTM_GetRole(p_dev_rec->bd_addr, &role) !=
        BTM_SUCCESS) {
      log::warn("Unable to get link policy role peer:{}", p_dev_rec->bd_addr);
    }
    if (p_dev_rec->sec_rec.new_encryption_key_is_p256) {
      if (btm_sec_use_smp_br_chnl(p_dev_rec) && role == HCI_ROLE_CENTRAL &&
          /* if LE key is not known, do deriving */
+0 −5
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ struct acl_set_peer_le_features_from_handle acl_set_peer_le_features_from_handle
struct acl_get_connection_from_address acl_get_connection_from_address;
struct btm_acl_for_bda btm_acl_for_bda;
struct acl_get_connection_from_handle acl_get_connection_from_handle;
struct BTM_GetRole BTM_GetRole;
struct BTM_ReadFailedContactCounter BTM_ReadFailedContactCounter;
struct BTM_ReadRSSI BTM_ReadRSSI;
struct BTM_ReadTxPower BTM_ReadTxPower;
@@ -259,10 +258,6 @@ tACL_CONN* acl_get_connection_from_handle(uint16_t handle) {
  inc_func_call_count(__func__);
  return test::mock::stack_acl::acl_get_connection_from_handle(handle);
}
tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr, tHCI_ROLE* p_role) {
  inc_func_call_count(__func__);
  return test::mock::stack_acl::BTM_GetRole(remote_bd_addr, p_role);
}
tBTM_STATUS BTM_ReadFailedContactCounter(const RawAddress& remote_bda, tBTM_CMPL_CB* p_cb) {
  inc_func_call_count(__func__);
  return test::mock::stack_acl::BTM_ReadFailedContactCounter(remote_bda, p_cb);
+0 −13
Original line number Diff line number Diff line
@@ -319,19 +319,6 @@ struct acl_get_connection_from_handle {
  tACL_CONN* operator()(uint16_t handle) { return body(handle); }
};
extern struct acl_get_connection_from_handle acl_get_connection_from_handle;
// Name: BTM_GetRole
// Params: const RawAddress& remote_bd_addr, tHCI_ROLE* p_role
// Returns: tBTM_STATUS
struct BTM_GetRole {
  std::function<tBTM_STATUS(const RawAddress& remote_bd_addr, tHCI_ROLE* p_role)> body{
          [](const RawAddress& /* remote_bd_addr */, tHCI_ROLE* /* p_role */) {
            return BTM_SUCCESS;
          }};
  tBTM_STATUS operator()(const RawAddress& remote_bd_addr, tHCI_ROLE* p_role) {
    return body(remote_bd_addr, p_role);
  }
};
extern struct BTM_GetRole BTM_GetRole;
// Name: BTM_ReadFailedContactCounter
// Params: const RawAddress& remote_bda, tBTM_CMPL_CB* p_cb
// Returns: tBTM_STATUS