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

Commit 1bb1d1f3 authored by Henri Chataing's avatar Henri Chataing
Browse files

system/gd: Inline ModuleStateDumper class into Module class

ModuleStateDumper is not directly inherited from by any class
other than Module

Bug: 333555245
Test: m com.android.btservices
Flag: EXEMPT, no-op change
Change-Id: I06f2e788d02dc2ae67920788e633d51e97aeecfd
parent 1ac3b366
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",
  ]

+13 −0
Original line number Diff line number Diff line
@@ -50,6 +50,19 @@ 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;
}

void Module::GetDumpsysData(int /* fd */) const {}

void Module::GetDumpsysData() const {}

void Module::GetDumpsysData(std::ostringstream& /* oss */) const {}

Module* ModuleRegistry::Get(const ModuleFactory* module) const {
  auto instance = started_modules_.find(module);
  log::assert_that(
+14 −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,11 @@ class Module : protected ModuleStateDumper {
    GetHandler()->CallOn(obj, std::forward<Functor>(functor), std::forward<Args>(args)...);
  }

  virtual DumpsysDataFinisher GetDumpsysData(flatbuffers::FlatBufferBuilder* builder) const;
  virtual void GetDumpsysData() const;
  virtual void GetDumpsysData(int fd) const;
  virtual void GetDumpsysData(std::ostringstream& oss) const;

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

system/gd/module_state_dumper.cc

deleted100644 → 0
+0 −34
Original line number Diff line number Diff line
/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "module_state_dumper.h"

namespace bluetooth {

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

DumpsysDataFinisher ModuleStateDumper::GetDumpsysData(
    flatbuffers::FlatBufferBuilder* /* builder */) const {
  return EmptyDumpsysDataFinisher;
}
void ModuleStateDumper::GetDumpsysData(int /* fd */) const {}

void ModuleStateDumper::GetDumpsysData() const {}

void ModuleStateDumper::GetDumpsysData(std::ostringstream& /* oss */) const {}

}  // namespace bluetooth
Loading