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

Commit 86e01041 authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge "Use GD for controller PM" into main

parents 92a4c663 1abe2173
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -205,11 +205,13 @@ cc_library_static {
        "bluetooth_flags_c_lib",
        "lib-bt-packets",
        "libbase",
        "libbluetooth_hci_pdl",
        "libbluetooth_log",
        "libbt-audio-hal-interface",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libcom.android.sysprop.bluetooth.wrapped",
        "libflatbuffers-cpp",
        "server_configurable_flags",
    ],
    apex_available: [
+4 −2
Original line number Diff line number Diff line
@@ -46,11 +46,13 @@
#include "btif/include/btif_dm.h"
#include "btif/include/stack_manager_t.h"
#include "device/include/controller.h"
#include "hci/controller_interface.h"
#include "include/bind_helpers.h"
#include "include/check.h"
#include "internal_include/bt_target.h"
#include "main/shim/acl_api.h"
#include "main/shim/btm_api.h"
#include "main/shim/entry.h"
#include "osi/include/allocator.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "osi/include/properties.h"
@@ -665,7 +667,7 @@ void handle_remote_features_complete(const RawAddress& bd_addr) {
    return;
  }

  if (controller_get_interface()->SupportsSniffSubrating() &&
  if (bluetooth::shim::GetController()->SupportsSniffSubrating() &&
      acl_peer_supports_sniff_subrating(bd_addr)) {
    log::debug("Device supports sniff subrating peer:{}",
               ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
@@ -718,7 +720,7 @@ void bta_dm_acl_up(const RawAddress& bd_addr, tBT_TRANSPORT transport,
  device->reset_device_info();
  device->transport = transport;

  if (controller_get_interface()->SupportsSniffSubrating() &&
  if (bluetooth::shim::GetController()->SupportsSniffSubrating() &&
      acl_peer_supports_sniff_subrating(bd_addr)) {
    // NOTE: This callback assumes upon ACL connection that
    // the read remote features has completed and is valid.
+5 −6
Original line number Diff line number Diff line
@@ -36,8 +36,9 @@
#include "bta/sys/bta_sys.h"
#include "btif/include/core_callbacks.h"
#include "btif/include/stack_manager_t.h"
#include "device/include/controller.h"
#include "hci/controller_interface.h"
#include "main/shim/dumpsys.h"
#include "main/shim/entry.h"
#include "os/log.h"
#include "osi/include/properties.h"
#include "stack/include/acl_api.h"
@@ -546,9 +547,8 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, const tBTA_SYS_ID id,
      log::debug("Do not perform SSR when AVDTP start");
    }
  } else {
    const controller_t* controller = controller_get_interface();
    uint8_t* p = NULL;
    if (controller->SupportsSniffSubrating() &&
    if (bluetooth::shim::GetController()->SupportsSniffSubrating() &&
        ((NULL != (p = get_btm_client_interface().peer.BTM_ReadRemoteFeatures(
                       peer_addr))) &&
         HCI_SNIFF_SUB_RATE_SUPPORTED(p)) &&
@@ -860,10 +860,9 @@ void bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE* p_peer_dev, uint8_t index) {
  uint8_t* p_rem_feat = get_btm_client_interface().peer.BTM_ReadRemoteFeatures(
      p_peer_dev->peer_bdaddr);

  const controller_t* controller = controller_get_interface();
  if (mode != BTM_PM_MD_SNIFF ||
      (controller->SupportsSniffSubrating() && p_rem_feat &&
       HCI_SNIFF_SUB_RATE_SUPPORTED(p_rem_feat) &&
      (bluetooth::shim::GetController()->SupportsSniffSubrating() &&
       p_rem_feat && HCI_SNIFF_SUB_RATE_SUPPORTED(p_rem_feat) &&
       !(p_peer_dev->is_ssr_active()))) {
    /* Dont initiate Sniff if controller has alreay accepted
     * remote sniff params. This avoid sniff loop issue with
+9 −13
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <future>
@@ -28,10 +29,11 @@
#include "btif/include/btif_api.h"
#include "btif/include/btif_common.h"
#include "btif/include/btif_util.h"
#include "hci/controller_interface_mock.h"
#include "include/hardware/bluetooth.h"
#include "include/hardware/bt_av.h"
#include "test/common/core_interface.h"
#include "test/mock/mock_main_shim_controller.h"
#include "test/mock/mock_main_shim_entry.h"
#include "test/mock/mock_stack_btm_sec.h"
#include "types/raw_address.h"

@@ -39,6 +41,7 @@ void set_hal_cbacks(bt_callbacks_t* callbacks);

const tBTA_AG_RES_DATA tBTA_AG_RES_DATA::kEmpty = {};

using testing::Return;
module_t bt_utils_module;
module_t gd_controller_module;
module_t gd_shim_module;
@@ -136,6 +139,7 @@ class BtifCoreTest : public ::testing::Test {
 protected:
  void SetUp() override {
    callback_map_.clear();
    bluetooth::hci::testing::mock_controller_ = &controller_;
    set_hal_cbacks(&callbacks);
    auto promise = std::promise<void>();
    auto future = promise.get_future();
@@ -155,27 +159,19 @@ class BtifCoreTest : public ::testing::Test {
    };
    CleanCoreInterface();
    ASSERT_EQ(std::future_status::ready, future.wait_for(timeout_time));
    bluetooth::hci::testing::mock_controller_ = nullptr;
    callback_map_.erase("callback_thread_event");
  }
  bluetooth::hci::testing::MockControllerInterface controller_;
};

namespace {
controller_t controller = {};
}

class BtifCoreWithControllerTest : public BtifCoreTest {
  void SetUp() override {
    BtifCoreTest::SetUp();
    controller.SupportsSniffSubrating = []() { return true; };
    bluetooth::testing::controller = &controller;
    ASSERT_TRUE(controller_get_interface() != nullptr);
    ON_CALL(controller_, SupportsSniffSubrating).WillByDefault(Return(true));
  }

  void TearDown() override {
    bluetooth::testing::controller = nullptr;
    controller = {};
    BtifCoreTest::TearDown();
  }
  void TearDown() override { BtifCoreTest::TearDown(); }
};

std::promise<int> promise0;
+0 −7
Original line number Diff line number Diff line
@@ -38,13 +38,6 @@ typedef struct controller_t {

  bool (*supports_enhanced_setup_synchronous_connection)(void);
  bool (*supports_enhanced_accept_synchronous_connection)(void);
  bool (*SupportsRoleSwitch)(void);
  bool (*SupportsHoldMode)(void);
  bool (*SupportsSniffMode)(void);
  bool (*SupportsParkMode)(void);
  bool (*SupportsNonFlushablePb)(void);
  bool (*SupportsSniffSubrating)(void);
  bool (*SupportsEncryptionPause)(void);
  bool (*supports_configure_data_path)(void);
  bool (*supports_set_min_encryption_key_size)(void);
  bool (*supports_read_encryption_key_size)(void);
Loading