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

Commit 0551cac0 authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge changes I031ddff1,I06f2e788 into main

* changes:
  system/gd: Remove unimplemented Module virtual methods
  system/gd: Inline ModuleStateDumper class into Module class
parents 26b6382a ef9c4e97
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -147,7 +147,6 @@ cc_defaults {
        ":BluetoothSyspropsSources",
        "module.cc",
        "module_dumper.cc",
        "module_state_dumper.cc",
        "stack_manager.cc",
    ],
    generated_headers: [
+0 −1
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ static_library("libbluetooth_gd") {
  sources = [
    "module.cc",
    "module_dumper.cc",
    "module_state_dumper.cc",
    "stack_manager.cc",
  ]

+7 −0
Original line number Diff line number Diff line
@@ -50,6 +50,13 @@ Module* Module::GetDependency(const ModuleFactory* module) const {
  log::fatal("Module was not listed as a dependency in ListDependencies");
}

bluetooth::DumpsysDataFinisher EmptyDumpsysDataFinisher =
    [](bluetooth::DumpsysDataBuilder* /* dumpsys_data_builder */) {};

DumpsysDataFinisher Module::GetDumpsysData(flatbuffers::FlatBufferBuilder* /* builder */) const {
  return EmptyDumpsysDataFinisher;
}

Module* ModuleRegistry::Get(const ModuleFactory* module) const {
  auto instance = started_modules_.find(module);
  log::assert_that(
+11 −2
Original line number Diff line number Diff line
@@ -17,17 +17,18 @@
#pragma once

#include <bluetooth/log.h>
#include <flatbuffers/flatbuffers.h>

#include <chrono>
#include <functional>
#include <future>
#include <map>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#include "common/bind.h"
#include "module_state_dumper.h"
#include "os/handler.h"
#include "os/log.h"
#include "os/thread.h"
@@ -70,6 +71,11 @@ public:
  std::vector<const ModuleFactory*> list_;
};

struct DumpsysDataBuilder;
using DumpsysDataFinisher = std::function<void(DumpsysDataBuilder*)>;

extern DumpsysDataFinisher EmptyDumpsysDataFinisher;

// Each leaf node module must have a factory like so:
//
// static const ModuleFactory Factory;
@@ -77,13 +83,14 @@ public:
// which will provide a constructor for the module registry to call.
// The module registry will also use the factory as the identifier
// for that module.
class Module : protected ModuleStateDumper {
class Module {
  friend ModuleDumper;
  friend ModuleRegistry;
  friend TestModuleRegistry;

 public:
  virtual ~Module() = default;

 protected:
  // Populate the provided list with modules that must start before yours
  virtual void ListDependencies(ModuleList* list) const = 0;
@@ -116,6 +123,8 @@ class Module : protected ModuleStateDumper {
    GetHandler()->CallOn(obj, std::forward<Functor>(functor), std::forward<Args>(args)...);
  }

  virtual DumpsysDataFinisher GetDumpsysData(flatbuffers::FlatBufferBuilder* builder) const;

 private:
  Module* GetDependency(const ModuleFactory* module) const;

+1 −4
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ using ::bluetooth::os::WakelockManager;

namespace bluetooth {

void ModuleDumper::DumpState(std::string* output, std::ostringstream& oss) const {
void ModuleDumper::DumpState(std::string* output, std::ostringstream& /*oss*/) const {
  log::assert_that(output != nullptr, "assert failed: output != nullptr");

  flatbuffers::FlatBufferBuilder builder(1024);
@@ -55,9 +55,6 @@ void ModuleDumper::DumpState(std::string* output, std::ostringstream& oss) const
    log::assert_that(
        instance != module_registry_.started_modules_.end(),
        "assert failed: instance != module_registry_.started_modules_.end()");
    instance->second->GetDumpsysData();
    instance->second->GetDumpsysData(fd_);
    instance->second->GetDumpsysData(oss);
    queue.push(instance->second->GetDumpsysData(&builder));
  }

Loading