From: Chris Manton Date: Fri, 28 Aug 2020 00:05:36 +0000 (-0700) Subject: Use tBTM_SEC_BLE::tADDRESS_TYPE X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=94403d59b3396154453cdba0b7d7044d18ceb540;p=android-x86%2Fsystem-bt.git Use tBTM_SEC_BLE::tADDRESS_TYPE Towards readable code Bug: 163134718 Tag: #refactor Test: compile & verify basic functions working Change-Id: I5b67eba668a3bb458bf058da80b2dc08e033bd44 --- diff --git a/stack/acl/ble_acl.cc b/stack/acl/ble_acl.cc index 491bd4187..f294ed34b 100644 --- a/stack/acl/ble_acl.cc +++ b/stack/acl/ble_acl.cc @@ -59,8 +59,8 @@ void acl_ble_enhanced_connection_complete( local_rpa); if (peer_addr_type & BLE_ADDR_TYPE_ID_BIT) - btm_ble_refresh_peer_resolvable_private_addr(address_with_type.bda, - peer_rpa, BLE_ADDR_RANDOM); + btm_ble_refresh_peer_resolvable_private_addr( + address_with_type.bda, peer_rpa, tBTM_SEC_BLE::BTM_BLE_ADDR_RRA); btm_ble_update_mode_operation(role, &address_with_type.bda, HCI_SUCCESS); if (role == HCI_ROLE_SLAVE) diff --git a/stack/acl/btm_acl.cc b/stack/acl/btm_acl.cc index c2a604ddd..ed0d61237 100644 --- a/stack/acl/btm_acl.cc +++ b/stack/acl/btm_acl.cc @@ -243,17 +243,17 @@ bool btm_ble_get_acl_remote_addr(tBTM_SEC_DEV_REC* p_dev_rec, } switch (p_dev_rec->ble.active_addr_type) { - case BTM_BLE_ADDR_PSEUDO: + case tBTM_SEC_BLE::BTM_BLE_ADDR_PSEUDO: conn_addr = p_dev_rec->bd_addr; *p_addr_type = p_dev_rec->ble.ble_addr_type; break; - case BTM_BLE_ADDR_RRA: + case tBTM_SEC_BLE::BTM_BLE_ADDR_RRA: conn_addr = p_dev_rec->ble.cur_rand_addr; *p_addr_type = BLE_ADDR_RANDOM; break; - case BTM_BLE_ADDR_STATIC: + case tBTM_SEC_BLE::BTM_BLE_ADDR_STATIC: conn_addr = p_dev_rec->ble.identity_addr; *p_addr_type = p_dev_rec->ble.identity_addr_type; break; @@ -2432,7 +2432,7 @@ bool acl_refresh_remote_address(const tBTM_SEC_DEV_REC* p_sec_rec, return false; } - if (rra_type == BTM_BLE_ADDR_PSEUDO) { + if (rra_type == tBTM_SEC_BLE::BTM_BLE_ADDR_PSEUDO) { /* use identity address, resolvable_private_addr is empty */ if (rpa.IsEmpty()) { p_acl->active_remote_addr_type = p_sec_rec->ble.identity_addr_type; diff --git a/stack/btm/btm_ble.cc b/stack/btm/btm_ble.cc index 4fdd3496a..eb256aaa5 100644 --- a/stack/btm/btm_ble.cc +++ b/stack/btm/btm_ble.cc @@ -1750,7 +1750,7 @@ void btm_ble_connected(const RawAddress& bda, uint16_t handle, uint8_t enc_mode, p_dev_rec->role_master = (role == HCI_ROLE_MASTER) ? true : false; if (!addr_matched) { - p_dev_rec->ble.active_addr_type = BTM_BLE_ADDR_PSEUDO; + p_dev_rec->ble.active_addr_type = tBTM_SEC_BLE::BTM_BLE_ADDR_PSEUDO; } if (!addr_matched && p_dev_rec->ble.ble_addr_type == BLE_ADDR_RANDOM) { p_dev_rec->ble.cur_rand_addr = bda; diff --git a/stack/btm/btm_ble_addr.cc b/stack/btm/btm_ble_addr.cc index 45520307b..f171ba3f9 100644 --- a/stack/btm/btm_ble_addr.cc +++ b/stack/btm/btm_ble_addr.cc @@ -313,9 +313,9 @@ bool btm_random_pseudo_to_identity_addr(RawAddress* random_pseudo, * connection address. * ******************************************************************************/ -void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda, - const RawAddress& rpa, - uint8_t rra_type) { +void btm_ble_refresh_peer_resolvable_private_addr( + const RawAddress& pseudo_bda, const RawAddress& rpa, + tBTM_SEC_BLE::tADDRESS_TYPE rra_type) { tBTM_SEC_DEV_REC* p_sec_rec = btm_find_dev(pseudo_bda); if (p_sec_rec == nullptr) { LOG_WARN("%s No matching known device in record", __func__); @@ -324,9 +324,10 @@ void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda, p_sec_rec->ble.cur_rand_addr = rpa; - if (rra_type == BTM_BLE_ADDR_PSEUDO) { - p_sec_rec->ble.active_addr_type = - rpa.IsEmpty() ? BTM_BLE_ADDR_STATIC : BTM_BLE_ADDR_RRA; + if (rra_type == tBTM_SEC_BLE::BTM_BLE_ADDR_PSEUDO) { + p_sec_rec->ble.active_addr_type = rpa.IsEmpty() + ? tBTM_SEC_BLE::BTM_BLE_ADDR_STATIC + : tBTM_SEC_BLE::BTM_BLE_ADDR_RRA; } else { p_sec_rec->ble.active_addr_type = rra_type; } @@ -341,4 +342,3 @@ void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda, } } } - diff --git a/stack/btm/btm_ble_connection_establishment.cc b/stack/btm/btm_ble_connection_establishment.cc index 799878f7d..316079599 100644 --- a/stack/btm/btm_ble_connection_establishment.cc +++ b/stack/btm/btm_ble_connection_establishment.cc @@ -140,7 +140,7 @@ void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len, if (match_rec) { LOG(INFO) << __func__ << ": matched and resolved random address"; match = true; - match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA; + match_rec->ble.active_addr_type = tBTM_SEC_BLE::BTM_BLE_ADDR_RRA; match_rec->ble.cur_rand_addr = bda; if (!btm_ble_init_pseudo_addr(match_rec, bda)) { /* assign the original address to be the current report address */ @@ -176,8 +176,8 @@ void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len, btm_ble_refresh_local_resolvable_private_addr(bda, local_rpa); if (peer_addr_type & BLE_ADDR_TYPE_ID_BIT) - btm_ble_refresh_peer_resolvable_private_addr(bda, peer_rpa, - BLE_ADDR_RANDOM); + btm_ble_refresh_peer_resolvable_private_addr( + bda, peer_rpa, tBTM_SEC_BLE::BTM_BLE_ADDR_RRA); } } else { // Log for non HCI success case diff --git a/stack/btm/btm_ble_gap.cc b/stack/btm/btm_ble_gap.cc index 6addf2833..cce44820b 100644 --- a/stack/btm/btm_ble_gap.cc +++ b/stack/btm/btm_ble_gap.cc @@ -1614,7 +1614,7 @@ void btm_ble_process_adv_addr(RawAddress& bda, uint8_t* addr_type) { if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) { tBTM_SEC_DEV_REC* match_rec = btm_ble_resolve_random_addr(bda); if (match_rec) { - match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA; + match_rec->ble.active_addr_type = tBTM_SEC_BLE::BTM_BLE_ADDR_RRA; match_rec->ble.cur_rand_addr = bda; if (btm_ble_init_pseudo_addr(match_rec, bda)) { diff --git a/stack/btm/btm_ble_int.h b/stack/btm/btm_ble_int.h index 31257949f..1c83f9a1f 100644 --- a/stack/btm/btm_ble_int.h +++ b/stack/btm/btm_ble_int.h @@ -143,7 +143,8 @@ extern bool btm_identity_addr_to_random_pseudo_from_address_with_type( extern bool btm_random_pseudo_to_identity_addr(RawAddress* random_pseudo, uint8_t* p_identity_addr_type); extern void btm_ble_refresh_peer_resolvable_private_addr( - const RawAddress& pseudo_bda, const RawAddress& rra, uint8_t rra_type); + const RawAddress& pseudo_bda, const RawAddress& rra, + tBTM_SEC_BLE::tADDRESS_TYPE type); extern void btm_ble_read_resolving_list_entry_complete(uint8_t* p, uint16_t evt_len); extern void btm_ble_remove_resolving_list_entry_complete(uint8_t* p, diff --git a/stack/btm/btm_ble_privacy.cc b/stack/btm/btm_ble_privacy.cc index c1fe9b15c..827eeeafd 100644 --- a/stack/btm/btm_ble_privacy.cc +++ b/stack/btm/btm_ble_privacy.cc @@ -336,7 +336,9 @@ void btm_ble_remove_resolving_list_entry_complete(uint8_t* p, * ******************************************************************************/ void btm_ble_read_resolving_list_entry_complete(uint8_t* p, uint16_t evt_len) { - uint8_t status, rra_type = BTM_BLE_ADDR_PSEUDO; + uint8_t status; + tBTM_SEC_BLE::tADDRESS_TYPE rra_type = + tBTM_SEC_BLE::tADDRESS_TYPE::BTM_BLE_ADDR_PSEUDO; RawAddress rra, pseudo_bda; STREAM_TO_UINT8(status, p); diff --git a/stack/btm/security_device_record.h b/stack/btm/security_device_record.h index cbe540788..36e3f10f4 100644 --- a/stack/btm/security_device_record.h +++ b/stack/btm/security_device_record.h @@ -337,10 +337,13 @@ typedef struct { uint8_t in_controller_list; /* in controller resolving list or not */ uint8_t resolving_list_index; RawAddress cur_rand_addr; /* current random address */ - uint8_t active_addr_type; -#define BTM_BLE_ADDR_PSEUDO 0 /* address index device record */ -#define BTM_BLE_ADDR_RRA 1 /* cur_rand_addr */ -#define BTM_BLE_ADDR_STATIC 2 /* static_addr */ + + typedef enum : uint8_t { + BTM_BLE_ADDR_PSEUDO = 0, + BTM_BLE_ADDR_RRA = 1, + BTM_BLE_ADDR_STATIC = 2, + } tADDRESS_TYPE; + tADDRESS_TYPE active_addr_type; tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */ tBTM_SEC_BLE_KEYS keys; /* LE device security info in slave rode */