diff options
author | Glen Kuhne <kuh@google.com> | 2016-06-09 16:13:04 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-06-09 16:13:04 +0000 |
commit | 373093ae826a68f0dd902309678c230ab3e078cd (patch) | |
tree | 8986e98cf8bef3de258b17f2cce7a7beddf5ede9 /service | |
parent | d016a8ff4c4a35179496c430b20d3f3e048507e1 (diff) | |
parent | 107f6ce4a5f6017ce336d9b60650ddbe28bee965 (diff) |
Merge "WifiMetrics: Record capture duration"
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiInjector.java | 4 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiMetrics.java | 36 | ||||
-rw-r--r-- | service/proto/wifi.proto | 3 |
3 files changed, 22 insertions, 21 deletions
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 36e27ac7d..e65573aec 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -32,10 +32,10 @@ public class WifiInjector { return LazyHolder.sInstance; } - private final WifiMetrics mWifiMetrics = new WifiMetrics(); + private final Clock mClock = new Clock(); + private final WifiMetrics mWifiMetrics = new WifiMetrics(mClock); private final WifiLastResortWatchdog mWifiLastResortWatchdog = new WifiLastResortWatchdog(mWifiMetrics); - private final Clock mClock = new Clock(); private final PropertyService mPropertyService = new SystemPropertyService(); private final BuildProperties mBuildProperties = new SystemBuildProperties(); private final KeyStore mKeyStore = KeyStore.getInstance(); diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 67914ae03..80c8b56bf 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -18,7 +18,6 @@ package com.android.server.wifi; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; -import android.os.SystemClock; import android.util.Base64; import android.util.Log; import android.util.SparseIntArray; @@ -45,7 +44,7 @@ public class WifiMetrics { private static final boolean DBG = false; private final Object mLock = new Object(); private static final int MAX_CONNECTION_EVENTS = 256; - + private Clock mClock; private boolean mScreenOn; private int mWifiState; /** @@ -72,6 +71,11 @@ public class WifiMetrics { * combination. Indexed by WifiLog.WifiState * (1 + screenOn) */ private SparseIntArray mWifiSystemStateEntries; + /** + * Records the getElapsedSinceBootMillis (in seconds) that represents the beginning of data + * capture for for this WifiMetricsProto + */ + private long mRecordStartTimeSec; class RouterFingerPrint { private WifiMetricsProto.RouterFingerPrint mRouterFingerPrintProto; @@ -298,7 +302,8 @@ public class WifiMetrics { } } - public WifiMetrics() { + public WifiMetrics(Clock clock) { + mClock = clock; mWifiLogProto = new WifiMetricsProto.WifiLog(); mConnectionEventList = new ArrayList<>(); mScanReturnEntries = new SparseIntArray(); @@ -306,6 +311,7 @@ public class WifiMetrics { mCurrentConnectionEvent = null; mScreenOn = true; mWifiState = WifiMetricsProto.WifiLog.WIFI_DISABLED; + mRecordStartTimeSec = mClock.getElapsedSinceBootMillis() / 1000; } // Values used for indexing SystemStateEntries @@ -348,12 +354,12 @@ public class WifiMetrics { } mCurrentConnectionEvent = new ConnectionEvent(); mCurrentConnectionEvent.mConnectionEvent.startTimeMillis = - System.currentTimeMillis(); + mClock.getWallClockMillis(); mCurrentConnectionEvent.mConfigBssid = targetBSSID; mCurrentConnectionEvent.mConnectionEvent.roamType = roamType; mCurrentConnectionEvent.mRouterFingerPrint.updateFromWifiConfiguration(config); mCurrentConnectionEvent.mConfigBssid = "any"; - mCurrentConnectionEvent.mRealStartTime = SystemClock.elapsedRealtime(); + mCurrentConnectionEvent.mRealStartTime = mClock.getElapsedSinceBootMillis(); mCurrentConnectionEvent.mWifiState = mWifiState; mCurrentConnectionEvent.mScreenOn = mScreenOn; mConnectionEventList.add(mCurrentConnectionEvent); @@ -406,7 +412,7 @@ public class WifiMetrics { boolean result = (level2FailureCode == 1) && (connectivityFailureCode == WifiMetricsProto.ConnectionEvent.HLF_NONE); mCurrentConnectionEvent.mConnectionEvent.connectionResult = result ? 1 : 0; - mCurrentConnectionEvent.mRealEndTime = SystemClock.elapsedRealtime(); + mCurrentConnectionEvent.mRealEndTime = mClock.getElapsedSinceBootMillis(); mCurrentConnectionEvent.mConnectionEvent.durationTakenToConnectMillis = (int) (mCurrentConnectionEvent.mRealEndTime - mCurrentConnectionEvent.mRealStartTime); @@ -899,6 +905,8 @@ public class WifiMetrics { + mWifiLogProto.numLastResortWatchdogTriggersWithBadDhcp); pw.println("mWifiLogProto.numLastResortWatchdogTriggersWithBadOther=" + mWifiLogProto.numLastResortWatchdogTriggersWithBadOther); + pw.println("mWifiLogProto.recordDurationSec=" + + ((mClock.getElapsedSinceBootMillis() / 1000) - mRecordStartTimeSec)); } } } @@ -954,19 +962,8 @@ public class WifiMetrics { mWifiLogProto.wifiSystemStateEntries[i].isScreenOn = (mWifiSystemStateEntries.keyAt(i) % 2) > 0; } - } - } - - /** - * Serializes all of WifiMetrics to WifiLog proto, and returns the byte array. - * Does not count as taking an automatic bug report - * - * @return byte array of the deserialized & consolidated Proto - */ - public byte[] toByteArray() { - synchronized (mLock) { - consolidateProto(false); - return WifiMetricsProto.WifiLog.toByteArray(mWifiLogProto); + mWifiLogProto.recordDurationSec = (int) ((mClock.getElapsedSinceBootMillis() / 1000) + - mRecordStartTimeSec); } } @@ -981,6 +978,7 @@ public class WifiMetrics { } mScanReturnEntries.clear(); mWifiSystemStateEntries.clear(); + mRecordStartTimeSec = mClock.getElapsedSinceBootMillis() / 1000; mWifiLogProto.clear(); } } diff --git a/service/proto/wifi.proto b/service/proto/wifi.proto index 73981afb5..43a4166dc 100644 --- a/service/proto/wifi.proto +++ b/service/proto/wifi.proto @@ -183,6 +183,9 @@ message WifiLog { // Count of times connectivity watchdog found background scan not working optional int32 num_connectivity_watchdog_background_bad = 33; + + // The time duration represented by this wifi log, from start to end of capture + optional int32 record_duration_sec = 34; } // Information that gets logged for every WiFi connection. |