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

Commit 89c5dd4e authored by Benson Li's avatar Benson Li
Browse files

Modify the HFP version to 1.9 if supported

 - Change the dynamic version to check greater or equal to 1.7
 - Add dynamic version for HFP 1.9
 - Reply the SDP with HFP version 1.9 if remote is supported

Bug: 299045871
Test: manual
Test: m .
Change-Id: I09c26f5c6d30861fe5b7045aed4f9fb024e4f5af
parent 0cfacee8
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -435,7 +435,10 @@ bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
        }
        /* Remote supports 1.7, store it in HFP 1.7 BL file */
        if (bluetooth::common::init_flags::hfp_dynamic_version_is_enabled()) {
          if (p_scb->peer_version == HFP_VERSION_1_7) {
          if (p_scb->peer_version >= HFP_VERSION_1_9) {
            interop_database_add_addr(INTEROP_HFP_1_9_ALLOWLIST,
                                      &p_scb->peer_addr, 3);
          } else if (p_scb->peer_version >= HFP_VERSION_1_7) {
            interop_database_add_addr(INTEROP_HFP_1_7_ALLOWLIST,
                                      &p_scb->peer_addr, 3);
          }
+2 −0
Original line number Diff line number Diff line
@@ -328,6 +328,8 @@ typedef enum {

  INTEROP_HFP_1_7_ALLOWLIST,

  INTEROP_HFP_1_9_ALLOWLIST,

  // Some device may have problem in reconnect flow,
  // need we initiate connection after signalling timeout
  INTEROP_IGNORE_DISC_BEFORE_SIGNALLING_TIMEOUT,
+1 −0
Original line number Diff line number Diff line
@@ -391,6 +391,7 @@ static const char* interop_feature_string_(const interop_feature_t feature) {
    CASE_RETURN_STR(INTEROP_AVRCP_1_3_ONLY)
    CASE_RETURN_STR(INTEROP_DISABLE_ROBUST_CACHING);
    CASE_RETURN_STR(INTEROP_HFP_1_7_ALLOWLIST);
    CASE_RETURN_STR(INTEROP_HFP_1_9_ALLOWLIST);
    CASE_RETURN_STR(INTEROP_IGNORE_DISC_BEFORE_SIGNALLING_TIMEOUT);
  }
  return UNKNOWN_INTEROP_FEATURE;
+11 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include "osi/include/allocator.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_sco_hfp_hal.h"
#include "stack/include/avrc_api.h"
#include "stack/include/avrc_defs.h"
#include "stack/include/bt_hdr.h"
@@ -60,6 +61,7 @@
#define SDP_PROFILE_DESC_LENGTH 8
#define HFP_PROFILE_MINOR_VERSION_6 0x06
#define HFP_PROFILE_MINOR_VERSION_7 0x07
#define HFP_PROFILE_MINOR_VERSION_9 0x09
#define PBAP_GOEP_L2CAP_PSM_LEN 0x06
#define PBAP_SUPP_FEA_LEN 0x08

@@ -171,12 +173,19 @@ bool sdp_dynamic_change_hfp_version(const tSDP_ATTRIBUTE* p_attr,
  bool is_allowlisted_1_7 =
      interop_match_addr_or_name(INTEROP_HFP_1_7_ALLOWLIST, &remote_address,
                                 &btif_storage_get_remote_device_property);
  bool is_allowlisted_1_9 =
      interop_match_addr_or_name(INTEROP_HFP_1_9_ALLOWLIST, &remote_address,
                                 &btif_storage_get_remote_device_property);
  /* For PTS we should update AG's HFP version as 1.7 */
  if (!(is_allowlisted_1_7) &&
  if (!(is_allowlisted_1_7) && !(is_allowlisted_1_9) &&
      !(osi_property_get_bool("vendor.bt.pts.certification", false))) {
    return false;
  }
  if (hfp_hal_interface::get_swb_supported() && is_allowlisted_1_9) {
    p_attr->value_ptr[PROFILE_VERSION_POSITION] = HFP_PROFILE_MINOR_VERSION_9;
  } else {
    p_attr->value_ptr[PROFILE_VERSION_POSITION] = HFP_PROFILE_MINOR_VERSION_7;
  }
  SDP_TRACE_INFO("%s SDP Change HFP Version = %d for %s", __func__,
                 p_attr->value_ptr[PROFILE_VERSION_POSITION],
                 ADDRESS_TO_LOGGABLE_CSTR(remote_address));
+12 −0
Original line number Diff line number Diff line
@@ -589,6 +589,10 @@ TEST_F(StackSdpUtilsTest, check_HFP_version_change_fail) {
              InteropMatchAddrOrName(INTEROP_HFP_1_7_ALLOWLIST, &bdaddr,
                                     &btif_storage_get_remote_device_property))
      .WillOnce(Return(false));
  EXPECT_CALL(*localIopMock,
              InteropMatchAddrOrName(INTEROP_HFP_1_9_ALLOWLIST, &bdaddr,
                                     &btif_storage_get_remote_device_property))
      .WillOnce(Return(false));
  ASSERT_EQ(sdp_dynamic_change_hfp_version(&hfp_attr, bdaddr), false);
}

@@ -601,6 +605,10 @@ TEST_F(StackSdpUtilsTest, check_HFP_version_change_success) {
              InteropMatchAddrOrName(INTEROP_HFP_1_7_ALLOWLIST, &bdaddr,
                                     &btif_storage_get_remote_device_property))
      .WillOnce(Return(true));
  EXPECT_CALL(*localIopMock,
              InteropMatchAddrOrName(INTEROP_HFP_1_9_ALLOWLIST, &bdaddr,
                                     &btif_storage_get_remote_device_property))
      .WillOnce(Return(true));
  ASSERT_EQ(sdp_dynamic_change_hfp_version(&hfp_attr, bdaddr), true);
}

@@ -613,6 +621,10 @@ TEST_F(StackSdpUtilsTest, check_HFP_version_fallback_success) {
              InteropMatchAddrOrName(INTEROP_HFP_1_7_ALLOWLIST, &bdaddr,
                                     &btif_storage_get_remote_device_property))
      .WillOnce(Return(true));
  EXPECT_CALL(*localIopMock,
              InteropMatchAddrOrName(INTEROP_HFP_1_9_ALLOWLIST, &bdaddr,
                                     &btif_storage_get_remote_device_property))
      .WillOnce(Return(true));
  bool is_hfp_fallback = sdp_dynamic_change_hfp_version(&hfp_attr, bdaddr);
  ASSERT_EQ(hfp_attr.value_ptr[PROFILE_VERSION_POSITION],
            HFP_PROFILE_MINOR_VERSION_7);