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

Commit 1b778274 authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Merge "Add bta sysprop for disable delay" am: e899136b

parents ae1f8377 e899136b
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"
}

+3 −0
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ cc_library_static {
    ],
    static_libs: [
        "lib-bt-packets",
        "libcom.android.sysprop.bluetooth",
    ],
    host_supported: true,
    min_sdk_version: "Tiramisu"
@@ -303,6 +304,7 @@ cc_test {
        "libbt-common",
        "libbt-protos-lite",
        "libbtcore",
        "libcom.android.sysprop.bluetooth",
        "libflatbuffers-cpp",
        "libgmock",
    ],
@@ -939,6 +941,7 @@ cc_test {
        "libgmock",
        "libbt-common",
        "libbt-protos-lite",
        "libcom.android.sysprop.bluetooth",
        "libosi", // ADDED
    ],
    generated_headers: [
+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>

@@ -172,16 +175,18 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tHCI_STATUS result);
#define PROPERTY_PAGE_TIMEOUT "bluetooth.core.classic.page_timeout"
#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;
@@ -469,15 +474,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
@@ -544,6 +544,7 @@ cc_test {
          "lib-bt-packets",
          "lib-bt-packets-avrcp",
          "lib-bt-packets-base",
          "libcom.android.sysprop.bluetooth",
          "libc++fs",
          "libflatbuffers-cpp",
          "libgmock",
@@ -665,6 +666,7 @@ cc_test {
          "lib-bt-packets",
          "lib-bt-packets-avrcp",
          "lib-bt-packets-base",
          "libcom.android.sysprop.bluetooth",
          "libc++fs",
          "libflatbuffers-cpp",
          "libgmock",
Loading