summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yongqin Liu <yongqin.liu@linaro.org> 2023-10-09 16:18:47 +0800
committer William Escande <wescande@google.com> 2023-10-09 17:31:08 -0700
commitfb145b12e79761a22bc7f42e47619654e975c9ee (patch)
treefd78903e974e19d2dd3e87b16110422a59058eb4
parent7efe7bb4ded562649b565dd125d1f7f957b4b465 (diff)
Add ble sysprop for vnd_included
The original BLE_VND_INCLUDED define method cannot be override on runtime and some targets need to disable this feature(Eg: hikey960 board) Test: m . Test: bluetooth enabled by default after boot with the hikey960 board Bug: 302408538 Change-Id: I6da644a22056c8198b0dcd63b98c12fe829d487f Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rw-r--r--sysprop/Android.bp1
-rw-r--r--sysprop/ble.sysprop10
-rw-r--r--system/bta/dm/bta_dm_act.cc24
-rw-r--r--system/internal_include/bt_target.h8
-rw-r--r--system/stack/Android.bp2
-rw-r--r--system/stack/btm/btm_ble_gap.cc33
-rw-r--r--system/stack/btm/btm_ble_int.h1
-rw-r--r--system/test/mock/mock_stack_btm_ble_gap.cc4
8 files changed, 45 insertions, 38 deletions
diff --git a/sysprop/Android.bp b/sysprop/Android.bp
index 08561eafa5..4f848817f2 100644
--- a/sysprop/Android.bp
+++ b/sysprop/Android.bp
@@ -8,6 +8,7 @@ sysprop_library {
srcs: [
"a2dp.sysprop",
"avrcp.sysprop",
+ "ble.sysprop",
"bta.sysprop",
"hfp.sysprop",
"pan.sysprop",
diff --git a/sysprop/ble.sysprop b/sysprop/ble.sysprop
new file mode 100644
index 0000000000..50723897c6
--- /dev/null
+++ b/sysprop/ble.sysprop
@@ -0,0 +1,10 @@
+module: "android.sysprop.bluetooth.Ble"
+owner: Platform
+
+prop {
+ api_name: "vnd_included"
+ type: Boolean
+ scope: Internal
+ access: Readonly
+ prop_name: "bluetooth.ble.vnd.included"
+}
diff --git a/system/bta/dm/bta_dm_act.cc b/system/bta/dm/bta_dm_act.cc
index 2a6f2f924f..4a684fe140 100644
--- a/system/bta/dm/bta_dm_act.cc
+++ b/system/bta/dm/bta_dm_act.cc
@@ -64,9 +64,9 @@
using namespace bluetooth::legacy::stack::sdp;
using bluetooth::Uuid;
+bool ble_vnd_is_included();
void BTIF_dm_disable();
void BTIF_dm_enable();
-void btm_ble_adv_init(void);
void btm_ble_scanner_init(void);
static uint8_t bta_dm_pin_cback(const RawAddress& bd_addr, DEV_CLASS dev_class,
@@ -103,9 +103,7 @@ static void bta_dm_ble_id_key_cback(uint8_t key_type,
tBTM_BLE_LOCAL_KEYS* p_key);
static uint8_t bta_dm_sirk_verifiction_cback(const RawAddress& bd_addr);
tBTM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void);
-#if (BLE_VND_INCLUDED == TRUE)
static void bta_dm_ctrl_features_rd_cmpl_cback(tHCI_STATUS result);
-#endif
#ifndef BTA_DM_BLE_ADV_CHNL_MAP
#define BTA_DM_BLE_ADV_CHNL_MAP \
@@ -353,17 +351,13 @@ void BTA_dm_on_hw_on() {
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);
-#else
- /* If VSC multi adv commands are available, advertising will be initialized
- * when capabilities are read. If they are not available, initialize
- * advertising here */
- btm_ble_adv_init();
- /* Set controller features even if vendor support is not included */
- if (bta_dm_cb.p_sec_cback)
- bta_dm_cb.p_sec_cback(BTA_DM_LE_FEATURES_READ, NULL);
-#endif
+ if (ble_vnd_is_included()) {
+ BTM_BleReadControllerFeatures(bta_dm_ctrl_features_rd_cmpl_cback);
+ } else {
+ /* Set controller features even if vendor support is not included */
+ if (bta_dm_cb.p_sec_cback)
+ bta_dm_cb.p_sec_cback(BTA_DM_LE_FEATURES_READ, NULL);
+ }
btm_ble_scanner_init();
@@ -2738,7 +2732,6 @@ void bta_dm_ble_reset_id(void) {
bluetooth::shim::BTM_BleResetId();
}
-#if (BLE_VND_INCLUDED == TRUE)
/*******************************************************************************
*
* Function bta_dm_ctrl_features_rd_cmpl_cback
@@ -2758,7 +2751,6 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tHCI_STATUS result) {
result);
}
}
-#endif /* BLE_VND_INCLUDED */
/*******************************************************************************
*
diff --git a/system/internal_include/bt_target.h b/system/internal_include/bt_target.h
index 9600187bd7..a6b75c46ef 100644
--- a/system/internal_include/bt_target.h
+++ b/system/internal_include/bt_target.h
@@ -499,14 +499,6 @@
#define LOCAL_BLE_CONTROLLER_ID 1
#endif
-/*
- * Toggles support for vendor specific extensions such as RPA offloading,
- * feature discovery, multi-adv etc.
- */
-#ifndef BLE_VND_INCLUDED
-#define BLE_VND_INCLUDED TRUE
-#endif
-
/* The maximum number of simultaneous applications that can register with LE
* L2CAP. */
#ifndef BLE_MAX_L2CAP_CLIENTS
diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index a1cbc6ce01..8b260ef13c 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -322,6 +322,7 @@ cc_library_static {
"libbt-hci",
"libbt-platform-protos-lite",
"libbt_shim_bridge",
+ "libcom.android.sysprop.bluetooth",
],
shared_libs: [
"libPlatformProperties",
@@ -1567,6 +1568,7 @@ cc_test {
"libbt_shim_ffi",
"libbtdevice",
"libchrome",
+ "libcom.android.sysprop.bluetooth",
"libevent",
"libgmock",
"liblc3",
diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc
index 1c177bab13..3bfebf7a48 100644
--- a/system/stack/btm/btm_ble_gap.cc
+++ b/system/stack/btm/btm_ble_gap.cc
@@ -28,6 +28,10 @@
#include <base/logging.h>
#include <base/strings/string_number_conversions.h>
+#ifdef __ANDROID__
+#include <ble.sysprop.h>
+#endif
+
#include <cstdint>
#include <list>
#include <memory>
@@ -181,9 +185,18 @@ AdvertisingCache cache;
} // namespace
-#if (BLE_VND_INCLUDED == TRUE)
-static tBTM_BLE_CTRL_FEATURES_CBACK* p_ctrl_le_feature_rd_cmpl_cback = NULL;
+bool ble_vnd_is_included() {
+#ifdef __ANDROID__
+ // replace build time config BLE_VND_INCLUDED with runtime
+ static const bool vnd_is_included =
+ android::sysprop::bluetooth::Ble::vnd_included().value_or(true);
+ return vnd_is_included;
+#else
+ return true;
#endif
+}
+
+static tBTM_BLE_CTRL_FEATURES_CBACK* p_ctrl_le_feature_rd_cmpl_cback = NULL;
/**********PAST & PS *******************/
using StartSyncCb = base::Callback<void(
uint8_t /*status*/, uint16_t /*sync_handle*/, uint8_t /*advertising_sid*/,
@@ -609,8 +622,6 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
return status;
}
-#if (BLE_VND_INCLUDED == TRUE)
-
static void btm_get_dynamic_audio_buffer_vsc_cmpl_cback(
tBTM_VSC_CMPL* p_vsc_cmpl_params) {
LOG(INFO) << __func__;
@@ -770,7 +781,6 @@ static void btm_ble_vendor_capability_vsc_cmpl_cback(
if (p_ctrl_le_feature_rd_cmpl_cback != NULL)
p_ctrl_le_feature_rd_cmpl_cback(static_cast<tHCI_STATUS>(status));
}
-#endif /* (BLE_VND_INCLUDED == TRUE) */
/*******************************************************************************
*
@@ -812,8 +822,9 @@ void BTM_BleGetDynamicAudioBuffer(
* Returns void
*
******************************************************************************/
-#if (BLE_VND_INCLUDED == TRUE)
void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK* p_vsc_cback) {
+ if (!ble_vnd_is_included()) return;
+
if (btm_cb.cmn_ble_vsc_cb.values_read) return;
BTM_TRACE_DEBUG("BTM_BleReadControllerFeatures");
@@ -822,10 +833,6 @@ void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK* p_vsc_cback) {
BTM_VendorSpecificCommand(HCI_BLE_VENDOR_CAP, 0, NULL,
btm_ble_vendor_capability_vsc_cmpl_cback);
}
-#else
-void BTM_BleReadControllerFeatures(
- UNUSED_ATTR tBTM_BLE_CTRL_FEATURES_CBACK* p_vsc_cback) {}
-#endif
/*******************************************************************************
*
@@ -3503,9 +3510,9 @@ void btm_ble_init(void) {
alarm_new("btm_ble_addr.refresh_raddr_timer");
btm_ble_pa_sync_cb = {};
sync_timeout_alarm = alarm_new("btm.sync_start_task");
-#if (BLE_VND_INCLUDED == FALSE)
- btm_ble_adv_filter_init();
-#endif
+ if (!ble_vnd_is_included()) {
+ btm_ble_adv_filter_init();
+ }
}
// Clean up btm ble control block
diff --git a/system/stack/btm/btm_ble_int.h b/system/stack/btm/btm_ble_int.h
index 788fad5ccd..361bd366ab 100644
--- a/system/stack/btm/btm_ble_int.h
+++ b/system/stack/btm/btm_ble_int.h
@@ -108,7 +108,6 @@ void btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC& p_dev_rec);
void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec);
void btm_ble_resolving_list_init(uint8_t max_irk_list_sz);
-void btm_ble_adv_init(void);
void btm_ble_multi_adv_cleanup(void);
void btm_ble_batchscan_init(void);
void btm_ble_adv_filter_init(void);
diff --git a/system/test/mock/mock_stack_btm_ble_gap.cc b/system/test/mock/mock_stack_btm_ble_gap.cc
index 79cd29edb9..18a48db7b1 100644
--- a/system/test/mock/mock_stack_btm_ble_gap.cc
+++ b/system/test/mock/mock_stack_btm_ble_gap.cc
@@ -64,6 +64,10 @@ using SyncReportCb = base::Callback<void(
using SyncLostCb = base::Callback<void(uint16_t /*sync_handle*/)>;
using SyncTransferCb = base::Callback<void(uint8_t /*status*/, RawAddress)>;
+bool ble_vnd_is_included() {
+ inc_func_call_count(__func__);
+ return false;
+}
bool BTM_BleConfigPrivacy(bool privacy_mode) {
inc_func_call_count(__func__);
return false;