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

Commit 208e8674 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add flatbuffer module entrypoints" am: 562667ed

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1340173

Change-Id: Ic93bc44250da75940a2d061ef0926ba0f98de748
parents 37f80546 562667ed
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -149,11 +149,14 @@ cc_defaults {
        ":BluetoothStorageSources",
    ],
    generated_headers: [
        "BluetoothGeneratedBundler_h",
        "BluetoothGeneratedPackets_h",
        "BluetoothGeneratedDumpsysData_h",
    ],
    shared_libs: [
        "libchrome",
        "libcrypto",
        "libflatbuffers-cpp",
    ],
    static_libs: [
        "libbluetooth-protos",
@@ -200,6 +203,7 @@ cc_binary {
    ],
    generated_headers: [
        "BluetoothFacadeGeneratedStub_h",
        "BluetoothGeneratedDumpsysData_h",
        "BluetoothGeneratedPackets_h",
        // Needed here to guarantee that generated zip file is created before
        // bluetooth_cert_tests.zip is packaged
@@ -209,9 +213,10 @@ cc_binary {
        "BluetoothFacadeGeneratedStub_cc",
    ],
    static_libs: [
        "libbluetooth_gd",
        "libbluetooth-protos",
        "breakpad_client",
        "libbluetooth-protos",
        "libbluetooth_gd",
        "libflatbuffers-cpp",
    ],
    shared_libs: [
        "libbacktrace",
@@ -286,13 +291,15 @@ cc_test {
        ":BluetoothStorageTestSources",
    ],
    generated_headers: [
        "BluetoothGeneratedDumpsysData_h",
        "BluetoothGeneratedPackets_h",
    ],
    static_libs: [
        "libbluetooth-protos",
        "libbluetooth_gd",
        "libgmock",
        "libc++fs",
        "libflatbuffers-cpp",
        "libgmock",
    ],
    shared_libs: [
        "libchrome",
@@ -340,10 +347,12 @@ cc_defaults {
    ],
    host_supported: true,
    generated_headers: [
        "BluetoothGeneratedDumpsysData_h",
        "BluetoothGeneratedPackets_h",
    ],
    shared_libs: [
        "libcrypto",
        "libflatbuffers-cpp",
    ],
    cflags: [
        "-DFUZZ_TARGET",
@@ -428,6 +437,20 @@ genrule {
    ],
}

genrule {
    name: "BluetoothGeneratedDumpsysData_h",
    tools: [
        "flatc",
    ],
    cmd: "$(location flatc) -I packages/modules/Bluetooth/system/gd -o $(genDir) --cpp $(in) ",
    srcs: [
        "dumpsys_data.fbs",
    ],
    out: [
        "dumpsys_data_generated.h",
    ],
}

genrule {
    name: "BluetoothGeneratedPackets_python3_cc",
    tools: [
+0 −1
Original line number Diff line number Diff line
@@ -74,4 +74,3 @@ cc_test {
        "test.bfbs",
    ],
}
+11 −0
Original line number Diff line number Diff line
// Top level module dumpsys data schema

namespace bluetooth;

attribute "privacy";

table DumpsysData {
    title:string;
}

root_type DumpsysData;
+10 −0
Original line number Diff line number Diff line
@@ -35,6 +35,11 @@ Handler* Module::GetHandler() const {
  return handler_;
}

DumpsysDataFinisher EmptyDumpsysDataFinisher = [](DumpsysDataBuilder* dumpsys_data_builder) {};
DumpsysDataFinisher Module::GetTable(flatbuffers::FlatBufferBuilder* builder) const {
  return EmptyDumpsysDataFinisher;
}

const ModuleRegistry* Module::GetModuleRegistry() const {
  return registry_;
}
@@ -121,4 +126,9 @@ os::Handler* ModuleRegistry::GetModuleHandler(const ModuleFactory* module) const
  return nullptr;
}

void ModuleDumper::DumpState(std::string* output) const {
  // TODO(cmanton)
  *output = std::string("TBD");
}

}  // namespace bluetooth
+10 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#pragma once

#include <flatbuffers/flatbuffers.h>
#include <functional>
#include <future>
#include <map>
@@ -23,6 +24,7 @@
#include <vector>

#include "common/bind.h"
#include "dumpsys_data_generated.h"
#include "os/handler.h"
#include "os/log.h"
#include "os/thread.h"
@@ -60,6 +62,8 @@ public:
  std::vector<const ModuleFactory*> list_;
};

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

// Each leaf node module must have a factory like so:
//
// static const ModuleFactory Factory;
@@ -85,6 +89,9 @@ class Module {
  // Release all resources, you're about to be deleted
  virtual void Stop() = 0;

  // Get relevant state data from the module
  virtual DumpsysDataFinisher GetTable(flatbuffers::FlatBufferBuilder* builder) const;

  virtual std::string ToString() const;

  ::bluetooth::os::Handler* GetHandler() const;
@@ -153,10 +160,11 @@ class ModuleRegistry {

class ModuleDumper {
 public:
  ModuleDumper(ModuleRegistry& module_registry) : module_registry_(module_registry) {}
  ModuleDumper(const ModuleRegistry& module_registry) : module_registry_(module_registry) {}
  void DumpState(std::string* output) const;

 private:
  [[maybe_unused]] ModuleRegistry& module_registry_;
  [[maybe_unused]] const ModuleRegistry& module_registry_;
};

class TestModuleRegistry : public ModuleRegistry {
Loading