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

Commit b3ebc0f6 authored by Sophie Hu's avatar Sophie Hu Committed by Automerger Merge Worker
Browse files

Add system property for rpa_offload_to_bt_controller am: 210363be

parents 1280ee2d 210363be
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -857,8 +857,7 @@ public:
      address_with_type = AddressWithType();
    }

    if (com::android::bluetooth::flags::rpa_offload_to_bt_controller() &&
        controller_->IsSupported(OpCode::LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_V2) &&
    if (controller_->IsRpaOffloadSupported() &&
        own_address_type != OwnAddressType::PUBLIC_DEVICE_ADDRESS) {
      log::info("Support RPA offload, set own address type RESOLVABLE_OR_RANDOM_ADDRESS");
      own_address_type = OwnAddressType::RESOLVABLE_OR_RANDOM_ADDRESS;
+12 −0
Original line number Diff line number Diff line
@@ -43,8 +43,11 @@ constexpr int kMinEncryptionKeySizeDefault = kMinEncryptionKeySize;
constexpr int kMaxEncryptionKeySize = 16;

constexpr bool kDefaultVendorCapabilitiesEnabled = true;
constexpr bool kDefaultRpaOffload = false;

static const std::string kPropertyVendorCapabilitiesEnabled =
        "bluetooth.core.le.vendor_capabilities.enabled";
static const std::string kPropertyRpaOffload = "bluetooth.core.le.rpa_offload";

using os::Handler;

@@ -1543,6 +1546,15 @@ uint64_t Controller::MaskLeEventMask(HciVersion version, uint64_t mask) {
  }
}

bool Controller::IsRpaOffloadSupported(void) {
  static const bool rpa_supported =
          com::android::bluetooth::flags::rpa_offload_to_bt_controller() &&
          os::GetSystemPropertyBool(kPropertyRpaOffload, kDefaultRpaOffload) &&
          IsSupported(OpCode::LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_V2);

  return rpa_supported;
}

const ModuleFactory Controller::Factory = ModuleFactory([]() { return new Controller(); });

void Controller::ListDependencies(ModuleList* list) const {
+2 −0
Original line number Diff line number Diff line
@@ -217,6 +217,8 @@ public:

  static uint64_t MaskLeEventMask(HciVersion version, uint64_t mask);

  bool IsRpaOffloadSupported(void);

protected:
  void ListDependencies(ModuleList* list) const override;

+7 −12
Original line number Diff line number Diff line
@@ -157,13 +157,11 @@ void LeAddressManager::SetPrivacyPolicyForInitiatorAddress(
        log::info("minimum_rotation_time_={}ms, maximum_rotation_time_={}ms",
                  minimum_rotation_time_.count(), maximum_rotation_time_.count());
      }
      if (com::android::bluetooth::flags::rpa_offload_to_bt_controller() &&
          controller_->IsSupported(hci::OpCode::LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_V2)) {
      if (controller_->IsRpaOffloadSupported()) {
        auto min_seconds = std::chrono::duration_cast<std::chrono::seconds>(minimum_rotation_time_);
        auto max_seconds = std::chrono::duration_cast<std::chrono::seconds>(maximum_rotation_time_);
        log::info(
                "Support RPA offload, set min_seconds={}s, max_seconds={}s",
                min_seconds.count(), max_seconds.count());
        log::info("Support RPA offload, set min_seconds={}s, max_seconds={}s", min_seconds.count(),
                  max_seconds.count());
        /* Default to 7 minutes minimum, 15 minutes maximum for random address refreshing;
         * device can override. */
        auto packet = hci::LeSetResolvablePrivateAddressTimeoutV2Builder::Create(
@@ -223,13 +221,11 @@ void LeAddressManager::SetPrivacyPolicyForInitiatorAddressForTest(
      maximum_rotation_time_ = maximum_rotation_time;
      log::info("minimum_rotation_time_={}ms, maximum_rotation_time_={}ms",
                minimum_rotation_time_.count(), maximum_rotation_time_.count());
      if (com::android::bluetooth::flags::rpa_offload_to_bt_controller() &&
          controller_->IsSupported(hci::OpCode::LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_V2)) {
      if (controller_->IsRpaOffloadSupported()) {
        auto min_seconds = std::chrono::duration_cast<std::chrono::seconds>(minimum_rotation_time_);
        auto max_seconds = std::chrono::duration_cast<std::chrono::seconds>(maximum_rotation_time_);
        log::info(
                "Support RPA offload, set min_seconds={}s, max_seconds={}s",
                min_seconds.count(), max_seconds.count());
        log::info("Support RPA offload, set min_seconds={}s, max_seconds={}s", min_seconds.count(),
                  max_seconds.count());
        /* Default to 7 minutes minimum, 15 minutes maximum for random address refreshing;
         * device can override. */
        auto packet = hci::LeSetResolvablePrivateAddressTimeoutV2Builder::Create(
@@ -269,8 +265,7 @@ void LeAddressManager::register_client(LeAddressManagerCallback* callback) {
  } else if (address_policy_ == AddressPolicy::USE_RESOLVABLE_ADDRESS ||
             address_policy_ == AddressPolicy::USE_NON_RESOLVABLE_ADDRESS) {
    if (registered_clients_.size() == 1) {
      if (!com::android::bluetooth::flags::rpa_offload_to_bt_controller() ||
          !controller_->IsSupported(hci::OpCode::LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT_V2)) {
      if (!controller_->IsRpaOffloadSupported()) {
        schedule_rotate_random_address();
        log::info("Scheduled address rotation for first client registered");
      }
+1 −1
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@

#include <gtest/gtest.h>

#include "hci/controller.h"
#include "hci/hci_layer_fake.h"
#include "hci/octets.h"
#include "hci/controller.h"
#include "packet/raw_builder.h"

using ::bluetooth::hci::Octet16;
Loading