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

Commit 248721c1 authored by William Escande's avatar William Escande
Browse files

Add hfp sysprop for hf_client_features

The `define` cannot be override on runtime and some target need to
configure the features (Eg: Wear OS)

Test: atest net_test_bta net_test_btif_hf_client_service
Test: manual | set the property and check new behavior
Bug: 263323082
Change-Id: Ic241364ceed263138797e3c3ad0f139da67e689a
parent 78535b92
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
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
@@ -17,4 +25,3 @@ prop {
    prop_name: "bluetooth.hfp.version.config"
}
+30 −0
Original line number Diff line number Diff line
@@ -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
}
+11 −0
Original line number Diff line number Diff line
@@ -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 */
+1 −1
Original line number Diff line number Diff line
@@ -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;

+2 −9
Original line number Diff line number Diff line
@@ -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;
Loading