include "l2cap/classic/l2cap_classic_module.fbs";
include "hci/hci_acl_manager.fbs";
include "module_unittest.fbs";
+include "os/wakelock_manager.fbs";
include "shim/dumpsys.fbs";
namespace bluetooth;
table DumpsysData {
title:string;
init_flags:common.InitFlagsData (privacy:"Any");
+ wakelock_manager_data:bluetooth.os.WakelockManagerData (privacy:"Any");
shim_dumpsys_data:bluetooth.shim.DumpsysModuleData (privacy:"Any");
l2cap_classic_dumpsys_data:bluetooth.l2cap.classic.L2capClassicModuleData (privacy:"Any");
hci_acl_manager_dumpsys_data:bluetooth.hci.AclManagerData (privacy:"Any");
#include "module.h"
#include "common/init_flags.h"
#include "dumpsys/init_flags.h"
+#include "os/wakelock_manager.h"
using ::bluetooth::os::Handler;
using ::bluetooth::os::Thread;
+using ::bluetooth::os::WakelockManager;
namespace bluetooth {
auto title = builder.CreateString(title_);
auto init_flags_offset = dumpsys::InitFlags::Dump(&builder);
+ 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++) {
DumpsysDataBuilder data_builder(builder);
data_builder.add_title(title);
data_builder.add_init_flags(init_flags_offset);
+ data_builder.add_wakelock_manager_data(wakelock_offset);
while (!queue.empty()) {
queue.front()(&data_builder);
#include "os/internal/wakelock_native.h"
#include "os/log.h"
-#include "wakelock_manager_generated.h"
namespace bluetooth {
namespace os {
return (ts.tv_sec * 1000LL) + (ts.tv_nsec / 1000000LL);
}
-const std::string WakelockManager::kBtWakelockId = "bluetooth_timer";
+const std::string WakelockManager::kBtWakelockId = "bluetooth_gd_timer";
// Wakelock statistics for the "bluetooth_timer"
struct WakelockManager::Stats {
total_acquired_interval_ms += delta_ms;
}
- void GetDumpsysData(flatbuffers::FlatBufferBuilder* fb_builder, bool is_native) const {
+ flatbuffers::Offset<WakelockManagerData> GetDumpsysData(
+ flatbuffers::FlatBufferBuilder* fb_builder, bool is_native) const {
const uint64_t just_now_ms = now_ms();
// Compute the last acquired interval if the wakelock is still acquired
uint64_t delta_ms = 0;
builder.add_avg_interval_millis(avg_interval_ms);
builder.add_total_interval_millis(total_interval_ms);
builder.add_total_time_since_reset_millis(just_now_ms - last_reset_timestamp_ms);
+ return builder.Finish();
}
};
initialized_ = false;
}
-void WakelockManager::GetDumpsysData(flatbuffers::FlatBufferBuilder* fb_builder) {
+flatbuffers::Offset<WakelockManagerData> WakelockManager::GetDumpsysData(flatbuffers::FlatBufferBuilder* fb_builder) {
std::lock_guard<std::recursive_mutex> lock_guard(mutex_);
- pstats_->GetDumpsysData(fb_builder, is_native_);
+ return pstats_->GetDumpsysData(fb_builder, is_native_);
}
WakelockManager::WakelockManager() : pstats_(std::make_unique<Stats>()) {}
{
flatbuffers::FlatBufferBuilder builder(1024);
- WakelockManager::Get().GetDumpsysData(&builder);
- WakelockManagerDataBuilder specific_builder(builder);
- auto offset = specific_builder.Finish();
+ auto offset = WakelockManager::Get().GetDumpsysData(&builder);
FinishWakelockManagerDataBuffer(builder, offset);
auto data = GetWakelockManagerData(builder.GetBufferPointer());
{
flatbuffers::FlatBufferBuilder builder(1024);
- WakelockManager::Get().GetDumpsysData(&builder);
- WakelockManagerDataBuilder specific_builder(builder);
- auto offset = specific_builder.Finish();
+ auto offset = WakelockManager::Get().GetDumpsysData(&builder);
FinishWakelockManagerDataBuffer(builder, offset);
auto data = GetWakelockManagerData(builder.GetBufferPointer());
#include <flatbuffers/flatbuffers.h>
#include "handler.h"
+#include "wakelock_manager_generated.h"
namespace bluetooth {
namespace os {
void CleanUp();
// Dump wakelock-related debug info to a flat buffer defined in wakelock_manager.fbs
- void GetDumpsysData(flatbuffers::FlatBufferBuilder* fb_builder);
+ flatbuffers::Offset<WakelockManagerData> GetDumpsysData(flatbuffers::FlatBufferBuilder* fb_builder);
~WakelockManager();
#include <queue>
#include "common/bind.h"
-#include "hal/hci_hal.h"
#include "module.h"
#include "os/handler.h"
#include "os/log.h"
#include "os/thread.h"
+#include "os/wakelock_manager.h"
using ::bluetooth::os::Handler;
using ::bluetooth::os::Thread;
+using ::bluetooth::os::WakelockManager;
namespace bluetooth {
management_thread_ = new Thread("management_thread", Thread::Priority::NORMAL);
handler_ = new Handler(management_thread_);
+ WakelockManager::Get().Acquire();
+
std::promise<void> promise;
auto future = promise.get_future();
handler_->Post(common::BindOnce(&StackManager::handle_start_up, common::Unretained(this), modules, stack_thread,
std::move(promise)));
auto init_status = future.wait_for(std::chrono::seconds(3));
+
+ WakelockManager::Get().Release();
+
ASSERT_LOG(
init_status == std::future_status::ready,
"Can't start stack, last instance: %s",
}
void StackManager::ShutDown() {
+ WakelockManager::Get().Acquire();
+
std::promise<void> promise;
auto future = promise.get_future();
handler_->Post(common::BindOnce(&StackManager::handle_shut_down, common::Unretained(this), std::move(promise)));
auto stop_status = future.wait_for(std::chrono::seconds(5));
+
+ WakelockManager::Get().Release();
+ WakelockManager::Get().CleanUp();
+
ASSERT_LOG(
stop_status == std::future_status::ready,
"Can't stop stack, last instance: %s",
android: {
shared_libs: [
"android.system.suspend.control-V1-ndk",
+ "android.system.suspend@1.0",
"libaaudio",
"libfmq",
],
"android.hardware.bluetooth@1.0",
"android.hardware.bluetooth@1.1",
"android.system.suspend.control-V1-ndk",
+ "android.system.suspend@1.0",
"libaaudio",
"libbase",
"libbinder_ndk",