Loading system/gd/Android.bp +10 −0 Original line number Diff line number Diff line cc_defaults { name: "gd_defaults", include_dirs: ["external/protobuf/src"], target: { android: { test_config_template: "AndroidTestTemplate.xml", Loading Loading @@ -113,12 +114,18 @@ cc_defaults { srcs: [ ":BluetoothOsSources_linux_generic", ], shared_libs: [ "libprotobuf-cpp-full", ], }, host: { srcs: [ ":BluetoothHalSources_hci_rootcanal", ":BluetoothOsSources_host", ], shared_libs: [ "libprotobuf-cpp-full", ], }, android: { srcs: [ Loading Loading @@ -218,6 +225,7 @@ cc_binary { "libchrome", "libcrypto", "libgrpc++_unsecure", "libprotobuf-cpp-full", ], target: { android: { Loading Loading @@ -296,6 +304,7 @@ cc_test { shared_libs: [ "libchrome", "libcrypto", "libprotobuf-cpp-full", ], sanitize: { address: true, Loading Loading @@ -343,6 +352,7 @@ cc_defaults { ], shared_libs: [ "libcrypto", "libprotobuf-cpp-full", ], cflags: [ "-DFUZZ_TARGET", Loading system/gd/module.cc +22 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include "module.h" #include "bluetooth/dumpmod.pb.h" using ::bluetooth::os::Handler; using ::bluetooth::os::Thread; Loading @@ -26,6 +27,10 @@ constexpr std::chrono::milliseconds kModuleStopTimeout = std::chrono::millisecon ModuleFactory::ModuleFactory(std::function<Module*()> ctor) : ctor_(ctor) { } std::unique_ptr<google::protobuf::Message> Module::DumpState() const { return nullptr; } std::string Module::ToString() const { return "Module"; } Loading Loading @@ -121,4 +126,21 @@ os::Handler* ModuleRegistry::GetModuleHandler(const ModuleFactory* module) const return nullptr; } void ModuleDumper::DumpState() const { Dumpmod dumpmod; for (auto it = module_registry_.start_order_.rbegin(); it != module_registry_.start_order_.rend(); it++) { auto instance = module_registry_.started_modules_.find(*it); ASSERT(instance != module_registry_.started_modules_.end()); std::unique_ptr<google::protobuf::Message> message = instance->second->DumpState(); if (message == nullptr) { continue; } ModuleDumpState dump_state; dump_state.set_name(instance->second->ToString()); dump_state.mutable_data()->PackFrom(*message); dumpmod.mutable_module_dump_states()->insert({dump_state.name(), dump_state}); } } } // namespace bluetooth system/gd/module.h +6 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #pragma once #include <google/protobuf/message.h> #include <functional> #include <future> #include <map> Loading Loading @@ -85,6 +86,9 @@ class Module { // Release all resources, you're about to be deleted virtual void Stop() = 0; // Get relevant state data from the module virtual std::unique_ptr<google::protobuf::Message> DumpState() const; virtual std::string ToString() const; ::bluetooth::os::Handler* GetHandler() const; Loading Loading @@ -154,9 +158,10 @@ class ModuleRegistry { class ModuleDumper { public: ModuleDumper(ModuleRegistry& module_registry) : module_registry_(module_registry) {} void DumpState() const; private: [[maybe_unused]] ModuleRegistry& module_registry_; ModuleRegistry& module_registry_; }; class TestModuleRegistry : public ModuleRegistry { Loading Loading
system/gd/Android.bp +10 −0 Original line number Diff line number Diff line cc_defaults { name: "gd_defaults", include_dirs: ["external/protobuf/src"], target: { android: { test_config_template: "AndroidTestTemplate.xml", Loading Loading @@ -113,12 +114,18 @@ cc_defaults { srcs: [ ":BluetoothOsSources_linux_generic", ], shared_libs: [ "libprotobuf-cpp-full", ], }, host: { srcs: [ ":BluetoothHalSources_hci_rootcanal", ":BluetoothOsSources_host", ], shared_libs: [ "libprotobuf-cpp-full", ], }, android: { srcs: [ Loading Loading @@ -218,6 +225,7 @@ cc_binary { "libchrome", "libcrypto", "libgrpc++_unsecure", "libprotobuf-cpp-full", ], target: { android: { Loading Loading @@ -296,6 +304,7 @@ cc_test { shared_libs: [ "libchrome", "libcrypto", "libprotobuf-cpp-full", ], sanitize: { address: true, Loading Loading @@ -343,6 +352,7 @@ cc_defaults { ], shared_libs: [ "libcrypto", "libprotobuf-cpp-full", ], cflags: [ "-DFUZZ_TARGET", Loading
system/gd/module.cc +22 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include "module.h" #include "bluetooth/dumpmod.pb.h" using ::bluetooth::os::Handler; using ::bluetooth::os::Thread; Loading @@ -26,6 +27,10 @@ constexpr std::chrono::milliseconds kModuleStopTimeout = std::chrono::millisecon ModuleFactory::ModuleFactory(std::function<Module*()> ctor) : ctor_(ctor) { } std::unique_ptr<google::protobuf::Message> Module::DumpState() const { return nullptr; } std::string Module::ToString() const { return "Module"; } Loading Loading @@ -121,4 +126,21 @@ os::Handler* ModuleRegistry::GetModuleHandler(const ModuleFactory* module) const return nullptr; } void ModuleDumper::DumpState() const { Dumpmod dumpmod; for (auto it = module_registry_.start_order_.rbegin(); it != module_registry_.start_order_.rend(); it++) { auto instance = module_registry_.started_modules_.find(*it); ASSERT(instance != module_registry_.started_modules_.end()); std::unique_ptr<google::protobuf::Message> message = instance->second->DumpState(); if (message == nullptr) { continue; } ModuleDumpState dump_state; dump_state.set_name(instance->second->ToString()); dump_state.mutable_data()->PackFrom(*message); dumpmod.mutable_module_dump_states()->insert({dump_state.name(), dump_state}); } } } // namespace bluetooth
system/gd/module.h +6 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #pragma once #include <google/protobuf/message.h> #include <functional> #include <future> #include <map> Loading Loading @@ -85,6 +86,9 @@ class Module { // Release all resources, you're about to be deleted virtual void Stop() = 0; // Get relevant state data from the module virtual std::unique_ptr<google::protobuf::Message> DumpState() const; virtual std::string ToString() const; ::bluetooth::os::Handler* GetHandler() const; Loading Loading @@ -154,9 +158,10 @@ class ModuleRegistry { class ModuleDumper { public: ModuleDumper(ModuleRegistry& module_registry) : module_registry_(module_registry) {} void DumpState() const; private: [[maybe_unused]] ModuleRegistry& module_registry_; ModuleRegistry& module_registry_; }; class TestModuleRegistry : public ModuleRegistry { Loading