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

Commit 78c3072d authored by Sanket Agarwal's avatar Sanket Agarwal Committed by Myles Watson
Browse files

BTA HF_CLIENT: Always reply to +BCS

Phones don't like when we don't reply to +BCS codec-negotiation. We were
having this behavior because not always do we want to accept a
connection request over SCO. Instead of not replying to +BCS (which is
essentially a codec negotiation) we rather refuse the SCO request when
it comes in. This creates other issues such as some phones trying to
connect SCO in an infinite loop but it still keeps interoperability with
other devices such as iPhones and Microsoft phones intact

Bug: b/35469963
Bug: b/35431871
Bug: b/35419773

Test: SCO (Phone Audio) test with iPhone, Microsoft and Nexus phones

Change-Id: I5319edcb4da9d66c6d6b3a49742248c90dee98e6
(cherry picked from commit 39b51f29)
parent 4300644d
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -445,11 +445,6 @@ static void bta_hf_client_handle_bcs(tBTA_HF_CLIENT_CB* client_cb,
                                     uint32_t codec) {
  APPL_TRACE_DEBUG("%s: codec: %u sco listen state: %d", __func__, codec,
                   client_cb->sco_state);

  // Only send acceptance for the codec request if we are ready to accept the
  // SCO connection. sco_state is set to listen when the upper layer calls for
  // audio connection.
  if (client_cb->sco_state == BTA_HF_CLIENT_SCO_LISTEN_ST) {
  if (codec == BTM_SCO_CODEC_CVSD || codec == BTM_SCO_CODEC_MSBC) {
    client_cb->negotiated_codec = codec;
    bta_hf_client_send_at_bcs(client_cb, codec);
@@ -458,7 +453,6 @@ static void bta_hf_client_handle_bcs(tBTA_HF_CLIENT_CB* client_cb,
    bta_hf_client_send_at_bac(client_cb);
  }
}
}

static void bta_hf_client_handle_bsir(tBTA_HF_CLIENT_CB* client_cb,
                                      uint32_t provided) {
+15 −6
Original line number Diff line number Diff line
@@ -330,12 +330,25 @@ static void bta_hf_client_sco_event(tBTA_HF_CLIENT_CB* client_cb,
  switch (client_cb->sco_state) {
    case BTA_HF_CLIENT_SCO_SHUTDOWN_ST:
      switch (event) {
        // For WBS we only listen to SCO requests. Even for outgoing SCO
        // requests we first do a AT+BCC and wait for remote to initiate SCO
        case BTA_HF_CLIENT_SCO_LISTEN_E:
          /* create sco listen connection */
          bta_hf_client_sco_create(client_cb, false);
          client_cb->sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
          break;

        // For non WBS cases and enabling outgoing SCO requests we need to force
        // open a SCO channel
        case BTA_HF_CLIENT_SCO_OPEN_E:
          /* remove listening connection */
          bta_hf_client_sco_remove(client_cb);

          /* create sco connection to peer */
          bta_hf_client_sco_create(client_cb, true);
          client_cb->sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
          break;

        default:
          APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_SHUTDOWN_ST: Ignoring event %d",
                             event);
@@ -345,10 +358,6 @@ static void bta_hf_client_sco_event(tBTA_HF_CLIENT_CB* client_cb,

    case BTA_HF_CLIENT_SCO_LISTEN_ST:
      switch (event) {
        case BTA_HF_CLIENT_SCO_LISTEN_E:
          /* Ignore */
          break;

        case BTA_HF_CLIENT_SCO_OPEN_E:
          /* remove listening connection */
          bta_hf_client_sco_remove(client_cb);
@@ -396,8 +405,8 @@ static void bta_hf_client_sco_event(tBTA_HF_CLIENT_CB* client_cb,

        case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
          /* sco failed; create sco listen connection */
          bta_hf_client_sco_create(client_cb, false);
          client_cb->sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
          // bta_hf_client_sco_create(client_cb, false);
          client_cb->sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
          break;

        default: