From da9ecc82c93101735e75efb34c73b5dfa31eb440 Mon Sep 17 00:00:00 2001 From: Benson Li <bensonli@google.com> Date: Fri, 19 May 2023 11:37:09 +0000 Subject: [PATCH] Revert "shim::LeScanningManager: Use shim storage" This reverts commit ff263c5308fd1953be477099b2d23167db1291d9. Reason for revert: b/283393411 (cherry picked from https://android-review.googlesource.com/q/commit:4ff9b6513dcce62f3e81b8f8cd6ecffb1d7a7459) Merged-In: Idb4bea1b68c543891cfc7ebb953f1ebfd081e8af Change-Id: Idb4bea1b68c543891cfc7ebb953f1ebfd081e8af --- system/main/shim/le_scanning_manager.cc | 38 ++++++++++--------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/system/main/shim/le_scanning_manager.cc b/system/main/shim/le_scanning_manager.cc index 085f27a7b38..ae76e8fa1a4 100644 --- a/system/main/shim/le_scanning_manager.cc +++ b/system/main/shim/le_scanning_manager.cc @@ -29,12 +29,10 @@ #include "advertise_data_parser.h" #include "btif/include/btif_common.h" #include "hci/address.h" -#include "hci/enum_helper.h" #include "hci/le_scanning_manager.h" #include "hci/msft.h" #include "include/hardware/ble_scanner.h" #include "main/shim/ble_scanner_interface_impl.h" -#include "main/shim/config.h" #include "main/shim/dumpsys.h" #include "main/shim/entry.h" #include "main/shim/helpers.h" @@ -42,6 +40,9 @@ #include "main/shim/shim.h" #include "stack/btm/btm_int_types.h" #include "stack/include/btm_log_history.h" +#include "storage/device.h" +#include "storage/le_device.h" +#include "storage/storage_module.h" #include "types/ble_address_with_type.h" #include "types/bluetooth/uuid.h" #include "types/raw_address.h" @@ -797,31 +798,22 @@ void BleScannerInterfaceImpl::handle_remote_properties( device_type); } + auto* storage_module = bluetooth::shim::GetStorage(); bluetooth::hci::Address address = ToGdAddress(bd_addr); - std::string device_type_property = ""; // update device type - switch (device_type) { - case bluetooth::hci::DeviceType::UNKNOWN: - device_type_property = "UNKNOWN"; - break; - case bluetooth::hci::DeviceType::BR_EDR: - device_type_property = "BR_EDR"; - break; - case bluetooth::hci::DeviceType::LE: - device_type_property = "LE"; - break; - case bluetooth::hci::DeviceType::DUAL: - device_type_property = "DUAL"; - break; - } - bluetooth::shim::BtifConfigInterface::SetStr(address.ToString(), "DevType", - device_type_property); + auto mutation = storage_module->Modify(); + bluetooth::storage::Device device = + storage_module->GetDeviceByLegacyKey(address); + mutation.Add(device.SetDeviceType(device_type)); + mutation.Commit(); + // update address type - std::string address_type = bluetooth::hci::AddressTypeText( - static_cast<bluetooth::hci::AddressType>(addr_type)); - bluetooth::shim::BtifConfigInterface::SetStr(address.ToString(), "AddrType", - address_type); + auto mutation2 = storage_module->Modify(); + bluetooth::storage::LeDevice le_device = device.Le(); + mutation2.Add( + le_device.SetAddressType((bluetooth::hci::AddressType)addr_type)); + mutation2.Commit(); } void BleScannerInterfaceImpl::AddressCache::add(const RawAddress& p_bda) { -- GitLab