Loading system/rust/src/connection/ffi/connection_shim.cc +1 −5 Original line number Diff line number Diff line Loading @@ -29,9 +29,6 @@ #include "src/core/ffi/types.h" #include "stack/btm/btm_dev.h" extern const tBLE_BD_ADDR convert_to_address_with_type( const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec); namespace bluetooth { namespace connection { Loading Loading @@ -177,8 +174,7 @@ void RegisterRustApis( } core::AddressWithType ResolveRawAddress(RawAddress bd_addr) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); tBLE_BD_ADDR address = convert_to_address_with_type(bd_addr, p_dev_rec); tBLE_BD_ADDR address = BTM_Sec_GetAddressWithType(bd_addr); return core::ToRustAddress(address); } Loading system/stack/btm/btm_ble_bgconn.cc +2 −67 Original line number Diff line number Diff line Loading @@ -63,38 +63,6 @@ struct BgConnHash { static std::unordered_map<RawAddress, BackgroundConnection, BgConnHash> background_connections; const tBLE_BD_ADDR convert_to_address_with_type( const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec) { if (p_dev_rec == nullptr || !p_dev_rec->is_device_type_has_ble()) { return { .type = BLE_ADDR_PUBLIC, .bda = bd_addr, }; } if (p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) { return { .type = p_dev_rec->ble.AddressType(), .bda = bd_addr, }; } else { // Floss doesn't support LL Privacy (yet). To expedite ARC testing, always // connect to the latest LE random address (if available and LL Privacy is // not enabled) rather than redesign. // TODO(b/235218533): Remove when LL Privacy is implemented. #if TARGET_FLOSS if (!p_dev_rec->ble.cur_rand_addr.IsEmpty() && btm_cb.ble_ctr_cb.privacy_mode < BTM_PRIVACY_1_2) { return { .type = BLE_ADDR_RANDOM, .bda = p_dev_rec->ble.cur_rand_addr, }; } #endif return p_dev_rec->ble.identity_address_with_type; } } /******************************************************************************* * * Function btm_update_scanner_filter_policy Loading Loading @@ -155,35 +123,6 @@ bool btm_ble_resume_bg_conn(void) { return true; } bool BTM_BackgroundConnectAddressKnown(const RawAddress& address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); // not a known device, or a classic device, we assume public address if (p_dev_rec == NULL || (p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) == 0) return true; LOG_WARN("%s, device type not BLE: 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), p_dev_rec->device_type); // bonded device with identity address known if (!p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) { return true; } // Public address, Random Static, or Random Non-Resolvable Address known if (p_dev_rec->ble.AddressType() == BLE_ADDR_PUBLIC || !BTM_BLE_IS_RESOLVE_BDA(address)) { return true; } LOG_WARN("%s, the address type is 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), p_dev_rec->ble.AddressType()); // Only Resolvable Private Address (RPA) is known, we don't allow it into // the background connection procedure. return false; } /** Adds the device into acceptlist. Returns false if acceptlist is full and * device can't be added, true otherwise. */ bool BTM_AcceptlistAdd(const RawAddress& address) { Loading @@ -199,10 +138,8 @@ bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct) { return false; } tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); return bluetooth::shim::ACL_AcceptLeConnectionFrom( convert_to_address_with_type(address, p_dev_rec), is_direct); BTM_Sec_GetAddressWithType(address), is_direct); } /** Removes the device from acceptlist */ Loading @@ -212,10 +149,8 @@ void BTM_AcceptlistRemove(const RawAddress& address) { return; } tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); bluetooth::shim::ACL_IgnoreLeConnectionFrom( convert_to_address_with_type(address, p_dev_rec)); BTM_Sec_GetAddressWithType(address)); return; } Loading system/stack/btm/btm_ble_gap.cc +0 −2 Original line number Diff line number Diff line Loading @@ -76,8 +76,6 @@ bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr, bool refresh); void btm_ble_batchscan_init(void); void btm_ble_adv_filter_init(void); extern const tBLE_BD_ADDR convert_to_address_with_type( const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec); #define BTM_EXT_BLE_RMT_NAME_TIMEOUT_MS (30 * 1000) #define MIN_ADV_LENGTH 2 Loading system/stack/btm/btm_dev.cc +77 −0 Original line number Diff line number Diff line Loading @@ -707,3 +707,80 @@ std::vector<tBTM_SEC_DEV_REC*> btm_get_sec_dev_rec() { } return result; } /******************************************************************************* * * Function BTM_Sec_AddressKnown * * Description Query the secure device database and check * whether the device associated with address has * its address resolved * * Returns True if * - the device is unknown, or * - the device is classic, or * - the device is ble and has a public address * - the device is ble with a resolved identity address * False, otherwise * ******************************************************************************/ bool BTM_Sec_AddressKnown(const RawAddress& address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); // not a known device, or a classic device, we assume public address if (p_dev_rec == NULL || (p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) == 0) return true; LOG_WARN("%s, device type not BLE: 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), p_dev_rec->device_type); // bonded device with identity address known if (!p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) { return true; } // Public address, Random Static, or Random Non-Resolvable Address known if (p_dev_rec->ble.AddressType() == BLE_ADDR_PUBLIC || !BTM_BLE_IS_RESOLVE_BDA(address)) { return true; } LOG_WARN("%s, the address type is 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), p_dev_rec->ble.AddressType()); // Only Resolvable Private Address (RPA) is known, we don't allow it into // the background connection procedure. return false; } const tBLE_BD_ADDR BTM_Sec_GetAddressWithType(const RawAddress& bd_addr) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); if (p_dev_rec == nullptr || !p_dev_rec->is_device_type_has_ble()) { return { .type = BLE_ADDR_PUBLIC, .bda = bd_addr, }; } if (p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) { return { .type = p_dev_rec->ble.AddressType(), .bda = bd_addr, }; } else { // Floss doesn't support LL Privacy (yet). To expedite ARC testing, always // connect to the latest LE random address (if available and LL Privacy is // not enabled) rather than redesign. // TODO(b/235218533): Remove when LL Privacy is implemented. #if TARGET_FLOSS if (!p_dev_rec->ble.cur_rand_addr.IsEmpty() && btm_cb.ble_ctr_cb.privacy_mode < BTM_PRIVACY_1_2) { return { .type = BLE_ADDR_RANDOM, .bda = p_dev_rec->ble.cur_rand_addr, }; } #endif return p_dev_rec->ble.identity_address_with_type; } } system/stack/btm/btm_dev.h +4 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include "stack/btm/security_device_record.h" #include "types/ble_address_with_type.h" #include "types/raw_address.h" void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec); Loading Loading @@ -206,3 +207,6 @@ bool btm_set_bond_type_dev(const RawAddress& bd_addr, * ******************************************************************************/ std::vector<tBTM_SEC_DEV_REC*> btm_get_sec_dev_rec(); bool BTM_Sec_AddressKnown(const RawAddress& address); const tBLE_BD_ADDR BTM_Sec_GetAddressWithType(const RawAddress& bd_addr); Loading
system/rust/src/connection/ffi/connection_shim.cc +1 −5 Original line number Diff line number Diff line Loading @@ -29,9 +29,6 @@ #include "src/core/ffi/types.h" #include "stack/btm/btm_dev.h" extern const tBLE_BD_ADDR convert_to_address_with_type( const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec); namespace bluetooth { namespace connection { Loading Loading @@ -177,8 +174,7 @@ void RegisterRustApis( } core::AddressWithType ResolveRawAddress(RawAddress bd_addr) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); tBLE_BD_ADDR address = convert_to_address_with_type(bd_addr, p_dev_rec); tBLE_BD_ADDR address = BTM_Sec_GetAddressWithType(bd_addr); return core::ToRustAddress(address); } Loading
system/stack/btm/btm_ble_bgconn.cc +2 −67 Original line number Diff line number Diff line Loading @@ -63,38 +63,6 @@ struct BgConnHash { static std::unordered_map<RawAddress, BackgroundConnection, BgConnHash> background_connections; const tBLE_BD_ADDR convert_to_address_with_type( const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec) { if (p_dev_rec == nullptr || !p_dev_rec->is_device_type_has_ble()) { return { .type = BLE_ADDR_PUBLIC, .bda = bd_addr, }; } if (p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) { return { .type = p_dev_rec->ble.AddressType(), .bda = bd_addr, }; } else { // Floss doesn't support LL Privacy (yet). To expedite ARC testing, always // connect to the latest LE random address (if available and LL Privacy is // not enabled) rather than redesign. // TODO(b/235218533): Remove when LL Privacy is implemented. #if TARGET_FLOSS if (!p_dev_rec->ble.cur_rand_addr.IsEmpty() && btm_cb.ble_ctr_cb.privacy_mode < BTM_PRIVACY_1_2) { return { .type = BLE_ADDR_RANDOM, .bda = p_dev_rec->ble.cur_rand_addr, }; } #endif return p_dev_rec->ble.identity_address_with_type; } } /******************************************************************************* * * Function btm_update_scanner_filter_policy Loading Loading @@ -155,35 +123,6 @@ bool btm_ble_resume_bg_conn(void) { return true; } bool BTM_BackgroundConnectAddressKnown(const RawAddress& address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); // not a known device, or a classic device, we assume public address if (p_dev_rec == NULL || (p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) == 0) return true; LOG_WARN("%s, device type not BLE: 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), p_dev_rec->device_type); // bonded device with identity address known if (!p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) { return true; } // Public address, Random Static, or Random Non-Resolvable Address known if (p_dev_rec->ble.AddressType() == BLE_ADDR_PUBLIC || !BTM_BLE_IS_RESOLVE_BDA(address)) { return true; } LOG_WARN("%s, the address type is 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), p_dev_rec->ble.AddressType()); // Only Resolvable Private Address (RPA) is known, we don't allow it into // the background connection procedure. return false; } /** Adds the device into acceptlist. Returns false if acceptlist is full and * device can't be added, true otherwise. */ bool BTM_AcceptlistAdd(const RawAddress& address) { Loading @@ -199,10 +138,8 @@ bool BTM_AcceptlistAdd(const RawAddress& address, bool is_direct) { return false; } tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); return bluetooth::shim::ACL_AcceptLeConnectionFrom( convert_to_address_with_type(address, p_dev_rec), is_direct); BTM_Sec_GetAddressWithType(address), is_direct); } /** Removes the device from acceptlist */ Loading @@ -212,10 +149,8 @@ void BTM_AcceptlistRemove(const RawAddress& address) { return; } tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); bluetooth::shim::ACL_IgnoreLeConnectionFrom( convert_to_address_with_type(address, p_dev_rec)); BTM_Sec_GetAddressWithType(address)); return; } Loading
system/stack/btm/btm_ble_gap.cc +0 −2 Original line number Diff line number Diff line Loading @@ -76,8 +76,6 @@ bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr, bool refresh); void btm_ble_batchscan_init(void); void btm_ble_adv_filter_init(void); extern const tBLE_BD_ADDR convert_to_address_with_type( const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec); #define BTM_EXT_BLE_RMT_NAME_TIMEOUT_MS (30 * 1000) #define MIN_ADV_LENGTH 2 Loading
system/stack/btm/btm_dev.cc +77 −0 Original line number Diff line number Diff line Loading @@ -707,3 +707,80 @@ std::vector<tBTM_SEC_DEV_REC*> btm_get_sec_dev_rec() { } return result; } /******************************************************************************* * * Function BTM_Sec_AddressKnown * * Description Query the secure device database and check * whether the device associated with address has * its address resolved * * Returns True if * - the device is unknown, or * - the device is classic, or * - the device is ble and has a public address * - the device is ble with a resolved identity address * False, otherwise * ******************************************************************************/ bool BTM_Sec_AddressKnown(const RawAddress& address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); // not a known device, or a classic device, we assume public address if (p_dev_rec == NULL || (p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) == 0) return true; LOG_WARN("%s, device type not BLE: 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), p_dev_rec->device_type); // bonded device with identity address known if (!p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) { return true; } // Public address, Random Static, or Random Non-Resolvable Address known if (p_dev_rec->ble.AddressType() == BLE_ADDR_PUBLIC || !BTM_BLE_IS_RESOLVE_BDA(address)) { return true; } LOG_WARN("%s, the address type is 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), p_dev_rec->ble.AddressType()); // Only Resolvable Private Address (RPA) is known, we don't allow it into // the background connection procedure. return false; } const tBLE_BD_ADDR BTM_Sec_GetAddressWithType(const RawAddress& bd_addr) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); if (p_dev_rec == nullptr || !p_dev_rec->is_device_type_has_ble()) { return { .type = BLE_ADDR_PUBLIC, .bda = bd_addr, }; } if (p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) { return { .type = p_dev_rec->ble.AddressType(), .bda = bd_addr, }; } else { // Floss doesn't support LL Privacy (yet). To expedite ARC testing, always // connect to the latest LE random address (if available and LL Privacy is // not enabled) rather than redesign. // TODO(b/235218533): Remove when LL Privacy is implemented. #if TARGET_FLOSS if (!p_dev_rec->ble.cur_rand_addr.IsEmpty() && btm_cb.ble_ctr_cb.privacy_mode < BTM_PRIVACY_1_2) { return { .type = BLE_ADDR_RANDOM, .bda = p_dev_rec->ble.cur_rand_addr, }; } #endif return p_dev_rec->ble.identity_address_with_type; } }
system/stack/btm/btm_dev.h +4 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include "stack/btm/security_device_record.h" #include "types/ble_address_with_type.h" #include "types/raw_address.h" void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec); Loading Loading @@ -206,3 +207,6 @@ bool btm_set_bond_type_dev(const RawAddress& bd_addr, * ******************************************************************************/ std::vector<tBTM_SEC_DEV_REC*> btm_get_sec_dev_rec(); bool BTM_Sec_AddressKnown(const RawAddress& address); const tBLE_BD_ADDR BTM_Sec_GetAddressWithType(const RawAddress& bd_addr);