diff options
author | Glen Kuhne <kuh@google.com> | 2017-08-30 12:58:46 -0700 |
---|---|---|
committer | Glen Kuhne <kuh@google.com> | 2017-09-01 10:17:50 -0700 |
commit | d582c6dfdbb3989b8b761a6cba608a0a3ce35df2 (patch) | |
tree | f13f37d77dc2f3db947c9cf647ff1c4482587c6f | |
parent | f77fca37902331575d779df9754566db471db85f (diff) |
Add WallClockTime to StaEventList dumpsys
Added wall clock timestamps into the StaEventList (previously only used
boot since milli time), to improve readability of the human readable
metrics dump. (Has no effect on the proto dump)
While I was here: Modified the human readable StaEventList dump to print
each event on a single line.
Bug: 63537531
Test: Verified manually with 'adb shell dumpsys wifi'
Change-Id: I3793844a012ec329921f6f457e72b7596ad87f4d
-rw-r--r-- | service/java/com/android/server/wifi/WifiMetrics.java | 76 |
1 files changed, 52 insertions, 24 deletions
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 7dfdb86d3..423a244a4 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -1388,8 +1388,8 @@ public class WifiMetrics { pw.println("mWifiLogProto.numWifiOnFailureDueToWificond=" + mWifiLogProto.numWifiOnFailureDueToWificond); pw.println("StaEventList:"); - for (StaEvent event : mStaEventList) { - pw.println(staEventToString(event)); + for (StaEventWithTime event : mStaEventList) { + pw.println(event); } pw.println("mWifiLogProto.numPasspointProviders=" @@ -1605,6 +1605,14 @@ public class WifiMetrics { mWifiLogProto.softApReturnCode[sapCode].count = mSoftApManagerReturnCodeCounts.valueAt(sapCode); } + + /** + * Convert StaEventList to array of StaEvents + */ + mWifiLogProto.staEventList = new StaEvent[mStaEventList.size()]; + for (int i = 0; i < mStaEventList.size(); i++) { + mWifiLogProto.staEventList[i] = mStaEventList.get(i).staEvent; + } mWifiLogProto.totalSsidsInScanHistogram = makeNumConnectableNetworksBucketArray(mTotalSsidsInScanHistogram); mWifiLogProto.totalBssidsInScanHistogram = @@ -1629,7 +1637,6 @@ public class WifiMetrics { mWifiLogProto.availableSavedPasspointProviderBssidsInScanHistogram = makeNumConnectableNetworksBucketArray( mAvailableSavedPasspointProviderBssidsInScanHistogram); - mWifiLogProto.staEventList = mStaEventList.toArray(mWifiLogProto.staEventList); mWifiLogProto.wifiAwareLog = mWifiAwareMetrics.consolidateProto(); } } @@ -1826,7 +1833,7 @@ public class WifiMetrics { mLastPollRssi = -127; mLastPollFreq = -1; mLastPollLinkSpeed = -1; - mStaEventList.add(staEvent); + mStaEventList.add(new StaEventWithTime(staEvent, mClock.getWallClockMillis())); // Prune StaEventList if it gets too long if (mStaEventList.size() > MAX_STA_EVENTS) mStaEventList.remove(); } @@ -1903,7 +1910,7 @@ public class WifiMetrics { private static String supplicantStateChangesBitmaskToString(int mask) { StringBuilder sb = new StringBuilder(); - sb.append("SUPPLICANT_STATE_CHANGE_EVENTS: {"); + sb.append("supplicantStateChangeEvents: {"); if ((mask & (1 << StaEvent.STATE_DISCONNECTED)) > 0) sb.append(" DISCONNECTED"); if ((mask & (1 << StaEvent.STATE_INTERFACE_DISABLED)) > 0) sb.append(" INTERFACE_DISABLED"); if ((mask & (1 << StaEvent.STATE_INACTIVE)) > 0) sb.append(" INACTIVE"); @@ -1928,58 +1935,56 @@ public class WifiMetrics { public static String staEventToString(StaEvent event) { if (event == null) return "<NULL>"; StringBuilder sb = new StringBuilder(); - Long time = event.startTimeMillis; - sb.append(String.format("%9d ", time.longValue())).append(" "); switch (event.type) { case StaEvent.TYPE_ASSOCIATION_REJECTION_EVENT: - sb.append("ASSOCIATION_REJECTION_EVENT:") + sb.append("ASSOCIATION_REJECTION_EVENT") .append(" timedOut=").append(event.associationTimedOut) .append(" status=").append(event.status).append(":") .append(ISupplicantStaIfaceCallback.StatusCode.toString(event.status)); break; case StaEvent.TYPE_AUTHENTICATION_FAILURE_EVENT: - sb.append("AUTHENTICATION_FAILURE_EVENT: reason=").append(event.authFailureReason) + sb.append("AUTHENTICATION_FAILURE_EVENT reason=").append(event.authFailureReason) .append(":").append(authFailureReasonToString(event.authFailureReason)); break; case StaEvent.TYPE_NETWORK_CONNECTION_EVENT: - sb.append("NETWORK_CONNECTION_EVENT:"); + sb.append("NETWORK_CONNECTION_EVENT"); break; case StaEvent.TYPE_NETWORK_DISCONNECTION_EVENT: - sb.append("NETWORK_DISCONNECTION_EVENT:") + sb.append("NETWORK_DISCONNECTION_EVENT") .append(" local_gen=").append(event.localGen) .append(" reason=").append(event.reason).append(":") .append(ISupplicantStaIfaceCallback.ReasonCode.toString( (event.reason >= 0 ? event.reason : -1 * event.reason))); break; case StaEvent.TYPE_CMD_ASSOCIATED_BSSID: - sb.append("CMD_ASSOCIATED_BSSID:"); + sb.append("CMD_ASSOCIATED_BSSID"); break; case StaEvent.TYPE_CMD_IP_CONFIGURATION_SUCCESSFUL: - sb.append("CMD_IP_CONFIGURATION_SUCCESSFUL:"); + sb.append("CMD_IP_CONFIGURATION_SUCCESSFUL"); break; case StaEvent.TYPE_CMD_IP_CONFIGURATION_LOST: - sb.append("CMD_IP_CONFIGURATION_LOST:"); + sb.append("CMD_IP_CONFIGURATION_LOST"); break; case StaEvent.TYPE_CMD_IP_REACHABILITY_LOST: - sb.append("CMD_IP_REACHABILITY_LOST:"); + sb.append("CMD_IP_REACHABILITY_LOST"); break; case StaEvent.TYPE_CMD_TARGET_BSSID: - sb.append("CMD_TARGET_BSSID:"); + sb.append("CMD_TARGET_BSSID"); break; case StaEvent.TYPE_CMD_START_CONNECT: - sb.append("CMD_START_CONNECT:"); + sb.append("CMD_START_CONNECT"); break; case StaEvent.TYPE_CMD_START_ROAM: - sb.append("CMD_START_ROAM:"); + sb.append("CMD_START_ROAM"); break; case StaEvent.TYPE_CONNECT_NETWORK: - sb.append("CONNECT_NETWORK:"); + sb.append("CONNECT_NETWORK"); break; case StaEvent.TYPE_NETWORK_AGENT_VALID_NETWORK: - sb.append("NETWORK_AGENT_VALID_NETWORK:"); + sb.append("NETWORK_AGENT_VALID_NETWORK"); break; case StaEvent.TYPE_FRAMEWORK_DISCONNECT: - sb.append("FRAMEWORK_DISCONNECT:") + sb.append("FRAMEWORK_DISCONNECT") .append(" reason=") .append(frameworkDisconnectReasonToString(event.frameworkDisconnectReason)); break; @@ -1991,11 +1996,11 @@ public class WifiMetrics { if (event.lastFreq != -1) sb.append(" lastFreq=").append(event.lastFreq); if (event.lastLinkSpeed != -1) sb.append(" lastLinkSpeed=").append(event.lastLinkSpeed); if (event.supplicantStateChangesBitmask != 0) { - sb.append("\n ").append(supplicantStateChangesBitmaskToString( + sb.append(", ").append(supplicantStateChangesBitmaskToString( event.supplicantStateChangesBitmask)); } if (event.configInfo != null) { - sb.append("\n ").append(configInfoToString(event.configInfo)); + sb.append(", ").append(configInfoToString(event.configInfo)); } return sb.toString(); @@ -2053,7 +2058,7 @@ public class WifiMetrics { } public static final int MAX_STA_EVENTS = 512; - private LinkedList<StaEvent> mStaEventList = new LinkedList<StaEvent>(); + private LinkedList<StaEventWithTime> mStaEventList = new LinkedList<StaEventWithTime>(); private int mLastPollRssi = -127; private int mLastPollLinkSpeed = -1; private int mLastPollFreq = -1; @@ -2085,4 +2090,27 @@ public class WifiMetrics { int count = sia.get(element); sia.put(element, count + 1); } + + private static class StaEventWithTime { + public StaEvent staEvent; + public long wallClockMillis; + + StaEventWithTime(StaEvent event, long wallClockMillis) { + staEvent = event; + this.wallClockMillis = wallClockMillis; + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + Calendar c = Calendar.getInstance(); + c.setTimeInMillis(wallClockMillis); + if (wallClockMillis != 0) { + sb.append(String.format("%tm-%td %tH:%tM:%tS.%tL", c, c, c, c, c, c)); + } else { + sb.append(" "); + } + sb.append(" ").append(staEventToString(staEvent)); + return sb.toString(); + } + } } |