summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sysprop/hfp.sysprop9
-rw-r--r--system/bta/hf_client/bta_hf_client_api.cc30
-rw-r--r--system/bta/include/bta_hf_client_api.h11
-rw-r--r--system/bta/test/bta_hf_client_add_record_test.cc2
-rw-r--r--system/btif/src/btif_hf_client.cc11
-rw-r--r--system/btif/test/btif_hf_client_service_test.cc20
-rw-r--r--system/test/mock/mock_bta_hf_client_api.cc4
7 files changed, 73 insertions, 14 deletions
diff --git a/sysprop/hfp.sysprop b/sysprop/hfp.sysprop
index d2cf1d6808..a641efa14f 100644
--- a/sysprop/hfp.sysprop
+++ b/sysprop/hfp.sysprop
@@ -2,6 +2,14 @@ module: "android.sysprop.bluetooth.Hfp"
owner: Platform
prop {
+ api_name: "hf_client_features"
+ type: Integer
+ scope: Internal
+ access: Readonly
+ prop_name: "bluetooth.hfp.hf_client_features.config"
+}
+
+prop {
api_name: "hf_services"
type: Integer
scope: Internal
@@ -17,4 +25,3 @@ prop {
prop_name: "bluetooth.hfp.version.config"
}
-
diff --git a/system/bta/hf_client/bta_hf_client_api.cc b/system/bta/hf_client/bta_hf_client_api.cc
index 8295478b17..d64b5ed224 100644
--- a/system/bta/hf_client/bta_hf_client_api.cc
+++ b/system/bta/hf_client/bta_hf_client_api.cc
@@ -28,6 +28,10 @@
#include <cstdint>
+#ifdef OS_ANDROID
+#include <hfp.sysprop.h>
+#endif
+
#include "bt_trace.h" // Legacy trace logging
#include "bta/hf_client/bta_hf_client_int.h"
#include "bta/sys/bta_sys.h"
@@ -204,3 +208,29 @@ void BTA_HfClientSendAT(uint16_t handle, tBTA_HF_CLIENT_AT_CMD_TYPE at,
*
******************************************************************************/
void BTA_HfClientDumpStatistics(int fd) { bta_hf_client_dump_statistics(fd); }
+
+/*******************************************************************************
+ *
+ * function get_default_hf_client_features
+ *
+ * description return the hf_client features.
+ * value can be override via system property
+ *
+ * returns int
+ *
+ ******************************************************************************/
+int get_default_hf_client_features() {
+#define DEFAULT_BTIF_HF_CLIENT_FEATURES \
+ (BTA_HF_CLIENT_FEAT_ECNR | BTA_HF_CLIENT_FEAT_3WAY | \
+ BTA_HF_CLIENT_FEAT_CLI | BTA_HF_CLIENT_FEAT_VREC | BTA_HF_CLIENT_FEAT_VOL | \
+ BTA_HF_CLIENT_FEAT_ECS | BTA_HF_CLIENT_FEAT_ECC | BTA_HF_CLIENT_FEAT_CODEC)
+
+#ifdef OS_ANDROID
+ static const int features =
+ android::sysprop::bluetooth::Hfp::hf_client_features().value_or(
+ DEFAULT_BTIF_HF_CLIENT_FEATURES);
+ return features;
+#else
+ return DEFAULT_BTIF_HF_CLIENT_FEATURES;
+#endif
+}
diff --git a/system/bta/include/bta_hf_client_api.h b/system/bta/include/bta_hf_client_api.h
index 0b01da6ff4..fe0728e1d4 100644
--- a/system/bta/include/bta_hf_client_api.h
+++ b/system/bta/include/bta_hf_client_api.h
@@ -391,4 +391,15 @@ void BTA_HfClientSendAT(uint16_t handle, tBTA_HF_CLIENT_AT_CMD_TYPE at,
******************************************************************************/
void BTA_HfClientDumpStatistics(int fd);
+/*******************************************************************************
+ *
+ * function get_default_hf_client_features
+ *
+ * description return the hf_client features.
+ * value can be override via system property
+ *
+ * returns int
+ *
+ ******************************************************************************/
+int get_default_hf_client_features();
#endif /* BTA_HF_CLIENT_API_H */
diff --git a/system/bta/test/bta_hf_client_add_record_test.cc b/system/bta/test/bta_hf_client_add_record_test.cc
index 5418e39721..4b16cd5221 100644
--- a/system/bta/test/bta_hf_client_add_record_test.cc
+++ b/system/bta/test/bta_hf_client_add_record_test.cc
@@ -58,7 +58,7 @@ class BtaHfClientAddRecordTest : public ::testing::Test {
};
TEST_F(BtaHfClientAddRecordTest, test_hf_client_add_record) {
- tBTA_HF_CLIENT_FEAT features = BTIF_HF_CLIENT_FEATURES;
+ tBTA_HF_CLIENT_FEAT features = get_default_hf_client_features();
uint32_t sdp_handle = 0;
uint8_t scn = 0;
diff --git a/system/btif/src/btif_hf_client.cc b/system/btif/src/btif_hf_client.cc
index fa8d7a6462..42a2c07d57 100644
--- a/system/btif/src/btif_hf_client.cc
+++ b/system/btif/src/btif_hf_client.cc
@@ -68,13 +68,6 @@
#define BTIF_HF_CLIENT_SERVICE_NAME ("Handsfree")
#endif
-#ifndef BTIF_HF_CLIENT_FEATURES
-#define BTIF_HF_CLIENT_FEATURES \
- (BTA_HF_CLIENT_FEAT_ECNR | BTA_HF_CLIENT_FEAT_3WAY | \
- BTA_HF_CLIENT_FEAT_CLI | BTA_HF_CLIENT_FEAT_VREC | BTA_HF_CLIENT_FEAT_VOL | \
- BTA_HF_CLIENT_FEAT_ECS | BTA_HF_CLIENT_FEAT_ECC | BTA_HF_CLIENT_FEAT_CODEC)
-#endif
-
/*******************************************************************************
* Local type definitions
******************************************************************************/
@@ -358,7 +351,7 @@ static bt_status_t connect_audio(const RawAddress* bd_addr) {
CHECK_BTHF_CLIENT_SLC_CONNECTED(cb);
- if ((BTIF_HF_CLIENT_FEATURES & BTA_HF_CLIENT_FEAT_CODEC) &&
+ if ((get_default_hf_client_features() & BTA_HF_CLIENT_FEAT_CODEC) &&
(cb->peer_feat & BTA_HF_CLIENT_PEER_CODEC)) {
BTA_HfClientSendAT(cb->handle, BTA_HF_CLIENT_AT_CMD_BCC, 0, 0, NULL);
} else {
@@ -1085,7 +1078,7 @@ static void bta_hf_client_evt(tBTA_HF_CLIENT_EVT event,
bt_status_t btif_hf_client_execute_service(bool b_enable) {
BTIF_TRACE_EVENT("%s: enable: %d", __func__, b_enable);
- tBTA_HF_CLIENT_FEAT features = BTIF_HF_CLIENT_FEATURES;
+ tBTA_HF_CLIENT_FEAT features = get_default_hf_client_features();
uint16_t hfp_version = get_default_hfp_version();
if (hfp_version >= HFP_VERSION_1_7) {
features |= BTA_HF_CLIENT_FEAT_ESCO_S4;
diff --git a/system/btif/test/btif_hf_client_service_test.cc b/system/btif/test/btif_hf_client_service_test.cc
index 7ff41aee6b..13a86525f8 100644
--- a/system/btif/test/btif_hf_client_service_test.cc
+++ b/system/btif/test/btif_hf_client_service_test.cc
@@ -23,6 +23,22 @@ int get_default_hfp_version() {
#endif
}
+int get_default_hf_client_features() {
+#define DEFAULT_BTIF_HF_CLIENT_FEATURES \
+ (BTA_HF_CLIENT_FEAT_ECNR | BTA_HF_CLIENT_FEAT_3WAY | \
+ BTA_HF_CLIENT_FEAT_CLI | BTA_HF_CLIENT_FEAT_VREC | BTA_HF_CLIENT_FEAT_VOL | \
+ BTA_HF_CLIENT_FEAT_ECS | BTA_HF_CLIENT_FEAT_ECC | BTA_HF_CLIENT_FEAT_CODEC)
+
+#ifdef OS_ANDROID
+ static const int features =
+ android::sysprop::bluetooth::Hfp::hf_client_features().value_or(
+ DEFAULT_BTIF_HF_CLIENT_FEATURES);
+ return features;
+#else
+ return DEFAULT_BTIF_HF_CLIENT_FEATURES;
+#endif
+}
+
uint8_t btif_trace_level = BT_TRACE_LEVEL_WARNING;
tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK* p_cback,
tBTA_HF_CLIENT_FEAT features,
@@ -43,9 +59,7 @@ const char* dump_hf_client_event(uint16_t event) {
class BtifHfClientTest : public ::testing::Test {
protected:
- void SetUp() override {
- gFeatures = BTIF_HF_CLIENT_FEATURES;
- }
+ void SetUp() override { gFeatures = get_default_hf_client_features(); }
void TearDown() override {}
};
diff --git a/system/test/mock/mock_bta_hf_client_api.cc b/system/test/mock/mock_bta_hf_client_api.cc
index c56e774496..6ccba1cd7e 100644
--- a/system/test/mock/mock_bta_hf_client_api.cc
+++ b/system/test/mock/mock_bta_hf_client_api.cc
@@ -54,3 +54,7 @@ void BTA_HfClientSendAT(uint16_t handle, tBTA_HF_CLIENT_AT_CMD_TYPE at,
uint32_t val1, uint32_t val2, const char* str) {
inc_func_call_count(__func__);
}
+int get_default_hf_client_features() {
+ inc_func_call_count(__func__);
+ return 0;
+}