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

Commit 8703e24d authored by Henri Chataing's avatar Henri Chataing
Browse files

gd/os/wakelock_manager: Rewrite dumpsys using std::format_to

Bug: 331817295
Test: m com.android.btservices
Flag: EXEMPT, no logical change
Change-Id: I3f00f0dad1e049ff2793e6b0102b073dcea64c95
parent ac0fc3f6
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -640,11 +640,9 @@ genrule {
    srcs: [
        "dumpsys_data.fbs",
        "module_unittest.fbs",
        "os/wakelock_manager.fbs",
    ],
    out: [
        "dumpsys_data.bfbs",
        "wakelock_manager.bfbs",
    ],
}

@@ -657,10 +655,8 @@ genrule {
    srcs: [
        "dumpsys_data.fbs",
        "module_unittest.fbs",
        "os/wakelock_manager.fbs",
    ],
    out: [
        "dumpsys_data_generated.h",
        "wakelock_manager_generated.h",
    ],
}
+0 −2
Original line number Diff line number Diff line
@@ -81,14 +81,12 @@ static_library("libbluetooth_gd") {
flatbuffer("BluetoothGeneratedDumpsysDataSchema_h") {
  sources = [
    "dumpsys_data.fbs",
    "os/wakelock_manager.fbs",
  ]
}

bt_flatc_binary_schema("BluetoothGeneratedDumpsysBinarySchema_bfbs") {
  sources = [
    "dumpsys_data.fbs",
    "os/wakelock_manager.fbs",
  ]

  include_dir = "system/gd"
+0 −2
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@


include "module_unittest.fbs";
include "os/wakelock_manager.fbs";

namespace bluetooth;

@@ -18,7 +17,6 @@ attribute "privacy";

table DumpsysData {
    title:string (privacy:"Any");
    wakelock_manager_data:bluetooth.os.WakelockManagerData (privacy:"Any");
    module_unittest_data:bluetooth.ModuleUnitTestData; // private
}

+1 −29
Original line number Diff line number Diff line
@@ -28,35 +28,7 @@ using ::bluetooth::os::WakelockManager;
namespace bluetooth {

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

  flatbuffers::FlatBufferBuilder builder(1024);
  auto title = builder.CreateString(title_);

  auto wakelock_offset = WakelockManager::Get().GetDumpsysData(&builder);

  std::queue<DumpsysDataFinisher> queue;
  for (auto it = module_registry_.start_order_.rbegin(); it != module_registry_.start_order_.rend();
       it++) {
    auto instance = module_registry_.started_modules_.find(*it);
    log::assert_that(instance != module_registry_.started_modules_.end(),
                     "assert failed: instance != module_registry_.started_modules_.end()");
    log::verbose("Starting dumpsys module:{}", instance->second->ToString());
    queue.push(instance->second->GetDumpsysData(&builder));
    log::verbose("Finished dumpsys module:{}", instance->second->ToString());
  }

  DumpsysDataBuilder data_builder(builder);
  data_builder.add_title(title);
  data_builder.add_wakelock_manager_data(wakelock_offset);

  while (!queue.empty()) {
    queue.front()(&data_builder);
    queue.pop();
  }

  builder.Finish(data_builder.Finish());
  *output = std::string(builder.GetBufferPointer(), builder.GetBufferPointer() + builder.GetSize());
  *output = "";
}

}  // namespace bluetooth
+2 −2
Original line number Diff line number Diff line
@@ -32,8 +32,8 @@ public:
  void DumpState(std::string* output, std::ostringstream& oss) const;

private:
  const ModuleRegistry& module_registry_;
  const std::string title_;
  [[maybe_unused]] const ModuleRegistry& module_registry_;
  [[maybe_unused]] const std::string title_;
};

}  // namespace bluetooth
Loading