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

Commit 9c4d8124 authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Fix HFP SLC failure due to devices not sending the AT+BIND command

Tag: #feature
Bug: 187174892
Test: Manual
Merged-In: I7bb95d30005ddd99a0b272df66f43097f45ab707
Change-Id: I7bb95d30005ddd99a0b272df66f43097f45ab707
parent 448e0369
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "bta/ag/bta_ag_int.h"
#include "bta/include/bta_ag_api.h"
#include "bta/include/utl.h"
#include "device/include/interop.h"
#include "osi/include/compat.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
@@ -820,6 +821,21 @@ static bool bta_ag_parse_biev_response(tBTA_AG_SCB* p_scb, tBTA_AG_VAL* val) {
  return true;
}

/*******************************************************************************
 *
 * Function         bta_ag_bind_timer_cback
 *
 * Description      Handles bind timer callback
 *
 *
 * Returns          void
 *
 ******************************************************************************/
static void bta_ag_bind_timer_cback(void* data) {
  tBTA_AG_SCB* p_scb = (tBTA_AG_SCB*)data;
  bta_ag_svc_conn_open(p_scb, tBTA_AG_DATA::kEmpty);
}

/*******************************************************************************
 *
 * Function         bta_ag_at_hfp_cback
@@ -966,6 +982,13 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
            !((p_scb->features & BTA_AG_FEAT_HF_IND) &&
              (p_scb->peer_features & BTA_AG_PEER_FEAT_HF_IND))) {
          bta_ag_svc_conn_open(p_scb, tBTA_AG_DATA::kEmpty);
        } else {
          if (p_scb->peer_version >= HFP_VERSION_1_7 &&
              interop_match_addr(INTEROP_SLC_SKIP_BIND_COMMAND,
                                 &p_scb->peer_addr)) {
            alarm_set_on_mloop(p_scb->bind_timer, BTA_AG_BIND_TIMEOUT_MS,
                               bta_ag_bind_timer_cback, p_scb);
          }
        }
      } else {
        val.idx = bta_ag_parse_chld(p_scb, val.str);
@@ -1008,6 +1031,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
    case BTA_AG_AT_BIND_EVT:
      APPL_TRACE_DEBUG("%s BTA_AG_AT_BIND_EVT arg_type: %d", __func__,
                       arg_type);
      alarm_cancel(p_scb->bind_timer);
      if (arg_type == BTA_AG_AT_SET) {
        if (bta_ag_parse_bind_set(p_scb, val)) {
          bta_ag_send_ok(p_scb);
+4 −0
Original line number Diff line number Diff line
@@ -59,6 +59,9 @@
  (BTA_AG_FEAT_3WAY | BTA_AG_FEAT_ECNR | BTA_AG_FEAT_VREC | \
   BTA_AG_FEAT_INBAND | BTA_AG_FEAT_VTAG)

/* Timeout for alarm in 2018 toyota camry carkit workaround */
#define BTA_AG_BIND_TIMEOUT_MS 500

enum {
  /* these events are handled by the state machine */
  BTA_AG_API_REGISTER_EVT = BTA_SYS_EVT_START(BTA_ID_AG),
@@ -230,6 +233,7 @@ struct tBTA_AG_SCB {
  uint8_t battchg_ind;      /* CIEV battery charge indicator value */
  uint8_t callheld_ind;     /* CIEV call held indicator value */
  uint32_t bia_masked_out;  /* indicators HF does not want us to send */
  alarm_t* bind_timer;      /* Timer for toyota camry 2018 carkit workaround */
  alarm_t* collision_timer;
  alarm_t* ring_timer;
  alarm_t* codec_negotiation_timer;
+5 −1
Original line number Diff line number Diff line
@@ -111,7 +111,11 @@ typedef enum {

  // Do not send AVDTP SUSPEND while the playback is paused.
  // Some older A2DP Sink devices might not support to pause the streaming.
  INTEROP_DISABLE_AVDTP_SUSPEND
  INTEROP_DISABLE_AVDTP_SUSPEND,

  // Some car kits do not send the AT+BIND command while establishing the SLC
  // which causes an HFP profile connection failure
  INTEROP_SLC_SKIP_BIND_COMMAND
} interop_feature_t;

// Check if a given |addr| matches a known interoperability workaround as
+4 −1
Original line number Diff line number Diff line
@@ -167,7 +167,10 @@ static const interop_addr_entry_t interop_addr_database[] = {
    {{{0x0c, 0xd9, 0xc1, 0, 0, 0}}, 3, INTEROP_AVRCP_1_4_ONLY},

    // KDDI Carkit
    {{{0x44, 0xea, 0xd8, 0, 0, 0}}, 3, INTEROP_DISABLE_SNIFF}
    {{{0x44, 0xea, 0xd8, 0, 0, 0}}, 3, INTEROP_DISABLE_SNIFF},

    // Toyota Camry 2018 Carkit HFP AT+BIND missing
    {{{0x94, 0xb2, 0xcc, 0x30, 0, 0}}, 4, INTEROP_SLC_SKIP_BIND_COMMAND}
};

typedef struct {
+1 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ static const char* interop_feature_string_(const interop_feature_t feature) {
    CASE_RETURN_STR(INTEROP_AVRCP_1_4_ONLY)
    CASE_RETURN_STR(INTEROP_DISABLE_SNIFF)
    CASE_RETURN_STR(INTEROP_DISABLE_AVDTP_SUSPEND)
    CASE_RETURN_STR(INTEROP_SLC_SKIP_BIND_COMMAND);
  }

  return "UNKNOWN";