Loading system/btif/include/btif_config.h +0 −37 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ static const std::string BT_CONFIG_KEY_REMOTE_VER_MFCT = "Manufacturer"; static const std::string BT_CONFIG_KEY_REMOTE_VER_VER = "LmpVer"; static const std::string BT_CONFIG_KEY_REMOTE_VER_SUBVER = "LmpSubVer"; bool btif_config_has_section(const char* section); bool btif_config_exist(const std::string& section, const std::string& key); bool btif_config_get_int(const std::string& section, const std::string& key, int* value); Loading Loading @@ -76,39 +75,3 @@ bool btif_get_address_type(const RawAddress& bd_addr, int* p_addr_type); bool btif_get_device_type(const RawAddress& bd_addr, int* p_device_type); void btif_debug_config_dump(int fd); typedef struct { std::string (*checksum_read)(const char* filename); bool (*checksum_save)(const std::string& checksum, const std::string& filename); bool (*config_get_bool)(const config_t& config, const std::string& section, const std::string& key, bool def_value); int (*config_get_int)(const config_t& config, const std::string& section, const std::string& key, int def_value); const std::string* (*config_get_string)(const config_t& config, const std::string& section, const std::string& key, const std::string* def_value); uint64_t (*config_get_uint64)(const config_t& config, const std::string& section, const std::string& key, uint64_t def_value); bool (*config_has_key)(const config_t& config, const std::string& section, const std::string& key); bool (*config_has_section)(const config_t& config, const std::string& section); std::unique_ptr<config_t> (*config_new)(const char* filename); std::unique_ptr<config_t> (*config_new_clone)(const config_t& src); std::unique_ptr<config_t> (*config_new_empty)(void); bool (*config_remove_key)(config_t* config, const std::string& section, const std::string& key); bool (*config_remove_section)(config_t* config, const std::string& section); bool (*config_save)(const config_t& config, const std::string& filename); void (*config_set_bool)(config_t* config, const std::string& section, const std::string& key, bool value); void (*config_set_int)(config_t* config, const std::string& section, const std::string& key, int value); void (*config_set_string)(config_t* config, const std::string& section, const std::string& key, const std::string& value); void (*config_set_uint64)(config_t* config, const std::string& section, const std::string& key, uint64_t value); } storage_config_t; system/btif/src/btif_config.cc +105 −44 Original line number Diff line number Diff line Loading @@ -20,29 +20,29 @@ #include "btif_config.h" #include <base/logging.h> #include <ctype.h> #include <openssl/rand.h> #include <openssl/sha.h> #include <private/android_filesystem_config.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h> #include <cctype> #include <cstdio> #include <cstring> #include <ctime> #include <functional> #include <mutex> #include <sstream> #include <string> #include <unordered_map> #include <btif_keystore.h> #include "bt_types.h" #include <private/android_filesystem_config.h> #include <openssl/rand.h> #include <base/logging.h> #include "btcore/include/module.h" #include "btif_api.h" #include "btif_common.h" #include "btif_config_cache.h" #include "btif_config_transcode.h" #include "btif_util.h" #include "btif_keystore.h" #include "common/address_obfuscator.h" #include "common/metric_id_allocator.h" #include "main/shim/config.h" Loading Loading @@ -123,23 +123,6 @@ static enum ConfigSource { static char btif_config_time_created[TIME_STRING_LENGTH]; static const storage_config_t interface = { checksum_read, checksum_save, config_get_bool, config_get_int, config_get_string, config_get_uint64, config_has_key, config_has_section, config_new, config_new_clone, config_new_empty, config_remove_key, config_remove_section, config_save, config_set_bool, config_set_int, config_set_string, config_set_uint64, }; static const storage_config_t* storage_config_get_interface() { if (bluetooth::shim::is_gd_stack_started_up()) { return bluetooth::shim::storage_config_get_interface(); } else { return &interface; } } static BluetoothKeystoreInterface* get_bluetooth_keystore_interface() { return bluetooth::bluetooth_keystore::getBluetoothKeystoreInterface(); } Loading Loading @@ -268,6 +251,13 @@ static BtifConfigCache btif_config_cache(TEMPORARY_SECTION_CAPACITY); // Module lifecycle functions static future_t* init(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); // TODO (b/158035889) Migrate metrics module to GD read_or_set_metrics_salt(); init_metric_id_allocator(); return future_new_immediate(FUTURE_SUCCESS); } std::unique_lock<std::recursive_mutex> lock(config_lock); std::unique_ptr<config_t> config; Loading Loading @@ -298,7 +288,7 @@ static future_t* init(void) { if (!config) { LOG_ERROR("%s unable to transcode legacy file; creating empty config.", __func__); config = storage_config_get_interface()->config_new_empty(); config = config_new_empty(); btif_config_source = NEW_FILE; file_source = "Empty"; } Loading Loading @@ -357,8 +347,7 @@ error: } static std::unique_ptr<config_t> btif_config_open(const char* filename) { std::unique_ptr<config_t> config = storage_config_get_interface()->config_new(filename); std::unique_ptr<config_t> config = config_new(filename); if (!config) return nullptr; if (!config_has_section(*config, "Adapter")) { Loading @@ -375,6 +364,13 @@ static future_t* shut_down(void) { } static future_t* clean_up(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); // GD storage module cleanup by itself std::unique_lock<std::recursive_mutex> lock(config_lock); MetricIdAllocator::GetInstance().Close(); return future_new_immediate(FUTURE_SUCCESS); } btif_config_flush(); alarm_free(config_timer); Loading @@ -393,20 +389,21 @@ EXPORT_SYMBOL module_t btif_config_module = {.name = BTIF_CONFIG_MODULE, .shut_down = shut_down, .clean_up = clean_up}; bool btif_config_has_section(const char* section) { CHECK(section != NULL); std::unique_lock<std::recursive_mutex> lock(config_lock); return btif_config_cache.HasSection(section); } bool btif_config_exist(const std::string& section, const std::string& key) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::HasProperty(section, key); } std::unique_lock<std::recursive_mutex> lock(config_lock); return btif_config_cache.HasKey(section, key); } bool btif_config_get_int(const std::string& section, const std::string& key, int* value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetInt(section, key, value); } CHECK(value != NULL); std::unique_lock<std::recursive_mutex> lock(config_lock); auto ret = btif_config_cache.GetInt(section, key); Loading @@ -419,6 +416,10 @@ bool btif_config_get_int(const std::string& section, const std::string& key, bool btif_config_set_int(const std::string& section, const std::string& key, int value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::SetInt(section, key, value); } std::unique_lock<std::recursive_mutex> lock(config_lock); btif_config_cache.SetInt(section, key, value); return true; Loading @@ -426,6 +427,10 @@ bool btif_config_set_int(const std::string& section, const std::string& key, bool btif_config_get_uint64(const std::string& section, const std::string& key, uint64_t* value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetUint64(section, key, value); } CHECK(value != NULL); std::unique_lock<std::recursive_mutex> lock(config_lock); auto ret = btif_config_cache.GetUint64(section, key); Loading @@ -438,6 +443,10 @@ bool btif_config_get_uint64(const std::string& section, const std::string& key, bool btif_config_set_uint64(const std::string& section, const std::string& key, uint64_t value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::SetUint64(section, key, value); } std::unique_lock<std::recursive_mutex> lock(config_lock); btif_config_cache.SetUint64(section, key, value); return true; Loading @@ -445,6 +454,11 @@ bool btif_config_set_uint64(const std::string& section, const std::string& key, bool btif_config_get_str(const std::string& section, const std::string& key, char* value, int* size_bytes) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetStr(section, key, value, size_bytes); } CHECK(value != NULL); CHECK(size_bytes != NULL); Loading @@ -460,6 +474,10 @@ bool btif_config_get_str(const std::string& section, const std::string& key, bool btif_config_set_str(const std::string& section, const std::string& key, const std::string& value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::SetStr(section, key, value); } std::unique_lock<std::recursive_mutex> lock(config_lock); btif_config_cache.SetString(section, key, value); return true; Loading @@ -473,6 +491,11 @@ static bool btif_in_encrypt_key_name_list(std::string key) { bool btif_config_get_bin(const std::string& section, const std::string& key, uint8_t* value, size_t* length) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetBin(section, key, value, length); } CHECK(value != NULL); CHECK(length != NULL); Loading Loading @@ -533,6 +556,10 @@ bool btif_config_get_bin(const std::string& section, const std::string& key, size_t btif_config_get_bin_length(const std::string& section, const std::string& key) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetBinLength(section, key); } std::unique_lock<std::recursive_mutex> lock(config_lock); auto value_str = btif_config_cache.GetString(section, key); if (!value_str) return 0; Loading @@ -542,6 +569,11 @@ size_t btif_config_get_bin_length(const std::string& section, bool btif_config_set_bin(const std::string& section, const std::string& key, const uint8_t* value, size_t length) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::SetBin(section, key, value, length); } const char* lookup = "0123456789abcdef"; if (length > 0) CHECK(value != NULL); Loading Loading @@ -579,7 +611,10 @@ bool btif_config_set_bin(const std::string& section, const std::string& key, std::vector<RawAddress> btif_config_get_paired_devices() { std::vector<std::string> names; { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); names = bluetooth::shim::BtifConfigInterface::GetPersistentDevices(); } else { std::unique_lock<std::recursive_mutex> lock(config_lock); names = btif_config_cache.GetPersistentSectionNames(); } Loading @@ -597,6 +632,10 @@ std::vector<RawAddress> btif_config_get_paired_devices() { } bool btif_config_remove(const std::string& section, const std::string& key) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::RemoveProperty(section, key); } if (is_niap_mode() && btif_in_encrypt_key_name_list(key)) { get_bluetooth_keystore_interface()->set_encrypt_key_or_remove_key( section + "-" + key, ""); Loading @@ -606,12 +645,22 @@ bool btif_config_remove(const std::string& section, const std::string& key) { } void btif_config_save(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); bluetooth::shim::BtifConfigInterface::Save(); return; } CHECK(config_timer != NULL); alarm_set(config_timer, CONFIG_SETTLE_PERIOD_MS, timer_config_save_cb, NULL); } void btif_config_flush(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); bluetooth::shim::BtifConfigInterface::Flush(); return; } CHECK(config_timer != NULL); alarm_cancel(config_timer); Loading @@ -619,6 +668,12 @@ void btif_config_flush(void) { } bool btif_config_clear(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); bluetooth::shim::BtifConfigInterface::Clear(); bluetooth::shim::BtifConfigInterface::Save(); return true; } CHECK(config_timer != NULL); alarm_cancel(config_timer); Loading @@ -626,8 +681,8 @@ bool btif_config_clear(void) { std::unique_lock<std::recursive_mutex> lock(config_lock); btif_config_cache.Clear(); bool ret = storage_config_get_interface()->config_save( btif_config_cache.PersistentSectionCopy(), CONFIG_FILE_PATH); bool ret = config_save(btif_config_cache.PersistentSectionCopy(), CONFIG_FILE_PATH); btif_config_source = RESET; return ret; Loading @@ -646,8 +701,7 @@ static void btif_config_write(UNUSED_ATTR uint16_t event, std::unique_lock<std::recursive_mutex> lock(config_lock); rename(CONFIG_FILE_PATH, CONFIG_BACKUP_PATH); storage_config_get_interface()->config_save( btif_config_cache.PersistentSectionCopy(), CONFIG_FILE_PATH); config_save(btif_config_cache.PersistentSectionCopy(), CONFIG_FILE_PATH); if (btif_is_niap_mode()) { get_bluetooth_keystore_interface()->set_encrypt_key_or_remove_key( CONFIG_FILE_PREFIX, CONFIG_FILE_HASH); Loading Loading @@ -679,7 +733,14 @@ void btif_debug_config_dump(int fd) { break; } auto file_source = btif_config_cache.GetString(INFO_SECTION, FILE_SOURCE); std::optional<std::string> file_source; if (bluetooth::shim::is_gd_stack_started_up()) { CHECK(bluetooth::shim::is_gd_shim_enabled()); file_source = bluetooth::shim::BtifConfigInterface::GetStr(INFO_SECTION, FILE_SOURCE); } else { file_source = btif_config_cache.GetString(INFO_SECTION, FILE_SOURCE); } if (!file_source) { file_source.emplace("Original"); } Loading system/gd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,7 @@ cc_binary { "android.hardware.bluetooth@1.0", "libhidlbase", "libutils", "libcutils", ], }, host: { Loading system/gd/facade/grpc_root_server.cc +2 −2 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ #include "shim/dumpsys.h" #include "shim/l2cap.h" #include "stack_manager.h" #include "storage/legacy.h" #include "storage/storage_module.h" namespace bluetooth { namespace facade { Loading Loading @@ -124,7 +124,7 @@ class RootFacadeService : public ::bluetooth::facade::RootFacade::Service { modules.add<::bluetooth::hci::LeAdvertisingManager>(); modules.add<::bluetooth::hci::LeScanningManager>(); modules.add<::bluetooth::security::SecurityModule>(); modules.add<::bluetooth::storage::LegacyModule>(); modules.add<::bluetooth::storage::StorageModule>(); break; default: return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "invalid module under test"); Loading system/gd/os/Android.bp +2 −0 Original line number Diff line number Diff line filegroup { name: "BluetoothOsSources_android", srcs: [ "android/parameter_provider.cc", "android/system_properties.cc", ], } Loading @@ -15,6 +16,7 @@ filegroup { filegroup { name: "BluetoothOsSources_host", srcs: [ "host/parameter_provider.cc", "host/system_properties.cc", ], } Loading Loading
system/btif/include/btif_config.h +0 −37 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ static const std::string BT_CONFIG_KEY_REMOTE_VER_MFCT = "Manufacturer"; static const std::string BT_CONFIG_KEY_REMOTE_VER_VER = "LmpVer"; static const std::string BT_CONFIG_KEY_REMOTE_VER_SUBVER = "LmpSubVer"; bool btif_config_has_section(const char* section); bool btif_config_exist(const std::string& section, const std::string& key); bool btif_config_get_int(const std::string& section, const std::string& key, int* value); Loading Loading @@ -76,39 +75,3 @@ bool btif_get_address_type(const RawAddress& bd_addr, int* p_addr_type); bool btif_get_device_type(const RawAddress& bd_addr, int* p_device_type); void btif_debug_config_dump(int fd); typedef struct { std::string (*checksum_read)(const char* filename); bool (*checksum_save)(const std::string& checksum, const std::string& filename); bool (*config_get_bool)(const config_t& config, const std::string& section, const std::string& key, bool def_value); int (*config_get_int)(const config_t& config, const std::string& section, const std::string& key, int def_value); const std::string* (*config_get_string)(const config_t& config, const std::string& section, const std::string& key, const std::string* def_value); uint64_t (*config_get_uint64)(const config_t& config, const std::string& section, const std::string& key, uint64_t def_value); bool (*config_has_key)(const config_t& config, const std::string& section, const std::string& key); bool (*config_has_section)(const config_t& config, const std::string& section); std::unique_ptr<config_t> (*config_new)(const char* filename); std::unique_ptr<config_t> (*config_new_clone)(const config_t& src); std::unique_ptr<config_t> (*config_new_empty)(void); bool (*config_remove_key)(config_t* config, const std::string& section, const std::string& key); bool (*config_remove_section)(config_t* config, const std::string& section); bool (*config_save)(const config_t& config, const std::string& filename); void (*config_set_bool)(config_t* config, const std::string& section, const std::string& key, bool value); void (*config_set_int)(config_t* config, const std::string& section, const std::string& key, int value); void (*config_set_string)(config_t* config, const std::string& section, const std::string& key, const std::string& value); void (*config_set_uint64)(config_t* config, const std::string& section, const std::string& key, uint64_t value); } storage_config_t;
system/btif/src/btif_config.cc +105 −44 Original line number Diff line number Diff line Loading @@ -20,29 +20,29 @@ #include "btif_config.h" #include <base/logging.h> #include <ctype.h> #include <openssl/rand.h> #include <openssl/sha.h> #include <private/android_filesystem_config.h> #include <stdio.h> #include <string.h> #include <time.h> #include <unistd.h> #include <cctype> #include <cstdio> #include <cstring> #include <ctime> #include <functional> #include <mutex> #include <sstream> #include <string> #include <unordered_map> #include <btif_keystore.h> #include "bt_types.h" #include <private/android_filesystem_config.h> #include <openssl/rand.h> #include <base/logging.h> #include "btcore/include/module.h" #include "btif_api.h" #include "btif_common.h" #include "btif_config_cache.h" #include "btif_config_transcode.h" #include "btif_util.h" #include "btif_keystore.h" #include "common/address_obfuscator.h" #include "common/metric_id_allocator.h" #include "main/shim/config.h" Loading Loading @@ -123,23 +123,6 @@ static enum ConfigSource { static char btif_config_time_created[TIME_STRING_LENGTH]; static const storage_config_t interface = { checksum_read, checksum_save, config_get_bool, config_get_int, config_get_string, config_get_uint64, config_has_key, config_has_section, config_new, config_new_clone, config_new_empty, config_remove_key, config_remove_section, config_save, config_set_bool, config_set_int, config_set_string, config_set_uint64, }; static const storage_config_t* storage_config_get_interface() { if (bluetooth::shim::is_gd_stack_started_up()) { return bluetooth::shim::storage_config_get_interface(); } else { return &interface; } } static BluetoothKeystoreInterface* get_bluetooth_keystore_interface() { return bluetooth::bluetooth_keystore::getBluetoothKeystoreInterface(); } Loading Loading @@ -268,6 +251,13 @@ static BtifConfigCache btif_config_cache(TEMPORARY_SECTION_CAPACITY); // Module lifecycle functions static future_t* init(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); // TODO (b/158035889) Migrate metrics module to GD read_or_set_metrics_salt(); init_metric_id_allocator(); return future_new_immediate(FUTURE_SUCCESS); } std::unique_lock<std::recursive_mutex> lock(config_lock); std::unique_ptr<config_t> config; Loading Loading @@ -298,7 +288,7 @@ static future_t* init(void) { if (!config) { LOG_ERROR("%s unable to transcode legacy file; creating empty config.", __func__); config = storage_config_get_interface()->config_new_empty(); config = config_new_empty(); btif_config_source = NEW_FILE; file_source = "Empty"; } Loading Loading @@ -357,8 +347,7 @@ error: } static std::unique_ptr<config_t> btif_config_open(const char* filename) { std::unique_ptr<config_t> config = storage_config_get_interface()->config_new(filename); std::unique_ptr<config_t> config = config_new(filename); if (!config) return nullptr; if (!config_has_section(*config, "Adapter")) { Loading @@ -375,6 +364,13 @@ static future_t* shut_down(void) { } static future_t* clean_up(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); // GD storage module cleanup by itself std::unique_lock<std::recursive_mutex> lock(config_lock); MetricIdAllocator::GetInstance().Close(); return future_new_immediate(FUTURE_SUCCESS); } btif_config_flush(); alarm_free(config_timer); Loading @@ -393,20 +389,21 @@ EXPORT_SYMBOL module_t btif_config_module = {.name = BTIF_CONFIG_MODULE, .shut_down = shut_down, .clean_up = clean_up}; bool btif_config_has_section(const char* section) { CHECK(section != NULL); std::unique_lock<std::recursive_mutex> lock(config_lock); return btif_config_cache.HasSection(section); } bool btif_config_exist(const std::string& section, const std::string& key) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::HasProperty(section, key); } std::unique_lock<std::recursive_mutex> lock(config_lock); return btif_config_cache.HasKey(section, key); } bool btif_config_get_int(const std::string& section, const std::string& key, int* value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetInt(section, key, value); } CHECK(value != NULL); std::unique_lock<std::recursive_mutex> lock(config_lock); auto ret = btif_config_cache.GetInt(section, key); Loading @@ -419,6 +416,10 @@ bool btif_config_get_int(const std::string& section, const std::string& key, bool btif_config_set_int(const std::string& section, const std::string& key, int value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::SetInt(section, key, value); } std::unique_lock<std::recursive_mutex> lock(config_lock); btif_config_cache.SetInt(section, key, value); return true; Loading @@ -426,6 +427,10 @@ bool btif_config_set_int(const std::string& section, const std::string& key, bool btif_config_get_uint64(const std::string& section, const std::string& key, uint64_t* value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetUint64(section, key, value); } CHECK(value != NULL); std::unique_lock<std::recursive_mutex> lock(config_lock); auto ret = btif_config_cache.GetUint64(section, key); Loading @@ -438,6 +443,10 @@ bool btif_config_get_uint64(const std::string& section, const std::string& key, bool btif_config_set_uint64(const std::string& section, const std::string& key, uint64_t value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::SetUint64(section, key, value); } std::unique_lock<std::recursive_mutex> lock(config_lock); btif_config_cache.SetUint64(section, key, value); return true; Loading @@ -445,6 +454,11 @@ bool btif_config_set_uint64(const std::string& section, const std::string& key, bool btif_config_get_str(const std::string& section, const std::string& key, char* value, int* size_bytes) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetStr(section, key, value, size_bytes); } CHECK(value != NULL); CHECK(size_bytes != NULL); Loading @@ -460,6 +474,10 @@ bool btif_config_get_str(const std::string& section, const std::string& key, bool btif_config_set_str(const std::string& section, const std::string& key, const std::string& value) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::SetStr(section, key, value); } std::unique_lock<std::recursive_mutex> lock(config_lock); btif_config_cache.SetString(section, key, value); return true; Loading @@ -473,6 +491,11 @@ static bool btif_in_encrypt_key_name_list(std::string key) { bool btif_config_get_bin(const std::string& section, const std::string& key, uint8_t* value, size_t* length) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetBin(section, key, value, length); } CHECK(value != NULL); CHECK(length != NULL); Loading Loading @@ -533,6 +556,10 @@ bool btif_config_get_bin(const std::string& section, const std::string& key, size_t btif_config_get_bin_length(const std::string& section, const std::string& key) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::GetBinLength(section, key); } std::unique_lock<std::recursive_mutex> lock(config_lock); auto value_str = btif_config_cache.GetString(section, key); if (!value_str) return 0; Loading @@ -542,6 +569,11 @@ size_t btif_config_get_bin_length(const std::string& section, bool btif_config_set_bin(const std::string& section, const std::string& key, const uint8_t* value, size_t length) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::SetBin(section, key, value, length); } const char* lookup = "0123456789abcdef"; if (length > 0) CHECK(value != NULL); Loading Loading @@ -579,7 +611,10 @@ bool btif_config_set_bin(const std::string& section, const std::string& key, std::vector<RawAddress> btif_config_get_paired_devices() { std::vector<std::string> names; { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); names = bluetooth::shim::BtifConfigInterface::GetPersistentDevices(); } else { std::unique_lock<std::recursive_mutex> lock(config_lock); names = btif_config_cache.GetPersistentSectionNames(); } Loading @@ -597,6 +632,10 @@ std::vector<RawAddress> btif_config_get_paired_devices() { } bool btif_config_remove(const std::string& section, const std::string& key) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); return bluetooth::shim::BtifConfigInterface::RemoveProperty(section, key); } if (is_niap_mode() && btif_in_encrypt_key_name_list(key)) { get_bluetooth_keystore_interface()->set_encrypt_key_or_remove_key( section + "-" + key, ""); Loading @@ -606,12 +645,22 @@ bool btif_config_remove(const std::string& section, const std::string& key) { } void btif_config_save(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); bluetooth::shim::BtifConfigInterface::Save(); return; } CHECK(config_timer != NULL); alarm_set(config_timer, CONFIG_SETTLE_PERIOD_MS, timer_config_save_cb, NULL); } void btif_config_flush(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); bluetooth::shim::BtifConfigInterface::Flush(); return; } CHECK(config_timer != NULL); alarm_cancel(config_timer); Loading @@ -619,6 +668,12 @@ void btif_config_flush(void) { } bool btif_config_clear(void) { if (bluetooth::shim::is_gd_shim_enabled()) { CHECK(bluetooth::shim::is_gd_stack_started_up()); bluetooth::shim::BtifConfigInterface::Clear(); bluetooth::shim::BtifConfigInterface::Save(); return true; } CHECK(config_timer != NULL); alarm_cancel(config_timer); Loading @@ -626,8 +681,8 @@ bool btif_config_clear(void) { std::unique_lock<std::recursive_mutex> lock(config_lock); btif_config_cache.Clear(); bool ret = storage_config_get_interface()->config_save( btif_config_cache.PersistentSectionCopy(), CONFIG_FILE_PATH); bool ret = config_save(btif_config_cache.PersistentSectionCopy(), CONFIG_FILE_PATH); btif_config_source = RESET; return ret; Loading @@ -646,8 +701,7 @@ static void btif_config_write(UNUSED_ATTR uint16_t event, std::unique_lock<std::recursive_mutex> lock(config_lock); rename(CONFIG_FILE_PATH, CONFIG_BACKUP_PATH); storage_config_get_interface()->config_save( btif_config_cache.PersistentSectionCopy(), CONFIG_FILE_PATH); config_save(btif_config_cache.PersistentSectionCopy(), CONFIG_FILE_PATH); if (btif_is_niap_mode()) { get_bluetooth_keystore_interface()->set_encrypt_key_or_remove_key( CONFIG_FILE_PREFIX, CONFIG_FILE_HASH); Loading Loading @@ -679,7 +733,14 @@ void btif_debug_config_dump(int fd) { break; } auto file_source = btif_config_cache.GetString(INFO_SECTION, FILE_SOURCE); std::optional<std::string> file_source; if (bluetooth::shim::is_gd_stack_started_up()) { CHECK(bluetooth::shim::is_gd_shim_enabled()); file_source = bluetooth::shim::BtifConfigInterface::GetStr(INFO_SECTION, FILE_SOURCE); } else { file_source = btif_config_cache.GetString(INFO_SECTION, FILE_SOURCE); } if (!file_source) { file_source.emplace("Original"); } Loading
system/gd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,7 @@ cc_binary { "android.hardware.bluetooth@1.0", "libhidlbase", "libutils", "libcutils", ], }, host: { Loading
system/gd/facade/grpc_root_server.cc +2 −2 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ #include "shim/dumpsys.h" #include "shim/l2cap.h" #include "stack_manager.h" #include "storage/legacy.h" #include "storage/storage_module.h" namespace bluetooth { namespace facade { Loading Loading @@ -124,7 +124,7 @@ class RootFacadeService : public ::bluetooth::facade::RootFacade::Service { modules.add<::bluetooth::hci::LeAdvertisingManager>(); modules.add<::bluetooth::hci::LeScanningManager>(); modules.add<::bluetooth::security::SecurityModule>(); modules.add<::bluetooth::storage::LegacyModule>(); modules.add<::bluetooth::storage::StorageModule>(); break; default: return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "invalid module under test"); Loading
system/gd/os/Android.bp +2 −0 Original line number Diff line number Diff line filegroup { name: "BluetoothOsSources_android", srcs: [ "android/parameter_provider.cc", "android/system_properties.cc", ], } Loading @@ -15,6 +16,7 @@ filegroup { filegroup { name: "BluetoothOsSources_host", srcs: [ "host/parameter_provider.cc", "host/system_properties.cc", ], } Loading