From: Hansong Zhang Date: Mon, 1 Feb 2021 08:35:47 +0000 (-0800) Subject: L2cap privacy shim X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=16815787d433e75f0189ac7373abaf38dc535a61;p=android-x86%2Fsystem-bt.git L2cap privacy shim Bug: 141555841 Tag: #gd-refactor Test: cert/run Change-Id: I62ac6986b9798638503cc3b2bf3e234234a0566b --- diff --git a/gd/hci/le_address_manager.cc b/gd/hci/le_address_manager.cc index fbafe060e..83b3ebc57 100644 --- a/gd/hci/le_address_manager.cc +++ b/gd/hci/le_address_manager.cc @@ -150,7 +150,7 @@ void LeAddressManager::register_client(LeAddressManagerCallback* callback) { } else if ( address_policy_ == AddressPolicy::USE_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) { schedule_rotate_random_address(); } diff --git a/main/shim/acl_api.cc b/main/shim/acl_api.cc index 38d3e0b09..8455492d9 100644 --- a/main/shim/acl_api.cc +++ b/main/shim/acl_api.cc @@ -17,6 +17,7 @@ #include #include +#include "gd/hci/acl_manager.h" #include "main/shim/acl_api.h" #include "main/shim/helpers.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) { - 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() + ->SetPrivacyPolicyForInitiatorAddress( + address_policy, empty_address_with_type, minimum_rotation_time, + maximum_rotation_time); } void bluetooth::shim::ACL_Disconnect(uint16_t handle, bool is_classic, diff --git a/stack/btm/btm_ble_gap.cc b/stack/btm/btm_ble_gap.cc index d5c6892bd..53c4fdb0c 100644 --- a/stack/btm/btm_ble_gap.cc +++ b/stack/btm/btm_ble_gap.cc @@ -705,7 +705,8 @@ bool BTM_BleConfigPrivacy(bool privacy_mode) { 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); } return true;