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

Commit 6426edd6 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap privacy shim

Bug: 141555841
Tag: #gd-refactor
Test: cert/run
Change-Id: I62ac6986b9798638503cc3b2bf3e234234a0566b
parent b88be74f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -150,7 +150,7 @@ void LeAddressManager::register_client(LeAddressManagerCallback* callback) {
  } else if (
  } else if (
      address_policy_ == AddressPolicy::USE_RESOLVABLE_ADDRESS ||
      address_policy_ == AddressPolicy::USE_RESOLVABLE_ADDRESS ||
      address_policy_ == AddressPolicy::USE_NON_RESOLVABLE_ADDRESS) {
      address_policy_ == AddressPolicy::USE_NON_RESOLVABLE_ADDRESS) {
    if (bluetooth::common::init_flags::gd_acl_is_enabled()) {
    if (bluetooth::common::init_flags::gd_acl_is_enabled() || bluetooth::common::init_flags::gd_l2cap_is_enabled()) {
      if (registered_clients_.size() == 1) {
      if (registered_clients_.size() == 1) {
        schedule_rotate_random_address();
        schedule_rotate_random_address();
      }
      }
+17 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
#include <cstddef>
#include <cstddef>
#include <cstdint>
#include <cstdint>


#include "gd/hci/acl_manager.h"
#include "main/shim/acl_api.h"
#include "main/shim/acl_api.h"
#include "main/shim/helpers.h"
#include "main/shim/helpers.h"
#include "main/shim/stack.h"
#include "main/shim/stack.h"
@@ -49,7 +50,22 @@ void bluetooth::shim::ACL_WriteData(uint16_t handle, const BT_HDR* p_buf) {
}
}


void bluetooth::shim::ACL_ConfigureLePrivacy(bool is_le_privacy_enabled) {
void bluetooth::shim::ACL_ConfigureLePrivacy(bool is_le_privacy_enabled) {
  Stack::GetInstance()->GetAcl()->ConfigureLePrivacy(is_le_privacy_enabled);
  hci::LeAddressManager::AddressPolicy address_policy =
      is_le_privacy_enabled
          ? hci::LeAddressManager::AddressPolicy::USE_RESOLVABLE_ADDRESS
          : hci::LeAddressManager::AddressPolicy::USE_PUBLIC_ADDRESS;
  hci::AddressWithType empty_address_with_type(
      hci::Address{}, hci::AddressType::RANDOM_DEVICE_ADDRESS);
  /* 7 minutes minimum, 15 minutes maximum for random address refreshing */
  auto minimum_rotation_time = std::chrono::minutes(7);
  auto maximum_rotation_time = std::chrono::minutes(15);

  Stack::GetInstance()
      ->GetStackManager()
      ->GetInstance<bluetooth::hci::AclManager>()
      ->SetPrivacyPolicyForInitiatorAddress(
          address_policy, empty_address_with_type, minimum_rotation_time,
          maximum_rotation_time);
}
}


void bluetooth::shim::ACL_Disconnect(uint16_t handle, bool is_classic,
void bluetooth::shim::ACL_Disconnect(uint16_t handle, bool is_classic,
+2 −1
Original line number Original line Diff line number Diff line
@@ -705,7 +705,8 @@ bool BTM_BleConfigPrivacy(bool privacy_mode) {


  GAP_BleAttrDBUpdate(GATT_UUID_GAP_CENTRAL_ADDR_RESOL, &gap_ble_attr_value);
  GAP_BleAttrDBUpdate(GATT_UUID_GAP_CENTRAL_ADDR_RESOL, &gap_ble_attr_value);


  if (bluetooth::shim::is_gd_acl_enabled()) {
  if (bluetooth::shim::is_gd_acl_enabled() ||
      bluetooth::shim::is_gd_l2cap_enabled()) {
    bluetooth::shim::ACL_ConfigureLePrivacy(privacy_mode);
    bluetooth::shim::ACL_ConfigureLePrivacy(privacy_mode);
  }
  }
  return true;
  return true;