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

Commit 2c01e6e9 authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Add bta sysprop for disable delay am: 3d4baaf5

parents 5e5cdc73 3d4baaf5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ sysprop_library {
  host_supported: true,
  srcs: [
    "avrcp.sysprop",
    "bta.sysprop",
  ],
  property_owner: "Platform",
  api_packages: ["android.sysprop"],

sysprop/bta.sysprop

0 → 100644
+12 −0
Original line number Diff line number Diff line
module: "android.sysprop.bluetooth.Bta"
owner: Platform

prop {
    api_name: "disable_delay"
    type: Integer
    scope: Internal
    access: Readonly
    prop_name: "bluetooth.bta.disable_delay.millis"
}

+2 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ cc_library_static {
    static_libs: [
        "avrcp-target-service",
        "lib-bt-packets",
        "libcom.android.sysprop.bluetooth",
    ],
    generated_headers: [
        "LeAudioSetConfigSchemas_h",
@@ -297,6 +298,7 @@ cc_test {
        "libbt-common",
        "libbt-protos-lite",
        "libbtcore",
        "libcom.android.sysprop.bluetooth",
        "libflatbuffers-cpp",
        "libgmock",
    ],
+14 −9
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@
#define LOG_TAG "bt_bta_dm"

#include <base/logging.h>
#ifdef OS_ANDROID
#include <bta.sysprop.h>
#endif

#include <cstdint>

@@ -157,16 +160,18 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tHCI_STATUS result);
#define BTA_DM_SWITCH_DELAY_TIMER_MS 500
#endif

namespace {

// Time to wait after receiving shutdown request to delay the actual shutdown
// process. This time may be zero which invokes immediate shutdown.
#ifndef BTA_DISABLE_DELAY
constexpr uint64_t kDisableDelayTimerInMs = 0;
static uint64_t get_DisableDelayTimerInMs() {
#ifndef OS_ANDROID
  return 200;
#else
constexpr uint64_t kDisableDelayTimerInMs =
    static_cast<uint64_t>(BTA_DISABLE_DELAY);
  static const uint64_t kDisableDelayTimerInMs =
      android::sysprop::bluetooth::Bta::disable_delay().value_or(200);
  return kDisableDelayTimerInMs;
#endif
}
namespace {

struct WaitForAllAclConnectionsToDrain {
  uint64_t time_to_wait_in_ms;
@@ -450,15 +455,15 @@ void bta_dm_disable() {

  if (BTM_GetNumAclLinks() == 0) {
    // We can shut down faster if there are no ACL links
    switch (kDisableDelayTimerInMs) {
    switch (get_DisableDelayTimerInMs()) {
      case 0:
        LOG_DEBUG("Immediately disabling device manager");
        bta_dm_disable_conn_down_timer_cback(nullptr);
        break;
      default:
        LOG_DEBUG("Set timer to delay disable initiation:%lu ms",
                  static_cast<unsigned long>(kDisableDelayTimerInMs));
        alarm_set_on_mloop(bta_dm_cb.disable_timer, kDisableDelayTimerInMs,
                  static_cast<unsigned long>(get_DisableDelayTimerInMs()));
        alarm_set_on_mloop(bta_dm_cb.disable_timer, get_DisableDelayTimerInMs(),
                           bta_dm_disable_conn_down_timer_cback, nullptr);
    }
  } else {
+2 −0
Original line number Diff line number Diff line
@@ -488,6 +488,7 @@ cc_test {
          "lib-bt-packets",
          "lib-bt-packets-avrcp",
          "lib-bt-packets-base",
          "libcom.android.sysprop.bluetooth",
          "libc++fs",
          "libflatbuffers-cpp",
          "libgmock",
@@ -605,6 +606,7 @@ cc_test {
          "lib-bt-packets",
          "lib-bt-packets-avrcp",
          "lib-bt-packets-base",
          "libcom.android.sysprop.bluetooth",
          "libc++fs",
          "libflatbuffers-cpp",
          "libgmock",
Loading