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

Commit e899136b authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "Add bta sysprop for disable delay"

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

sysprop/bta.sysprop

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


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


#include <cstdint>
#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"
#define PROPERTY_PAGE_TIMEOUT "bluetooth.core.classic.page_timeout"
#endif
#endif


namespace {

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


struct WaitForAllAclConnectionsToDrain {
struct WaitForAllAclConnectionsToDrain {
  uint64_t time_to_wait_in_ms;
  uint64_t time_to_wait_in_ms;
@@ -469,15 +474,15 @@ void bta_dm_disable() {


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