From: Jeff DeCew Date: Fri, 4 Dec 2020 18:05:42 +0000 (+0000) Subject: Revert "rusty-gd: move init_flag parsing to rust" X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=126ad36e2b8cd19d41cd60d056e704d7a5042f71;p=android-x86%2Fsystem-bt.git Revert "rusty-gd: move init_flag parsing to rust" Revert submission 1512686 Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master&target=mainline_modules&lkgb=7010703&lkbb=7011903&fkbb=7010786, bug b/174815635 Bug: 174815635 Reverted Changes: I163111bc8:rusty-gd: move init_flag parsing to rust I54cffe93d:rusty-gd: compile into libbluetooth I5207f4df9:rusty-gd: add stack start stubs, define shim libra... Change-Id: I5740575cf7790ed1ab43cc3f521e86f4ef6966e6 --- diff --git a/btif/Android.bp b/btif/Android.bp index 45da4d469..50dc1292d 100755 --- a/btif/Android.bp +++ b/btif/Android.bp @@ -115,6 +115,7 @@ cc_library_static { cflags: [ "-DBUILDCFG", ], + } // btif unit tests for target diff --git a/build/Android.bp b/build/Android.bp index d7643e987..809091f88 100644 --- a/build/Android.bp +++ b/build/Android.bp @@ -97,9 +97,6 @@ fluoride_defaults { enabled: false, }, }, - generated_headers: [ - "libbt_common_bridge_header", - ], } // Enables code coverage for a set of source files. Must be combined with diff --git a/gd/common/init_flags.cc b/gd/common/init_flags.cc index 2788dde24..6a841fbac 100644 --- a/gd/common/init_flags.cc +++ b/gd/common/init_flags.cc @@ -22,10 +22,20 @@ #include "common/strings.h" #include "os/log.h" +#include "src/init_flags.rs.h" namespace bluetooth { namespace common { +bool InitFlags::btaa_hci_log_enabled = false; +bool InitFlags::gd_core_enabled = false; +bool InitFlags::gd_advertising_enabled = false; +bool InitFlags::gd_security_enabled = false; +bool InitFlags::gd_acl_enabled = false; +bool InitFlags::gd_l2cap_enabled = false; +bool InitFlags::gd_hci_enabled = false; +bool InitFlags::gd_controller_enabled = false; +bool InitFlags::gatt_robust_caching_enabled = false; bool InitFlags::logging_debug_enabled_for_all = false; std::unordered_map InitFlags::logging_debug_explicit_tag_settings = {}; @@ -42,16 +52,33 @@ bool ParseBoolFlag(const std::vector& flag_pair, const std::string& } void InitFlags::Load(const char** flags) { + rust::Vec rusted_flags = rust::Vec(); + while (flags != nullptr && *flags != nullptr) { + rusted_flags.push_back(rust::String(*flags)); + flags++; + } + init_flags_load(std::move(rusted_flags)); + SetAll(false); while (flags != nullptr && *flags != nullptr) { std::string flag_element = *flags; auto flag_pair = StringSplit(flag_element, "=", 2); if (flag_pair.size() != 2) { + LOG_ERROR("Bad flag %s, must be in = format", flag_element.c_str()); flags++; continue; } + ParseBoolFlag(flag_pair, "INIT_gd_core", &gd_core_enabled); + ParseBoolFlag(flag_pair, "INIT_gd_advertising", &gd_advertising_enabled); + ParseBoolFlag(flag_pair, "INIT_gd_security", &gd_security_enabled); + ParseBoolFlag(flag_pair, "INIT_gd_acl", &gd_acl_enabled); + ParseBoolFlag(flag_pair, "INIT_gd_l2cap", &gd_l2cap_enabled); + ParseBoolFlag(flag_pair, "INIT_gd_hci", &gd_hci_enabled); + ParseBoolFlag(flag_pair, "INIT_gd_controller", &gd_controller_enabled); + ParseBoolFlag(flag_pair, "INIT_gatt_robust_caching", &gatt_robust_caching_enabled); ParseBoolFlag(flag_pair, "INIT_logging_debug_enabled_for_all", &logging_debug_enabled_for_all); + ParseBoolFlag(flag_pair, "INIT_btaa_hci", &btaa_hci_log_enabled); if ("INIT_logging_debug_enabled_for_tags" == flag_pair[0]) { auto tags = StringSplit(flag_pair[1], ","); for (const auto& tag : tags) { @@ -70,6 +97,23 @@ void InitFlags::Load(const char** flags) { flags++; } + if (gd_core_enabled && !gd_security_enabled) { + gd_security_enabled = true; + } + if (gd_security_enabled && !gd_acl_enabled) { + gd_acl_enabled = true; + } + if (gd_acl_enabled && !gd_controller_enabled) { + gd_controller_enabled = true; + } + if (gd_l2cap_enabled) { + gd_acl_enabled = false; + gd_hci_enabled = true; + } + if (gd_controller_enabled && !gd_hci_enabled) { + gd_hci_enabled = true; + } + std::vector logging_debug_enabled_tags; std::vector logging_debug_disabled_tags; for (const auto& tag_setting : logging_debug_explicit_tag_settings) { @@ -80,21 +124,35 @@ void InitFlags::Load(const char** flags) { } } - rust::Vec rusted_flags = rust::Vec(); - while (flags != nullptr && *flags != nullptr) { - rusted_flags.push_back(rust::String(*flags)); - flags++; - } - init_flags::load(std::move(rusted_flags)); + LOG_INFO( + "Flags loaded: gd_advertising_enabled=%s, gd_security_enabled=%s, gd_acl_enabled=%s, gd_hci_enabled=%s, " + "gd_controller_enabled=%s, gd_core_enabled=%s, logging_debug_enabled_for_all=%s, " + "logging_debug_enabled_tags=%s, logging_debug_disabled_tags=%s, btaa_hci_log_enabled=%s", + ToString(gd_advertising_enabled).c_str(), + ToString(gd_security_enabled).c_str(), + ToString(gd_acl_enabled).c_str(), + ToString(gd_hci_enabled).c_str(), + ToString(gd_controller_enabled).c_str(), + ToString(gd_core_enabled).c_str(), + ToString(logging_debug_enabled_for_all).c_str(), + StringJoin(logging_debug_enabled_tags, ",").c_str(), + StringJoin(logging_debug_disabled_tags, ",").c_str(), + ToString(btaa_hci_log_enabled).c_str()); } void InitFlags::SetAll(bool value) { + gd_core_enabled = value; + gd_advertising_enabled = value; + gd_acl_enabled = value; + gd_security_enabled = value; + gd_controller_enabled = value; + gd_hci_enabled = value; + gatt_robust_caching_enabled = value; logging_debug_enabled_for_all = value; logging_debug_explicit_tag_settings.clear(); } void InitFlags::SetAllForTesting() { - init_flags::set_all_for_testing(); SetAll(true); } diff --git a/gd/common/init_flags.h b/gd/common/init_flags.h index d1dbebc7f..3fdd769f3 100644 --- a/gd/common/init_flags.h +++ b/gd/common/init_flags.h @@ -18,7 +18,6 @@ #include #include -#include "src/init_flags.rs.h" namespace bluetooth { namespace common { @@ -27,6 +26,38 @@ class InitFlags final { public: static void Load(const char** flags); + static bool GdAdvertisingEnabled() { + return gd_advertising_enabled; + } + + static bool GdSecurityEnabled() { + return gd_security_enabled; + } + + static bool GdAclEnabled() { + return gd_acl_enabled; + } + + static bool GdHciEnabled() { + return gd_hci_enabled; + } + + static bool GdControllerEnabled() { + return gd_controller_enabled; + } + + static bool GdL2capEnabled() { + return gd_l2cap_enabled; + } + + static bool GdCoreEnabled() { + return gd_core_enabled; + } + + static bool GattRobustCachingEnabled() { + return gatt_robust_caching_enabled; + } + inline static bool IsDebugLoggingEnabledForTag(const std::string& tag) { auto tag_setting = logging_debug_explicit_tag_settings.find(tag); if (tag_setting != logging_debug_explicit_tag_settings.end()) { @@ -39,13 +70,26 @@ class InitFlags final { return logging_debug_enabled_for_all; } + static bool BtaaHciLogEnabled() { + return btaa_hci_log_enabled; + } + static void SetAllForTesting(); private: static void SetAll(bool value); + static bool gd_advertising_enabled; + static bool gd_security_enabled; + static bool gd_acl_enabled; + static bool gd_hci_enabled; + static bool gd_controller_enabled; + static bool gd_l2cap_enabled; + static bool gd_core_enabled; + static bool gatt_robust_caching_enabled; static bool logging_debug_enabled_for_all; // save both log allow list and block list in the map to save hashing time static std::unordered_map logging_debug_explicit_tag_settings; + static bool btaa_hci_log_enabled; }; } // namespace common diff --git a/gd/common/init_flags_test.cc b/gd/common/init_flags_test.cc index 76babcc81..18a295ba8 100644 --- a/gd/common/init_flags_test.cc +++ b/gd/common/init_flags_test.cc @@ -22,6 +22,56 @@ using bluetooth::common::InitFlags; +TEST(InitFlagsTest, test_load_nullptr) { + InitFlags::Load(nullptr); + ASSERT_FALSE(InitFlags::GdCoreEnabled()); +} + +TEST(InitFlagsTest, test_load_empty) { + const char* input[] = {nullptr}; + InitFlags::Load(input); + ASSERT_FALSE(InitFlags::GdCoreEnabled()); +} + +TEST(InitFlagsTest, test_load_garbage) { + const char* input[] = {"some random non-existent flag", nullptr}; + InitFlags::Load(input); + ASSERT_FALSE(InitFlags::GdCoreEnabled()); +} + +TEST(InitFlagsTest, test_load_core) { + const char* input[] = {"INIT_gd_core=true", nullptr}; + InitFlags::Load(input); + ASSERT_TRUE(InitFlags::GdCoreEnabled()); + ASSERT_TRUE(InitFlags::GdControllerEnabled()); + ASSERT_TRUE(InitFlags::GdHciEnabled()); + ASSERT_FALSE(InitFlags::BtaaHciLogEnabled()); +} + +TEST(InitFlagsTest, test_load_controller) { + const char* input[] = {"INIT_gd_controller=true", nullptr}; + InitFlags::Load(input); + ASSERT_FALSE(InitFlags::GdCoreEnabled()); + ASSERT_TRUE(InitFlags::GdControllerEnabled()); + ASSERT_TRUE(InitFlags::GdHciEnabled()); + ASSERT_FALSE(InitFlags::BtaaHciLogEnabled()); +} + +TEST(InitFlagsTest, test_load_hci) { + const char* input[] = {"INIT_gd_hci=true", nullptr}; + InitFlags::Load(input); + ASSERT_FALSE(InitFlags::GdCoreEnabled()); + ASSERT_FALSE(InitFlags::GdControllerEnabled()); + ASSERT_TRUE(InitFlags::GdHciEnabled()); + ASSERT_FALSE(InitFlags::BtaaHciLogEnabled()); +} + +TEST(InitFlagsTest, test_load_gatt_robust_caching) { + const char* input[] = {"INIT_gatt_robust_caching=true", nullptr}; + InitFlags::Load(input); + ASSERT_TRUE(InitFlags::GattRobustCachingEnabled()); +} + TEST(InitFlagsTest, test_enable_debug_logging_for_all) { const char* input[] = {"INIT_logging_debug_enabled_for_all=true", nullptr}; InitFlags::Load(input); @@ -62,3 +112,12 @@ TEST(InitFlagsTest, test_debug_logging_multiple_flags) { ASSERT_FALSE(InitFlags::IsDebugLoggingEnabledForTag("Foo")); ASSERT_FALSE(InitFlags::IsDebugLoggingEnabledForAll()); } + +TEST(InitFlagsTest, test_load_btaa_hci_log) { + const char* input[] = {"INIT_btaa_hci=true", nullptr}; + InitFlags::Load(input); + ASSERT_TRUE(InitFlags::BtaaHciLogEnabled()); + ASSERT_FALSE(InitFlags::GdCoreEnabled()); + ASSERT_FALSE(InitFlags::GdControllerEnabled()); + ASSERT_FALSE(InitFlags::GdHciEnabled()); +} diff --git a/gd/dumpsys/init_flags.cc b/gd/dumpsys/init_flags.cc index 3c13ad9a1..e45c7acae 100644 --- a/gd/dumpsys/init_flags.cc +++ b/gd/dumpsys/init_flags.cc @@ -23,11 +23,11 @@ flatbuffers::Offset bluetooth::dumpsys::InitFl auto title = fb_builder->CreateString("----- Init Flags -----"); common::InitFlagsDataBuilder builder(*fb_builder); builder.add_title(title); - builder.add_gd_advertising_enabled(bluetooth::common::init_flags::gd_advertising_is_enabled()); - builder.add_gd_security_enabled(bluetooth::common::init_flags::gd_security_is_enabled()); - builder.add_gd_acl_enabled(bluetooth::common::init_flags::gd_acl_is_enabled()); - builder.add_gd_hci_enabled(bluetooth::common::init_flags::gd_hci_is_enabled()); - builder.add_gd_controller_enabled(bluetooth::common::init_flags::gd_controller_is_enabled()); - builder.add_gd_core_enabled(bluetooth::common::init_flags::gd_core_is_enabled()); + builder.add_gd_advertising_enabled(bluetooth::common::InitFlags::GdAdvertisingEnabled()); + builder.add_gd_security_enabled(bluetooth::common::InitFlags::GdSecurityEnabled()); + builder.add_gd_acl_enabled(bluetooth::common::InitFlags::GdAclEnabled()); + builder.add_gd_hci_enabled(bluetooth::common::InitFlags::GdHciEnabled()); + builder.add_gd_controller_enabled(bluetooth::common::InitFlags::GdControllerEnabled()); + builder.add_gd_core_enabled(bluetooth::common::InitFlags::GdCoreEnabled()); return builder.Finish(); } diff --git a/gd/hci/controller.cc b/gd/hci/controller.cc index a9ad0ab88..a8f423c27 100644 --- a/gd/hci/controller.cc +++ b/gd/hci/controller.cc @@ -35,7 +35,7 @@ struct Controller::impl { void Start(hci::HciLayer* hci) { hci_ = hci; Handler* handler = module_.GetHandler(); - if (common::init_flags::gd_acl_is_enabled() || common::init_flags::gd_l2cap_is_enabled()) { + if (common::InitFlags::GdAclEnabled() || common::InitFlags::GdL2capEnabled()) { hci_->RegisterEventHandler( EventCode::NUMBER_OF_COMPLETED_PACKETS, handler->BindOn(this, &Controller::impl::NumberOfCompletedPackets)); } @@ -133,7 +133,7 @@ struct Controller::impl { } void Stop() { - if (bluetooth::common::init_flags::gd_core_is_enabled()) { + if (bluetooth::common::InitFlags::GdCoreEnabled()) { hci_->UnregisterEventHandler(EventCode::NUMBER_OF_COMPLETED_PACKETS); } hci_ = nullptr; diff --git a/gd/hci/hci_layer.cc b/gd/hci/hci_layer.cc index d817d9cd2..6ccaf1434 100644 --- a/gd/hci/hci_layer.cc +++ b/gd/hci/hci_layer.cc @@ -421,7 +421,7 @@ void HciLayer::Start() { RegisterEventHandler(EventCode::COMMAND_COMPLETE, handler->BindOn(impl_, &impl::on_command_complete)); RegisterEventHandler(EventCode::COMMAND_STATUS, handler->BindOn(impl_, &impl::on_command_status)); RegisterLeMetaEventHandler(handler->BindOn(impl_, &impl::on_le_meta_event)); - if (bluetooth::common::init_flags::gd_acl_is_enabled() || bluetooth::common::init_flags::gd_l2cap_is_enabled()) { + if (bluetooth::common::InitFlags::GdAclEnabled() || bluetooth::common::InitFlags::GdL2capEnabled()) { RegisterEventHandler( EventCode::DISCONNECTION_COMPLETE, handler->BindOn(this, &HciLayer::on_disconnection_complete)); RegisterEventHandler( diff --git a/gd/hci/le_address_manager.cc b/gd/hci/le_address_manager.cc index 93604cfc1..4ec388358 100644 --- a/gd/hci/le_address_manager.cc +++ b/gd/hci/le_address_manager.cc @@ -147,7 +147,7 @@ void LeAddressManager::register_client(LeAddressManagerCallback* callback) { } else if ( address_policy_ == AddressPolicy::USE_RESOLVABLE_ADDRESS || address_policy_ == AddressPolicy::USE_NON_RESOLVABLE_ADDRESS) { - if (bluetooth::common::init_flags::gd_acl_is_enabled()) { + if (bluetooth::common::InitFlags::GdAclEnabled()) { if (registered_clients_.size() == 1) { schedule_rotate_random_address(); } diff --git a/gd/rust/common/Android.bp b/gd/rust/common/Android.bp index 2a77c981e..5db37a8c3 100644 --- a/gd/rust/common/Android.bp +++ b/gd/rust/common/Android.bp @@ -1,6 +1,5 @@ -rust_defaults { - name: "libbt_common_defaults", - stem: "libbt_common", +rust_library { + name: "libbt_common", crate_name: "bt_common", srcs: ["src/lib.rs"], edition: "2018", @@ -22,20 +21,34 @@ rust_defaults { ], }, }, - proc_macros: [ - "libpaste", - ], host_supported: true, } -rust_library { - name: "libbt_common", - defaults: ["libbt_common_defaults"], -} - rust_ffi_static { name: "libbt_common_ffi", - defaults: ["libbt_common_defaults"], + stem: "libbt_common", + crate_name: "bt_common", + srcs: ["src/lib.rs"], + edition: "2018", + rustlibs: [ + "libtokio", + "libnix", + "liblog_rust", + "libcxx", + ], + target: { + android: { + rustlibs: [ + "libandroid_logger", + ], + }, + host: { + rustlibs: [ + "libenv_logger", + ], + }, + }, + host_supported: true, } rust_test_host { diff --git a/gd/rust/common/src/init_flags.rs b/gd/rust/common/src/init_flags.rs index b550c34c1..72d8e8783 100644 --- a/gd/rust/common/src/init_flags.rs +++ b/gd/rust/common/src/init_flags.rs @@ -1,124 +1,16 @@ -use log::{error, info}; -use paste::paste; -use std::sync::Mutex; +use log::error; -#[cxx::bridge(namespace = bluetooth::common::init_flags)] +#[cxx::bridge(namespace = bluetooth::common)] mod ffi { extern "Rust" { - fn load(flags: Vec); - fn set_all_for_testing(); - - fn gd_core_is_enabled() -> bool; - fn gd_security_is_enabled() -> bool; - fn gd_advertising_is_enabled() -> bool; - fn gd_acl_is_enabled() -> bool; - fn gd_l2cap_is_enabled() -> bool; - fn gd_hci_is_enabled() -> bool; - fn gd_controller_is_enabled() -> bool; - fn gatt_robust_caching_is_enabled() -> bool; - fn btaa_hci_is_enabled() -> bool; + fn init_flags_load(flags: Vec); } } -macro_rules! init_flags { - (flags: { $($flag:ident),* }, dependencies: { $($parent:ident => $child:ident),* }) => { - #[derive(Default)] - struct InitFlags { - $($flag: bool,)* - } - - pub fn set_all_for_testing() { - *FLAGS.lock().unwrap() = InitFlags { $($flag: true,)* }; - } - - impl InitFlags { - fn parse(flags: Vec) -> Self { - $(let mut $flag = false;)* - - for flag in flags { - let values: Vec<&str> = flag.split("=").collect(); - if values.len() != 2 { - error!("Bad flag {}, must be in = format", flag); - continue; - } - - match values[0] { - $(concat!("INIT_", stringify!($flag)) => $flag = values[1].parse().unwrap_or(false),)* - _ => {} - } - } - - Self { $($flag,)* }.reconcile() - } - - fn reconcile(mut self) -> Self { - // Loop to ensure dependencies can be specified in any order - loop { - let mut any_change = false; - $(if self.$parent && !self.$child { - self.$child = true; - any_change = true; - })* - - if !any_change { - break; - } - } - - // TODO: acl should not be off if l2cap is on, but need to reconcile legacy code - if self.gd_l2cap { - self.gd_acl = false; - self.gd_hci = true; - } - - self - } - - fn log(&self) { - info!(concat!("Flags loaded: ", $(stringify!($flag), "={} ",)*), $(self.$flag,)*); - } - } - - paste! { - $( - pub fn [<$flag _is_enabled>]() -> bool { - FLAGS.lock().unwrap().$flag - } - )* - } - }; -} - -init_flags!( - flags: { - gd_core, - gd_advertising, - gd_security, - gd_acl, - gd_l2cap, - gd_hci, - gd_controller, - gatt_robust_caching, - btaa_hci - }, - dependencies: { - gd_core => gd_security, - gd_security => gd_acl, - gd_acl => gd_controller, - gd_controller => gd_hci - } -); - -lazy_static! { - static ref FLAGS: Mutex = Mutex::new(InitFlags::default()); -} - -fn load(flags: Vec) { +fn init_flags_load(flags: Vec) { crate::init_logging(); - let flags = InitFlags::parse(flags); - flags.log(); - *FLAGS.lock().unwrap() = flags; + for flag in flags { + error!("hello from rust: {}", flag); + } } - - diff --git a/gd/rust/common/src/lib.rs b/gd/rust/common/src/lib.rs index ca1e1cc39..1f38f728e 100644 --- a/gd/rust/common/src/lib.rs +++ b/gd/rust/common/src/lib.rs @@ -1,6 +1,4 @@ //! Bluetooth common library -#[macro_use] -extern crate lazy_static; /// Provides waking timer abstractions pub mod time; diff --git a/hci/src/btsnoop_mem.cc b/hci/src/btsnoop_mem.cc index a13eae583..27303f732 100644 --- a/hci/src/btsnoop_mem.cc +++ b/hci/src/btsnoop_mem.cc @@ -67,7 +67,7 @@ void btsnoop_mem_capture(const BT_HDR* packet, uint64_t timestamp_us) { if (length && data_callback) (*data_callback)(type, data, length, timestamp_us); if (length && attribution_callback && - bluetooth::common::init_flags::btaa_hci_is_enabled()) { + bluetooth::common::InitFlags::BtaaHciLogEnabled()) { (*attribution_callback)(type, data, length, timestamp_us); } } diff --git a/main/shim/le_advertising_manager.cc b/main/shim/le_advertising_manager.cc index 634f2d1ce..5f42e45a3 100644 --- a/main/shim/le_advertising_manager.cc +++ b/main/shim/le_advertising_manager.cc @@ -50,7 +50,7 @@ class BleAdvertiserInterfaceImpl : public BleAdvertiserInterface, // Register callback bluetooth::shim::GetAdvertising()->RegisterAdvertisingCallback(this); - if (!bluetooth::common::init_flags::gd_security_is_enabled()) { + if (!bluetooth::common::InitFlags::GdSecurityEnabled()) { // Set private policy auto address = bluetooth::shim::GetController()->GetMacAddress(); bluetooth::hci::AddressWithType address_with_type( @@ -344,7 +344,7 @@ class BleAdvertiserInterfaceImpl : public BleAdvertiserInterface, config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS; } - if (!bluetooth::common::init_flags::gd_security_is_enabled()) { + if (!bluetooth::common::InitFlags::GdSecurityEnabled()) { // use public address for testing config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS; } diff --git a/main/shim/shim.cc b/main/shim/shim.cc index a8eb413ef..ea280499b 100644 --- a/main/shim/shim.cc +++ b/main/shim/shim.cc @@ -56,36 +56,36 @@ EXPORT_SYMBOL extern const module_t gd_shim_module = { bool bluetooth::shim::is_gd_advertising_enabled() { // TODO enable when module ready - // return bluetooth::common::init_flags::gd_advertising_is_enabled(); + // return bluetooth::common::InitFlags::GdAdvertisingEnabled(); return false; } bool bluetooth::shim::is_gd_security_enabled() { - return bluetooth::common::init_flags::gd_security_is_enabled(); + return bluetooth::common::InitFlags::GdSecurityEnabled(); } bool bluetooth::shim::is_gd_acl_enabled() { - return bluetooth::common::init_flags::gd_acl_is_enabled(); + return bluetooth::common::InitFlags::GdAclEnabled(); } bool bluetooth::shim::is_gd_hci_enabled() { - return bluetooth::common::init_flags::gd_hci_is_enabled(); + return bluetooth::common::InitFlags::GdHciEnabled(); } bool bluetooth::shim::is_gd_controller_enabled() { - return bluetooth::common::init_flags::gd_controller_is_enabled(); + return bluetooth::common::InitFlags::GdControllerEnabled(); } bool bluetooth::shim::is_gd_l2cap_enabled() { - return bluetooth::common::init_flags::gd_l2cap_is_enabled(); + return bluetooth::common::InitFlags::GdL2capEnabled(); } bool bluetooth::shim::is_gd_shim_enabled() { - return bluetooth::common::init_flags::gd_core_is_enabled(); + return bluetooth::common::InitFlags::GdCoreEnabled(); } bool bluetooth::shim::is_any_gd_enabled() { - return bluetooth::common::init_flags::gd_hci_is_enabled(); + return bluetooth::common::InitFlags::GdHciEnabled(); } bool bluetooth::shim::is_gd_stack_started_up() { diff --git a/main/shim/stack.cc b/main/shim/stack.cc index 03876040d..bf92d5106 100644 --- a/main/shim/stack.cc +++ b/main/shim/stack.cc @@ -71,29 +71,29 @@ void Stack::StartEverything() { ASSERT_LOG(!is_running_, "%s Gd stack already running", __func__); LOG_INFO("%s Starting Gd stack", __func__); ModuleList modules; - if (common::init_flags::gd_hci_is_enabled()) { + if (common::InitFlags::GdHciEnabled()) { modules.add(); modules.add(); modules.add(); modules.add(); } - if (common::init_flags::gd_controller_is_enabled()) { + if (common::InitFlags::GdControllerEnabled()) { modules.add(); } - if (common::init_flags::gd_acl_is_enabled()) { + if (common::InitFlags::GdAclEnabled()) { modules.add(); } - if (common::init_flags::gd_l2cap_is_enabled()) { + if (common::InitFlags::GdL2capEnabled()) { modules.add(); modules.add(); } - if (common::init_flags::gd_security_is_enabled()) { + if (common::InitFlags::GdSecurityEnabled()) { modules.add(); } - if (common::init_flags::gd_advertising_is_enabled()) { + if (common::InitFlags::GdAdvertisingEnabled()) { modules.add(); } - if (common::init_flags::gd_core_is_enabled()) { + if (common::InitFlags::GdCoreEnabled()) { modules.add(); modules.add(); modules.add(); @@ -110,24 +110,24 @@ void Stack::StartEverything() { // Make sure the leaf modules are started ASSERT(stack_manager_.GetInstance() != nullptr); ASSERT(stack_manager_.GetInstance() != nullptr); - if (common::init_flags::gd_core_is_enabled()) { + if (common::InitFlags::GdCoreEnabled()) { btm_ = new Btm(stack_handler_, stack_manager_.GetInstance()); } - if (common::init_flags::gd_acl_is_enabled()) { - if (!common::init_flags::gd_core_is_enabled()) { + if (common::InitFlags::GdAclEnabled()) { + if (!common::InitFlags::GdCoreEnabled()) { acl_ = new legacy::Acl(stack_handler_, legacy::GetAclInterface()); } } - if (!common::init_flags::gd_core_is_enabled()) { + if (!common::InitFlags::GdCoreEnabled()) { bluetooth::shim::hci_on_reset_complete(); } - if (common::init_flags::gd_advertising_is_enabled()) { + if (common::InitFlags::GdAdvertisingEnabled()) { bluetooth::shim::init_advertising_manager(); } - if (common::init_flags::gd_l2cap_is_enabled() && - !common::init_flags::gd_core_is_enabled()) { + if (common::InitFlags::GdL2capEnabled() && + !common::InitFlags::GdCoreEnabled()) { L2CA_UseLegacySecurityModule(); } } @@ -147,7 +147,7 @@ void Stack::Start(ModuleList* modules) { void Stack::Stop() { std::lock_guard lock(mutex_); - if (!common::init_flags::gd_core_is_enabled()) { + if (!common::InitFlags::GdCoreEnabled()) { bluetooth::shim::hci_on_shutting_down(); } delete acl_;