From 4b4c31de80aa3c518669db4b2cad43b5677a9bdb Mon Sep 17 00:00:00 2001 From: Pavel Zhamaitsiak Date: Fri, 29 Apr 2016 14:54:14 -0700 Subject: [PATCH] Connectivity Metrics service: dump throttling states to dumpsys Print throttling counters per each component and time remaining before counters will be reset. Also adjust estimate of space needed for events serialization. Bug: 28204408 Change-Id: Ib57a24db554645e9f933126da00ef74c23097d1c --- .../connectivity/MetricsLoggerService.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/MetricsLoggerService.java b/services/core/java/com/android/server/connectivity/MetricsLoggerService.java index 5096b35e881c4..6d1c5311fa8ea 100644 --- a/services/core/java/com/android/server/connectivity/MetricsLoggerService.java +++ b/services/core/java/com/android/server/connectivity/MetricsLoggerService.java @@ -144,8 +144,13 @@ public class MetricsLoggerService extends SystemService { boolean dumpSerializedSize = false; boolean dumpEvents = false; + boolean dumpDebugInfo = false; for (String arg : args) { switch (arg) { + case "--debug": + dumpDebugInfo = true; + break; + case "--events": dumpEvents = true; break; @@ -155,6 +160,7 @@ public class MetricsLoggerService extends SystemService { break; case "--all": + dumpDebugInfo = true; dumpEvents = true; dumpSerializedSize = true; break; @@ -163,6 +169,7 @@ public class MetricsLoggerService extends SystemService { synchronized (mEvents) { pw.println("Number of events: " + mEvents.size()); + pw.println("Counter: " + mEventCounter); if (mEvents.size() > 0) { pw.println("Time span: " + DateUtils.formatElapsedTime( @@ -171,16 +178,12 @@ public class MetricsLoggerService extends SystemService { } if (dumpSerializedSize) { - long dataSize = 0; Parcel p = Parcel.obtain(); for (ConnectivityMetricsEvent e : mEvents) { - dataSize += 16; // timestamp and 2 stamps - - p.writeParcelable(e.data, 0); + p.writeParcelable(e, 0); } - dataSize += p.dataSize(); + pw.println("Serialized data size: " + p.dataSize()); p.recycle(); - pw.println("Serialized data size: " + dataSize); } if (dumpEvents) { @@ -192,6 +195,21 @@ public class MetricsLoggerService extends SystemService { } } + if (dumpDebugInfo) { + synchronized (mThrottlingCounters) { + pw.println(); + for (int i = 0; i < ConnectivityMetricsLogger.NUMBER_OF_COMPONENTS; i++) { + if (mThrottlingCounters[i] > 0) { + pw.println("Throttling Counter #" + i + ": " + mThrottlingCounters[i]); + } + } + pw.println("Throttling Time Remaining: " + + DateUtils.formatElapsedTime( + (mThrottlingIntervalBoundaryMillis - System.currentTimeMillis()) + / 1000)); + } + } + synchronized (mPendingIntents) { if (!mPendingIntents.isEmpty()) { pw.println();