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

Commit b9f7d66c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Implement Bluetooth classic sysprops" am: ac1f9c8a

parents 69ec77f2 ac1f9c8a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#include "osi/include/fixed_queue.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_ble_int.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_sec.h"
@@ -154,6 +155,11 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tHCI_STATUS result);
#define BTA_DM_SWITCH_DELAY_TIMER_MS 500
#endif

/* Sysprop path for page timeout */
#ifndef PROPERTY_PAGE_TIMEOUT
#define PROPERTY_PAGE_TIMEOUT "bluetooth.core.classic.page_timeout"
#endif

namespace {

// Time to wait after receiving shutdown request to delay the actual shutdown
@@ -387,7 +393,8 @@ void BTA_dm_on_hw_on() {
    get_btm_client_interface().security.BTM_SecRegister(&bta_security);
  }

  BTM_WritePageTimeout(p_bta_dm_cfg->page_timeout);
  BTM_WritePageTimeout(osi_property_get_int32(PROPERTY_PAGE_TIMEOUT,
                                              p_bta_dm_cfg->page_timeout));

#if (BLE_VND_INCLUDED == TRUE)
  BTM_BleReadControllerFeatures(bta_dm_ctrl_features_rd_cmpl_cback);
+14 −1
Original line number Diff line number Diff line
@@ -64,7 +64,20 @@ std::string SyspropsModule::ToString() const {
}

void SyspropsModule::parse_config(std::string file_path) {
  const std::list<std::string> supported_sysprops = {"bluetooth.core.gap.le.privacy.enabled"};
  const std::list<std::string> supported_sysprops = {
      // General
      "bluetooth.core.gap.le.privacy.enabled",
      "bluetooth.device.class_of_device",
      // BR/EDR
      "bluetooth.core.classic.page_scan_type",
      "bluetooth.core.classic.page_scan_interval",
      "bluetooth.core.classic.page_scan_window",
      "bluetooth.core.classic.inq_scan_type",
      "bluetooth.core.classic.inq_scan_interval",
      "bluetooth.core.classic.inq_scan_window",
      "bluetooth.core.acl.link_supervision_timeout",
      "bluetooth.core.classic.page_timeout",
  };

  auto config = storage::LegacyConfigFile::FromPath(file_path).Read(kDefaultCapacity);
  if (!config) {
+10 −2
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@
#include "osi/include/allocator.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "osi/include/properties.h"
#include "stack/acl/acl.h"
#include "stack/acl/peer_packet_types.h"
#include "stack/btm/btm_dev.h"
@@ -72,6 +73,11 @@
#include "types/hci_role.h"
#include "types/raw_address.h"

#ifndef PROPERTY_LINK_SUPERVISION_TIMEOUT
#define PROPERTY_LINK_SUPERVISION_TIMEOUT \
  "bluetooth.core.acl.link_supervision_timeout"
#endif

void BTM_update_version_info(const RawAddress& bd_addr,
                             const remote_version_info& remote_version_info);

@@ -1398,7 +1404,8 @@ void StackAclBtmAcl::btm_acl_role_changed(tHCI_STATUS hci_status,
    /* Reload LSTO: link supervision timeout is reset in the LM after a role
     * switch */
    if (new_role == HCI_ROLE_CENTRAL) {
      constexpr uint16_t link_supervision_timeout = 8000;
      uint16_t link_supervision_timeout =
          osi_property_get_int32(PROPERTY_LINK_SUPERVISION_TIMEOUT, 8000);
      BTM_SetLinkSuperTout(bd_addr, link_supervision_timeout);
    }
  } else {
@@ -2532,7 +2539,8 @@ void on_acl_br_edr_connected(const RawAddress& bda, uint16_t handle,
  delayed_role_change_ = nullptr;
  btm_acl_set_paging(false);
  l2c_link_hci_conn_comp(HCI_SUCCESS, handle, bda);
  constexpr uint16_t link_supervision_timeout = 8000;
  uint16_t link_supervision_timeout =
      osi_property_get_int32(PROPERTY_LINK_SUPERVISION_TIMEOUT, 8000);
  BTM_SetLinkSuperTout(bda, link_supervision_timeout);

  tACL_CONN* p_acl = internal_.acl_get_connection_from_handle(handle);
+46 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@

#define LOG_TAG "bluetooth"

#include <base/logging.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@@ -40,6 +41,7 @@
#include "osi/include/allocator.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_ble_int.h"
#include "stack/btm/btm_int_types.h"
#include "stack/include/acl_api.h"
@@ -50,8 +52,6 @@
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"

#include <base/logging.h>

namespace {
constexpr char kBtmLogTag[] = "SCAN";
}
@@ -78,6 +78,30 @@ using bluetooth::Uuid;
#define BTM_INQ_DEBUG FALSE
#endif

#ifndef PROPERTY_PAGE_SCAN_TYPE
#define PROPERTY_PAGE_SCAN_TYPE "bluetooth.core.classic.page_scan_type"
#endif

#ifndef PROPERTY_PAGE_SCAN_INTERVAL
#define PROPERTY_PAGE_SCAN_INTERVAL "bluetooth.core.classic.page_scan_interval"
#endif

#ifndef PROPERTY_PAGE_SCAN_WINDOW
#define PROPERTY_PAGE_SCAN_WINDOW "bluetooth.core.classic.page_scan_window"
#endif

#ifndef PROPERTY_INQ_SCAN_TYPE
#define PROPERTY_INQ_SCAN_TYPE "bluetooth.core.classic.inq_scan_type"
#endif

#ifndef PROPERTY_INQ_SCAN_INTERVAL
#define PROPERTY_INQ_SCAN_INTERVAL "bluetooth.core.classic.inq_scan_interval"
#endif

#ifndef PROPERTY_INQ_SCAN_WINDOW
#define PROPERTY_INQ_SCAN_WINDOW "bluetooth.core.classic.inq_scan_window"
#endif

#define BTIF_DM_DEFAULT_INQ_MAX_DURATION 10

/******************************************************************************/
@@ -228,6 +252,11 @@ tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode) {
    scan_mode |= HCI_INQUIRY_SCAN_ENABLED;
  }

  window =
      osi_property_get_int32(PROPERTY_INQ_SCAN_WINDOW, BTM_DEFAULT_DISC_WINDOW);
  interval = osi_property_get_int32(PROPERTY_INQ_SCAN_INTERVAL,
                                    BTM_DEFAULT_DISC_INTERVAL);

  /* Send down the inquiry scan window and period if changed */
  if ((window != btm_cb.btm_inq_vars.inq_scan_window) ||
      (interval != btm_cb.btm_inq_vars.inq_scan_period)) {
@@ -269,7 +298,12 @@ void BTM_EnableInterlacedInquiryScan() {
  }

  BTM_TRACE_API("BTM_EnableInterlacedInquiryScan");

  uint16_t inq_scan_type =
      osi_property_get_int32(PROPERTY_INQ_SCAN_TYPE, BTM_SCAN_TYPE_INTERLACED);

  if (!controller_get_interface()->supports_interlaced_inquiry_scan() ||
      inq_scan_type != BTM_SCAN_TYPE_INTERLACED ||
      btm_cb.btm_inq_vars.inq_scan_type == BTM_SCAN_TYPE_INTERLACED) {
    return;
  }
@@ -285,7 +319,12 @@ void BTM_EnableInterlacedPageScan() {
  }

  BTM_TRACE_API("BTM_EnableInterlacedPageScan");

  uint16_t page_scan_type =
      osi_property_get_int32(PROPERTY_PAGE_SCAN_TYPE, BTM_SCAN_TYPE_INTERLACED);

  if (!controller_get_interface()->supports_interlaced_inquiry_scan() ||
      page_scan_type != BTM_SCAN_TYPE_INTERLACED ||
      btm_cb.btm_inq_vars.page_scan_type == BTM_SCAN_TYPE_INTERLACED) {
    return;
  }
@@ -384,6 +423,11 @@ tBTM_STATUS BTM_SetConnectability(uint16_t page_mode) {
    scan_mode |= HCI_PAGE_SCAN_ENABLED;
  }

  window = osi_property_get_int32(PROPERTY_PAGE_SCAN_WINDOW,
                                  BTM_DEFAULT_CONN_WINDOW);
  interval = osi_property_get_int32(PROPERTY_PAGE_SCAN_INTERVAL,
                                    BTM_DEFAULT_CONN_INTERVAL);

  if ((window != p_inq->page_scan_window) ||
      (interval != p_inq->page_scan_period)) {
    p_inq->page_scan_window = window;