OSDN Git Service

Update main/shim/::ble_addr_type
authorChris Manton <cmanton@google.com>
Wed, 2 Sep 2020 04:45:37 +0000 (21:45 -0700)
committerChris Manton <cmanton@google.com>
Fri, 4 Sep 2020 16:25:59 +0000 (16:25 +0000)
Using strict types tBLE_ADDR_TYPE

Towards readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ieb3b5a50f12317b926a96d6886f431686ef2d37d

main/shim/btif_dm.cc
main/shim/btm.cc
main/shim/l2c_api.cc

index 1c94360..fd1f4e8 100644 (file)
@@ -152,8 +152,8 @@ void BTIF_RegisterBondStateChangeListener(
 void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t addr_type, bt_ssp_variant_t variant, uint8_t accept) {
   // TODO: GD expects to receive correct address type.
   // pass addr_type once it's properly set in btif layer
-  hci::AddressWithType address = ToAddressWithType(bd_addr, 0);
-  hci::AddressWithType address2 = ToAddressWithType(bd_addr, 1);
+  hci::AddressWithType address = ToAddressWithType(bd_addr, BLE_ADDR_PUBLIC);
+  hci::AddressWithType address2 = ToAddressWithType(bd_addr, BLE_ADDR_RANDOM);
   auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager();
 
   if (variant == BT_SSP_VARIANT_PASSKEY_CONFIRMATION) {
@@ -182,8 +182,8 @@ void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t addr_type, bt_ssp_varia
 void BTIF_DM_pin_reply(const RawAddress bd_addr, uint8_t addr_type, uint8_t accept, uint8_t pin_len, bt_pin_code_t pin_code) {
   // TODO: GD expects to receive correct address type.
   // pass addr_type once it's properly set in btif layer
-  hci::AddressWithType address = ToAddressWithType(bd_addr, 0);
-  hci::AddressWithType address2 = ToAddressWithType(bd_addr, 1);
+  hci::AddressWithType address = ToAddressWithType(bd_addr, BLE_ADDR_PUBLIC);
+  hci::AddressWithType address2 = ToAddressWithType(bd_addr, BLE_ADDR_RANDOM);
   auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager();
 
   if (!accept) {
index b300956..d56ef95 100644 (file)
@@ -58,7 +58,7 @@ using BtmRemoteDeviceName = tBTM_REMOTE_DEV_NAME;
 extern void btm_process_cancel_complete(uint8_t status, uint8_t mode);
 extern void btm_process_inq_complete(uint8_t status, uint8_t result_type);
 extern void btm_ble_process_adv_addr(RawAddress& raw_address,
-                                     uint8_t* address_type);
+                                     tBLE_ADDR_TYPE* address_type);
 extern void btm_ble_process_adv_pkt_cont(
     uint16_t event_type, uint8_t address_type, const RawAddress& raw_address,
     uint8_t primary_phy, uint8_t secondary_phy, uint8_t advertising_sid,
@@ -153,7 +153,8 @@ static void store_le_address_type(RawAddress address, tBLE_ADDR_TYPE type) {
 void Btm::ScanningCallbacks::on_advertisements(
     std::vector<std::shared_ptr<hci::LeReport>> reports) {
   for (auto le_report : reports) {
-    uint8_t address_type = static_cast<uint8_t>(le_report->address_type_);
+    tBLE_ADDR_TYPE address_type =
+        static_cast<tBLE_ADDR_TYPE>(le_report->address_type_);
     uint16_t extended_event_type = 0;
     uint8_t* report_data = nullptr;
     size_t report_len = 0;
index 7b96714..3719329 100644 (file)
@@ -275,7 +275,7 @@ struct LeFixedChannelHelper {
 
     (freg_.pL2CA_FixedConn_Cb)(cid_, address, true, 0, BT_TRANSPORT_LE);
     bluetooth::shim::Btm::StoreAddressType(
-        address, static_cast<uint8_t>(device.GetAddressType()));
+        address, static_cast<tBLE_ADDR_TYPE>(device.GetAddressType()));
   }
 
   void on_incoming_data(bluetooth::hci::AddressWithType remote) {