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

Commit 7894395f authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Don't skip SDP discovery prior to AVDTP connection

This fixes an issue where the default AVDT_VERSION could be incorrectly
assigned to a remote device.

Bug: 74002223
Test: Manual: connect to Kinivo BTC450; power off/on the device to reconnect
Change-Id: I53817e942638d6e962aa5b8b87b7b31998270857
(cherry picked from commit 243661fe202b00b56a34dbdd2d80d9eff4951485)
parent 6ff95b64
Loading
Loading
Loading
Loading
+14 −23
Original line number Diff line number Diff line
@@ -821,18 +821,6 @@ void bta_av_do_disc_a2dp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {

  bta_sys_app_open(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);

  if (p_scb->skip_sdp) {
    tA2DP_Service a2dp_ser;
    a2dp_ser.avdt_version = AVDT_VERSION;
    p_scb->skip_sdp = false;
    p_scb->uuid_int = p_data->api_open.uuid;
    /* only one A2DP find service is active at a time */
    bta_av_cb.handle = p_scb->hndl;
    APPL_TRACE_WARNING("%s: Skip Sdp for incoming A2dp connection", __func__);
    bta_av_a2dp_sdp_cback(true, &a2dp_ser);
    return;
  }

  /* only one A2DP find service is active at a time */
  bta_av_cb.handle = p_scb->hndl;

@@ -847,16 +835,21 @@ void bta_av_do_disc_a2dp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  else if (p_scb->uuid_int == UUID_SERVCLASS_AUDIO_SOURCE)
    sdp_uuid = UUID_SERVCLASS_AUDIO_SINK;

  APPL_TRACE_DEBUG("%s: uuid_int 0x%x, Doing SDP For 0x%x", __func__,
                   p_scb->uuid_int, sdp_uuid);
  if (A2DP_FindService(sdp_uuid, p_scb->peer_addr, &db_params,
                       bta_av_a2dp_sdp_cback) == A2DP_SUCCESS)
    return;

  /* when the code reaches here, either the DB is NULL
   * or A2DP_FindService is not successful */
  APPL_TRACE_DEBUG(
      "%s: Initiate SDP discovery for peer %s : uuid_int=0x%x "
      "sdp_uuid=0x%x",
      __func__, p_scb->peer_addr.ToString().c_str(), p_scb->uuid_int, sdp_uuid);
  tA2DP_STATUS find_service_status = A2DP_FindService(
      sdp_uuid, p_scb->peer_addr, &db_params, bta_av_a2dp_sdp_cback);
  if (find_service_status != A2DP_SUCCESS) {
    APPL_TRACE_ERROR(
        "%s: A2DP_FindService() failed for peer %s uuid_int=0x%x "
        "sdp_uuid=0x%x : status=%d",
        __func__, p_scb->peer_addr.ToString().c_str(), p_scb->uuid_int,
        sdp_uuid, find_service_status);
    bta_av_a2dp_sdp_cback(false, NULL);
  }
}

/*******************************************************************************
 *
@@ -904,7 +897,6 @@ void bta_av_cleanup(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) {

  p_scb->offload_start_pending = false;

  p_scb->skip_sdp = false;
  if (p_scb->deregistering) {
    /* remove stream */
    for (int i = 0; i < BTAV_A2DP_CODEC_INDEX_MAX; i++) {
@@ -2949,7 +2941,6 @@ void bta_av_open_at_inc(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
    tBTA_AV_API_OPEN* p_buf =
        (tBTA_AV_API_OPEN*)osi_malloc(sizeof(tBTA_AV_API_OPEN));
    memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN));
    p_scb->skip_sdp = true;
    bta_sys_sendmsg(p_buf);
  }
}
+0 −1
Original line number Diff line number Diff line
@@ -514,7 +514,6 @@ struct tBTA_AV_SCB {
  bool no_rtp_header; /* true if add no RTP header */
  uint16_t uuid_int; /*intended UUID of Initiator to connect to */
  bool offload_start_pending;
  bool skip_sdp; /* Decides if sdp to be done prior to profile connection */
  bool offload_started;
};

+0 −2
Original line number Diff line number Diff line
@@ -518,7 +518,6 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) {

    p_scb->suspend_sup = true;
    p_scb->recfg_sup = true;
    p_scb->skip_sdp = false;

    avdtp_stream_config.scb_index = p_scb->hdi;
    avdtp_stream_config.p_avdt_ctrl_cback = &bta_av_proc_stream_evt;
@@ -1438,6 +1437,5 @@ void bta_debug_av_dump(int fd) {
            p_scb->no_rtp_header ? "true" : "false");
    dprintf(fd, "    Intended UUID of Initiator to connect to: 0x%x\n",
            p_scb->uuid_int);
    dprintf(fd, "    Skip SDP: %s\n", p_scb->skip_sdp ? "true" : "false");
  }
}