From 8757bc7ab09a3143fd1faff156378b8a5aea7822 Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Wed, 23 May 2018 07:40:09 -0700 Subject: [PATCH] Reduce A2DP/AVDTP related dumpsys output * Don't print control blocks that are not in use * Print some sections only if the runtime trace level is DEBUG(=5) or above * Renamed section "A2DP Codecs and Peers State:" to "A2DP Peers State:" Bug: 80179152 Test: Manual Change-Id: I9fcd7387ed469094132d5be989d4976ce103cfc8 --- bta/av/bta_av_main.cc | 11 +++++++++++ btif/co/bta_av_co.cc | 28 +++++++++++++++++----------- stack/avdt/avdt_api.cc | 8 ++++++++ 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/bta/av/bta_av_main.cc b/bta/av/bta_av_main.cc index bd4ffa5d5..e3b74db4f 100644 --- a/bta/av/bta_av_main.cc +++ b/bta/av/bta_av_main.cc @@ -1370,6 +1370,8 @@ const char* bta_av_evt_code(uint16_t evt_code) { } void bta_debug_av_dump(int fd) { + if (appl_trace_level < BT_TRACE_LEVEL_DEBUG) return; + dprintf(fd, "\nBTA AV State:\n"); dprintf(fd, " State Machine State: %s\n", bta_av_st_code(bta_av_cb.state)); dprintf(fd, " Link signalling timer: %s\n", @@ -1398,6 +1400,9 @@ void bta_debug_av_dump(int fd) { for (size_t i = 0; i < sizeof(bta_av_cb.lcb) / sizeof(bta_av_cb.lcb[0]); i++) { const tBTA_AV_LCB& lcb = bta_av_cb.lcb[i]; + if (lcb.addr.IsEmpty()) { + continue; + } dprintf(fd, "\n Link control block: %zu peer: %s\n", i, lcb.addr.ToString().c_str()); dprintf(fd, " Connected stream handle mask: 0x%x\n", lcb.conn_msk); @@ -1408,12 +1413,18 @@ void bta_debug_av_dump(int fd) { if (p_scb == nullptr) { continue; } + if (p_scb->PeerAddress().IsEmpty()) { + continue; + } dprintf(fd, "\n BTA ID: %zu peer: %s\n", i, p_scb->PeerAddress().ToString().c_str()); dprintf(fd, " SDP discovery started: %s\n", p_scb->sdp_discovery_started ? "true" : "false"); for (size_t j = 0; j < BTAV_A2DP_CODEC_INDEX_MAX; j++) { const tBTA_AV_SEP& sep = p_scb->seps[j]; + if (sep.av_handle == 0) { + continue; + } dprintf(fd, " SEP ID: %zu\n", j); dprintf(fd, " SEP AVDTP handle: %d\n", sep.av_handle); dprintf(fd, " Local SEP type: %d\n", sep.tsep); diff --git a/btif/co/bta_av_co.cc b/btif/co/bta_av_co.cc index 61477446e..24cd6040e 100644 --- a/btif/co/bta_av_co.cc +++ b/btif/co/bta_av_co.cc @@ -1626,16 +1626,32 @@ bool BtaAvCo::ReportSinkCodecState(BtaAvCoPeer* p_peer) { // Nothing to do (for now) return true; } + void BtaAvCo::DebugDump(int fd) { std::lock_guard lock(codec_lock_); - dprintf(fd, "\nA2DP Codecs and Peers State:\n"); + // + // Active peer codec-specific stats + // + if (active_peer_ != nullptr) { + A2dpCodecs* a2dp_codecs = active_peer_->GetCodecs(); + if (a2dp_codecs != nullptr) { + a2dp_codecs->debug_codec_dump(fd); + } + } + + if (appl_trace_level < BT_TRACE_LEVEL_DEBUG) return; + + dprintf(fd, "\nA2DP Peers State:\n"); dprintf(fd, " Active peer: %s\n", (active_peer_ != nullptr) ? active_peer_->addr.ToString().c_str() : "null"); for (size_t i = 0; i < BTA_AV_CO_NUM_ELEMENTS(peers_); i++) { const BtaAvCoPeer& peer = peers_[i]; + if (peer.addr.IsEmpty()) { + continue; + } dprintf(fd, " Peer: %s\n", peer.addr.ToString().c_str()); dprintf(fd, " Number of sinks: %u\n", peer.num_sinks); dprintf(fd, " Number of sources: %u\n", peer.num_sources); @@ -1652,16 +1668,6 @@ void BtaAvCo::DebugDump(int fd) { dprintf(fd, " UUID to connect: 0x%x\n", peer.uuid_to_connect); dprintf(fd, " BTA AV handle: %u\n", peer.BtaAvHandle()); } - - // - // Active peer codec-specific stats - // - if (active_peer_ != nullptr) { - A2dpCodecs* a2dp_codecs = active_peer_->GetCodecs(); - if (a2dp_codecs != nullptr) { - a2dp_codecs->debug_codec_dump(fd); - } - } } bool BtaAvCo::ContentProtectIsScmst(const uint8_t* p_protect_info) { diff --git a/stack/avdt/avdt_api.cc b/stack/avdt/avdt_api.cc index 43954b458..903862ea2 100644 --- a/stack/avdt/avdt_api.cc +++ b/stack/avdt/avdt_api.cc @@ -1212,6 +1212,8 @@ uint8_t AVDT_SetTraceLevel(uint8_t new_level) { } void stack_debug_avdtp_api_dump(int fd) { + if (appl_trace_level < BT_TRACE_LEVEL_DEBUG) return; + dprintf(fd, "\nAVDTP Stack State:\n"); dprintf(fd, " AVDTP signalling L2CAP channel MTU: %d\n", avdtp_cb.rcb.ctrl_mtu); @@ -1219,6 +1221,9 @@ void stack_debug_avdtp_api_dump(int fd) { for (size_t i = 0; i < AVDT_NUM_LINKS; i++) { const AvdtpCcb& ccb = avdtp_cb.ccb[i]; + if (ccb.peer_addr.IsEmpty()) { + continue; + } dprintf(fd, "\n Channel control block: %zu peer: %s\n", i, ccb.peer_addr.ToString().c_str()); dprintf(fd, " Allocated: %s\n", ccb.allocated ? "true" : "false"); @@ -1235,6 +1240,9 @@ void stack_debug_avdtp_api_dump(int fd) { for (size_t i = 0; i < AVDT_NUM_SEPS; i++) { const AvdtpScb& scb = ccb.scb[i]; + if (!scb.in_use) { + continue; + } dprintf(fd, "\n Stream control block: %zu\n", i); dprintf(fd, " SEP codec: %s\n", A2DP_CodecName(scb.stream_config.cfg.codec_info)); -- 2.11.0