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

Commit 94c2ceb9 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Include only the Basic Capability for AVDTP GetCapabilities response

AVDTP GetCapabilities request should return only the Basic
Capabilities, as defined in the AVDTP 1.3 spec.
Otherwise, returning a capability such as Delay Reporting would
result in some remote devices droping the AVDTP connection

Also:
 * Print SEP protocol service capabilities per Stream Control
   Block when dumping the state to a bugreport
 * Add extra log messages

Bug: 77668253
Test: Manual: connect with Momentum M2 Headset and examine the
      AVDTP GetCapabilities response.

Change-Id: I34f2e8ff586115a38c3436b2b6300514f65346a9
parent e86055ad
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1675,9 +1675,9 @@ void bta_av_getcap_results(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  memcpy(cfg.codec_info, p_scb->peer_cap.codec_info, AVDT_CODEC_SIZE);
  memcpy(cfg.protect_info, p_scb->peer_cap.protect_info, AVDT_PROTECT_SIZE);

  APPL_TRACE_DEBUG("%s: peer %s handle:%d num_codec:%d", __func__,
  APPL_TRACE_DEBUG("%s: peer %s handle:%d num_codec:%d psc_mask=0x%x", __func__,
                   p_scb->peer_addr.ToString().c_str(), p_scb->hndl,
                   p_scb->peer_cap.num_codec);
                   p_scb->peer_cap.num_codec, p_scb->cfg.psc_mask);
  APPL_TRACE_DEBUG("%s: media type 0x%x, 0x%x", __func__, media_type,
                   p_scb->media_type);
  APPL_TRACE_DEBUG("%s: codec: %s", __func__,
@@ -1710,6 +1710,11 @@ void bta_av_getcap_results(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
    /* use only the services peer supports */
    cfg.psc_mask &= p_scb->peer_cap.psc_mask;
    p_scb->cur_psc_mask = cfg.psc_mask;
    APPL_TRACE_DEBUG(
        "%s: peer %s handle:%d sep_idx:%d sep_info_idx:%d "
        "cur_psc_mask:0x%x",
        __func__, p_scb->peer_addr.ToString().c_str(), p_scb->hndl,
        p_scb->sep_idx, p_scb->sep_info_idx, p_scb->cur_psc_mask);

    if ((uuid_int == UUID_SERVCLASS_AUDIO_SINK) &&
        (p_scb->seps[p_scb->sep_idx].p_app_sink_data_cback != NULL)) {
+27 −16
Original line number Diff line number Diff line
@@ -824,8 +824,8 @@ BtaAvCoPeer* BtaAvCo::FindPeerAndUpdate(tBTA_AV_HNDL bta_av_handle,

  BtaAvCoPeer* p_peer = FindPeer(bta_av_handle);
  if (p_peer == nullptr) {
    APPL_TRACE_ERROR("%s: peer for BTA AV handle 0x%x not found", __func__,
                     bta_av_handle);
    APPL_TRACE_ERROR("%s: peer entry for BTA AV handle 0x%x peer %s not found",
                     __func__, bta_av_handle, peer_address.ToString().c_str());
    return nullptr;
  }

@@ -927,7 +927,8 @@ tA2DP_STATUS BtaAvCo::ProcessSourceGetConfig(
      p_sink->num_protect = *p_num_protect;
      memcpy(p_sink->protect_info, p_protect_info, AVDT_CP_INFO_LEN);
    } else {
      APPL_TRACE_ERROR("%s: no more room for Sink info", __func__);
      APPL_TRACE_ERROR("%s: peer %s : no more room for Sink info", __func__,
                       p_peer->addr.ToString().c_str());
    }
  }

@@ -1040,7 +1041,8 @@ tA2DP_STATUS BtaAvCo::ProcessSinkGetConfig(tBTA_AV_HNDL bta_av_handle,
      p_source->num_protect = *p_num_protect;
      memcpy(p_source->protect_info, p_protect_info, AVDT_CP_INFO_LEN);
    } else {
      APPL_TRACE_ERROR("%s: no more room for Source info", __func__);
      APPL_TRACE_ERROR("%s: peer %s : no more room for Source info", __func__,
                       p_peer->addr.ToString().c_str());
    }
  }

@@ -1463,8 +1465,10 @@ bool BtaAvCo::SetCodecUserConfig(
    p_sink = p_peer->p_sink;
  }
  if (p_sink == nullptr) {
    APPL_TRACE_ERROR("%s: cannot find peer SEP to configure for codec type %d",
                     __func__, codec_user_config.codec_type);
    APPL_TRACE_ERROR(
        "%s: peer %s : cannot find peer SEP to configure for codec type %d",
        __func__, p_peer->addr.ToString().c_str(),
        codec_user_config.codec_type);
    success = false;
    goto done;
  }
@@ -1487,15 +1491,17 @@ bool BtaAvCo::SetCodecUserConfig(

    p_sink = SelectSourceCodec(p_peer);
    if (p_sink == nullptr) {
      APPL_TRACE_ERROR("%s: cannot set up codec for the peer SINK", __func__);
      APPL_TRACE_ERROR("%s: peer %s : cannot set up codec for the peer SINK",
                       __func__, p_peer->addr.ToString().c_str());
      success = false;
      goto done;
    }
    // Don't call BTA_AvReconfig() prior to retrieving all peer's capabilities
    if ((p_peer->num_rx_sinks != p_peer->num_sinks) &&
        (p_peer->num_sup_sinks != BTA_AV_CO_NUM_ELEMENTS(p_peer->sinks))) {
      APPL_TRACE_WARNING("%s: not all peer's capabilities have been retrieved",
                         __func__);
      APPL_TRACE_WARNING(
          "%s: peer %s : not all peer's capabilities have been retrieved",
          __func__, p_peer->addr.ToString().c_str());
      success = false;
      goto done;
    }
@@ -1539,7 +1545,8 @@ bool BtaAvCo::SetCodecAudioConfig(
  // Use the current sink codec
  const BtaAvCoSep* p_sink = p_peer->p_sink;
  if (p_sink == nullptr) {
    APPL_TRACE_ERROR("%s: cannot find peer SEP to configure", __func__);
    APPL_TRACE_ERROR("%s: peer %s : cannot find peer SEP to configure",
                     __func__, p_peer->addr.ToString().c_str());
    return false;
  }

@@ -1563,8 +1570,9 @@ bool BtaAvCo::SetCodecAudioConfig(
    // Don't call BTA_AvReconfig() prior to retrieving all peer's capabilities
    if ((p_peer->num_rx_sinks != p_peer->num_sinks) &&
        (p_peer->num_sup_sinks != BTA_AV_CO_NUM_ELEMENTS(p_peer->sinks))) {
      APPL_TRACE_WARNING("%s: not all peer's capabilities have been retrieved",
                         __func__);
      APPL_TRACE_WARNING(
          "%s: peer %s : not all peer's capabilities have been retrieved",
          __func__, p_peer->addr.ToString().c_str());
    } else {
      p_peer->acceptor = false;
      APPL_TRACE_DEBUG("%s: call BTA_AvReconfig(0x%x)", __func__,
@@ -1971,7 +1979,8 @@ bool BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer,
    // There are no peer SEPs if we didn't do the discovery procedure yet.
    // We have all the information we need from the peer, so we can
    // proceed with the OTA codec configuration.
    APPL_TRACE_ERROR("%s: cannot find peer SEP to configure", __func__);
    APPL_TRACE_ERROR("%s: peer %s : cannot find peer SEP to configure",
                     __func__, p_peer->addr.ToString().c_str());
    return false;
  }

@@ -1980,7 +1989,8 @@ bool BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer,
  if (!p_peer->GetCodecs()->setCodecOtaConfig(
          p_ota_codec_config, &peer_params, result_codec_config, &restart_input,
          &restart_output, &config_updated)) {
    APPL_TRACE_ERROR("%s: cannot set OTA config", __func__);
    APPL_TRACE_ERROR("%s: peer %s : cannot set OTA config", __func__,
                     p_peer->addr.ToString().c_str());
    return false;
  }

@@ -2054,8 +2064,9 @@ tA2DP_STATUS bta_av_co_audio_getconfig(tBTA_AV_HNDL bta_av_handle,
    default:
      break;
  }
  APPL_TRACE_ERROR("%s: Invalid peer UUID: 0x%x for bta_av_handle 0x%x",
                   peer_uuid, bta_av_handle);
  APPL_TRACE_ERROR(
      "%s: peer %s : Invalid peer UUID: 0x%x for bta_av_handle 0x%x",
      peer_address.ToString().c_str(), peer_uuid, bta_av_handle);
  return A2DP_FAIL;
}

+12 −4
Original line number Diff line number Diff line
@@ -1753,6 +1753,10 @@ bool BtifAvStateMachine::StateOpened::ProcessEvent(uint32_t event,
      break;  // Ignore

    case BTIF_AV_START_STREAM_REQ_EVT:
      LOG_INFO(LOG_TAG, "%s: Peer %s : event=%s flags=%s", __PRETTY_FUNCTION__,
               peer_.PeerAddress().ToString().c_str(),
               BtifAvEvent::EventName(event).c_str(),
               peer_.FlagsToString().c_str());
      BTA_AvStart(peer_.BtaHandle());
      peer_.SetFlags(BtifAvPeer::kFlagPendingStart);
      break;
@@ -1918,7 +1922,11 @@ bool BtifAvStateMachine::StateStarted::ProcessEvent(uint32_t event,
      break;  // Ignore

    case BTIF_AV_START_STREAM_REQ_EVT:
      // We were remotely started, just ACK back the local request
      LOG_INFO(LOG_TAG, "%s: Peer %s : event=%s flags=%s", __PRETTY_FUNCTION__,
               peer_.PeerAddress().ToString().c_str(),
               BtifAvEvent::EventName(event).c_str(),
               peer_.FlagsToString().c_str());
      // We were started remotely, just ACK back the local request
      if (peer_.IsSink())
        btif_a2dp_on_started(peer_.PeerAddress(), nullptr, true);
      break;
@@ -2749,7 +2757,7 @@ bool btif_av_stream_ready(void) {
  }

  int state = peer->StateMachine().StateId();
  BTIF_TRACE_DEBUG("%s: Peer %s : state=%d, flags=%s", __func__,
  LOG_INFO(LOG_TAG, "%s: Peer %s : state=%d, flags=%s", __func__,
           peer->PeerAddress().ToString().c_str(), state,
           peer->FlagsToString().c_str());
  // check if we are remotely suspended or stop is pending
+2 −0
Original line number Diff line number Diff line
@@ -1238,6 +1238,8 @@ void stack_debug_avdtp_api_dump(int fd) {
      dprintf(fd, "\n    Stream control block: %zu\n", i);
      dprintf(fd, "      SEP codec: %s\n",
              A2DP_CodecName(scb.stream_config.cfg.codec_info));
      dprintf(fd, "      SEP protocol service capabilities: 0x%x\n",
              scb.stream_config.cfg.psc_mask);
      dprintf(fd, "      SEP type: 0x%x\n", scb.stream_config.tsep);
      dprintf(fd, "      Media type: 0x%x\n", scb.stream_config.media_type);
      dprintf(fd, "      MTU: %d\n", scb.stream_config.mtu);
+3 −0
Original line number Diff line number Diff line
@@ -469,6 +469,9 @@ static void avdt_msg_bld_discover_rsp(uint8_t** p, tAVDT_MSG* p_msg) {
static void avdt_msg_bld_svccap(uint8_t** p, tAVDT_MSG* p_msg) {
  AvdtpSepConfig cfg = *p_msg->svccap.p_cfg;

  // Include only the Basic Capability
  cfg.psc_mask &= AVDT_LEG_PSC;

  avdt_msg_bld_cfg(p, &cfg);
}