Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d6d221a authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Revert "Remove protobuf options from module"

This reverts commit 02e30d5a.

Reason for revert: Breaks aosp-master build as indicated here: https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master&target=run_bluetooth_host_native_tests&lkgb=6595363&lkbb=6595627&fkbb=6595392

Change-Id: I93e7dd80d3f0b153d71f2650cd16bcaf0fcdd89f
parent 02e30d5a
Loading
Loading
Loading
Loading
+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",
@@ -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: [
@@ -218,6 +225,7 @@ cc_binary {
        "libchrome",
        "libcrypto",
        "libgrpc++_unsecure",
        "libprotobuf-cpp-full",
    ],
    target: {
        android: {
@@ -296,6 +304,7 @@ cc_test {
    shared_libs: [
        "libchrome",
        "libcrypto",
        "libprotobuf-cpp-full",
    ],
    sanitize: {
        address: true,
@@ -343,6 +352,7 @@ cc_defaults {
    ],
    shared_libs: [
        "libcrypto",
        "libprotobuf-cpp-full",
    ],
    cflags: [
        "-DFUZZ_TARGET",
+22 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

#include "module.h"
#include "bluetooth/dumpmod.pb.h"

using ::bluetooth::os::Handler;
using ::bluetooth::os::Thread;
@@ -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";
}
@@ -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
+6 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#pragma once

#include <google/protobuf/message.h>
#include <functional>
#include <future>
#include <map>
@@ -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;
@@ -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 {