OSDN Git Service

Reduce A2DP/AVDTP related dumpsys output
authorPavlin Radoslavov <pavlin@google.com>
Wed, 23 May 2018 14:40:09 +0000 (07:40 -0700)
committerPavlin Radoslavov <pavlin@google.com>
Wed, 23 May 2018 14:44:10 +0000 (07:44 -0700)
* 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
btif/co/bta_av_co.cc
stack/avdt/avdt_api.cc

index bd4ffa5..e3b74db 100644 (file)
@@ -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);
index 6147744..24cd604 100644 (file)
@@ -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<std::recursive_mutex> 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) {
index 43954b4..903862e 100644 (file)
@@ -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));