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

Commit d71ff9e4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "gd: stack: use new start/stop timeout properties" into main

parents 005d3c2f 350054d1
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "module.h"
#include "os/handler.h"
#include "os/log.h"
#include "os/system_properties.h"
#include "os/thread.h"
#include "os/wakelock_manager.h"

@@ -45,7 +46,8 @@ void StackManager::StartUp(ModuleList* modules, Thread* stack_thread) {
  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));
  auto init_status = future.wait_for(std::chrono::milliseconds(
      get_gd_stack_timeout_ms(/* is_start = */ true)));

  WakelockManager::Get().Release();

@@ -71,7 +73,8 @@ void StackManager::ShutDown() {
  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));
  auto stop_status = future.wait_for(std::chrono::milliseconds(
      get_gd_stack_timeout_ms(/* is_start = */ false)));

  WakelockManager::Get().Release();
  WakelockManager::Get().CleanUp();
@@ -92,4 +95,11 @@ void StackManager::handle_shut_down(std::promise<void> promise) {
  promise.set_value();
}

std::chrono::milliseconds StackManager::get_gd_stack_timeout_ms(bool is_start) {
  auto gd_timeout = os::GetSystemPropertyUint32(
        is_start ? "bluetooth.gd.start_timeout" : "bluetooth.gd.stop_timeout",
        /* default_value = */ is_start ? 3000 : 5000);
  return std::chrono::milliseconds(gd_timeout);
}

}  // namespace bluetooth
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ class StackManager {

  void handle_start_up(ModuleList* modules, os::Thread* stack_thread, std::promise<void> promise);
  void handle_shut_down(std::promise<void> promise);
  static std::chrono::milliseconds get_gd_stack_timeout_ms(bool is_start);
};

}  // namespace bluetooth