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

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

mock: [7/63] Remove BTM_BleSetPhy

Use get_btm_client_interface() instead

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

Change-Id: Ie0d6877999ae445840a4df125ea60aeb683b3678
parent af626fea
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
#include "hci/controller_interface.h"
#include "internal_include/bt_trace.h"
#include "main/shim/entry.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_sec.h"
@@ -49,6 +48,7 @@
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/l2c_api.h"  // L2CAP_MIN_OFFSET
#include "stack/include/main_thread.h"
#include "types/bluetooth/uuid.h"
@@ -521,7 +521,7 @@ public:

    if (bluetooth::shim::GetController()->SupportsBle2mPhy()) {
      log::info("{} set preferred 2M PHY", address);
      BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0);
      get_btm_client_interface().ble.BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0);
    }

    // Set data length
@@ -711,7 +711,7 @@ public:
              "phy update successful with unexpected phys, retrying:"
              " bd_addr={} tx_phy=0x{:x} rx_phy=0x{:x}",
              hearingDevice->address, tx_phys, rx_phys);
      BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0);
      get_btm_client_interface().ble.BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0);
      hearingDevice->phy_update_retry_remain--;
    } else {
      log::warn(
+4 −3
Original line number Diff line number Diff line
@@ -2009,7 +2009,7 @@ public:

    if (bluetooth::shim::GetController()->SupportsBle2mPhy()) {
      log::info("{} set preferred PHY to 2M", address);
      BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0);
      get_btm_client_interface().ble.BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0);
    }

    get_btm_client_interface().peer.BTM_RequestPeerSCA(leAudioDevice->address_, transport);
@@ -2149,7 +2149,7 @@ public:
    if (!leAudioDevice->acl_phy_update_done_ &&
        bluetooth::shim::GetController()->SupportsBle2mPhy()) {
      log::info("{} set preferred PHY to 2M", leAudioDevice->address_);
      BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0);
      get_btm_client_interface().ble.BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0);
    }

    changeMtuIfPossible(leAudioDevice);
@@ -5623,7 +5623,8 @@ private:
      }

      log::info("SetAsymmetricBlePhy: {} for {}", asymmetric, tmpDevice->address_);
      BTM_BleSetPhy(tmpDevice->address_, PHY_LE_2M, asymmetric ? PHY_LE_1M : PHY_LE_2M, 0);
      get_btm_client_interface().ble.BTM_BleSetPhy(tmpDevice->address_, PHY_LE_2M,
                                                   asymmetric ? PHY_LE_1M : PHY_LE_2M, 0);
      tmpDevice->acl_asymmetric_ = asymmetric;
    }
  }
+4 −6
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@ void bluetooth::manager::SetMockBtmInterface(MockBtmInterface* mock_btm_interfac
                                                         tBT_TRANSPORT transport) {
    btm_interface->RequestPeerSCA(bd_addr, transport);
  };
  mock_btm_client_interface.ble.BTM_BleSetPhy = [](const RawAddress& bd_addr, uint8_t tx_phys,
                                                   uint8_t rx_phys, uint16_t phy_options) {
    btm_interface->BleSetPhy(bd_addr, tx_phys, rx_phys, phy_options);
  };
}

bool BTM_IsLinkKeyKnown(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
@@ -66,12 +70,6 @@ tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr, tBT_TRANSPORT transport
  return btm_interface->SetEncryption(bd_addr, transport, p_callback, p_ref_data, sec_act);
}

void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys,
                   uint16_t phy_options) {
  log::assert_that(btm_interface != nullptr, "Mock btm interface not set!");
  btm_interface->BleSetPhy(bd_addr, tx_phys, rx_phys, phy_options);
}

bool BTM_SecIsSecurityPending(const RawAddress& bd_addr) {
  log::assert_that(btm_interface != nullptr, "Mock btm interface not set!");
  return btm_interface->SecIsSecurityPending(bd_addr);
+6 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include "stack/include/acl_api.h"
#include "stack/include/acl_api_types.h"
#include "stack/include/btm_ble_sec_api.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/main_thread.h"
#include "storage/config_keys.h"
#include "types/ble_address_with_type.h"
@@ -608,7 +609,11 @@ bt_status_t btif_gattc_conn_parameter_update(const RawAddress& bd_addr, int min_
static bt_status_t btif_gattc_set_preferred_phy(const RawAddress& bd_addr, uint8_t tx_phy,
                                                uint8_t rx_phy, uint16_t phy_options) {
  CHECK_BTGATT_INIT();
  do_in_main_thread(Bind(&BTM_BleSetPhy, bd_addr, tx_phy, rx_phy, phy_options));
  do_in_main_thread(Bind(
          [](const RawAddress& bd_addr, uint8_t tx_phy, uint8_t rx_phy, uint16_t phy_options) {
            get_btm_client_interface().ble.BTM_BleSetPhy(bd_addr, tx_phy, rx_phy, phy_options);
          },
          bd_addr, tx_phy, rx_phy, phy_options));
  return BT_STATUS_SUCCESS;
}

+6 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include "btif_gatt_util.h"
#include "osi/include/allocator.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/main_thread.h"
#include "types/ble_address_with_type.h"
#include "types/bluetooth/uuid.h"
@@ -430,7 +431,11 @@ static bt_status_t btif_gatts_send_response(int conn_id, int trans_id, int statu
static bt_status_t btif_gatts_set_preferred_phy(const RawAddress& bd_addr, uint8_t tx_phy,
                                                uint8_t rx_phy, uint16_t phy_options) {
  CHECK_BTGATT_INIT();
  do_in_main_thread(Bind(&BTM_BleSetPhy, bd_addr, tx_phy, rx_phy, phy_options));
  do_in_main_thread(Bind(
          [](const RawAddress& bd_addr, uint8_t tx_phy, uint8_t rx_phy, uint16_t phy_options) {
            get_btm_client_interface().ble.BTM_BleSetPhy(bd_addr, tx_phy, rx_phy, phy_options);
          },
          bd_addr, tx_phy, rx_phy, phy_options));
  return BT_STATUS_SUCCESS;
}

Loading