diff options
author | Glen Kuhne <kuh@google.com> | 2016-06-13 17:56:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-06-13 17:56:11 +0000 |
commit | e1b848bb11cc44060328bf53162cb776e3dd54dc (patch) | |
tree | ef019eb6f3aaea9dbd4d8a32d2f28ebb801aa3ae /service | |
parent | e8f7d4ab151251991982329f7274f866bb03b3da (diff) | |
parent | 622e9ff3874251022ae3c27548bc5a2f77bdc8bc (diff) |
Merge \"DO NOT MERGE WifiMetrics: Record capture duration\" into nyc-dev
am: 622e9ff387
Change-Id: Ie7de4f9173a815abe88f91efc5a46893be5270d1
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 cc4048eb9..6939d4574 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 f3ab02c24..cc6fe000f 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 elapsedRealtime (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.elapsedRealtime() / 1000; } // Values used for indexing SystemStateEntries @@ -348,12 +354,12 @@ public class WifiMetrics { } mCurrentConnectionEvent = new ConnectionEvent(); mCurrentConnectionEvent.mConnectionEvent.startTimeMillis = - System.currentTimeMillis(); + mClock.currentTimeMillis(); mCurrentConnectionEvent.mConfigBssid = targetBSSID; mCurrentConnectionEvent.mConnectionEvent.roamType = roamType; mCurrentConnectionEvent.mRouterFingerPrint.updateFromWifiConfiguration(config); mCurrentConnectionEvent.mConfigBssid = "any"; - mCurrentConnectionEvent.mRealStartTime = SystemClock.elapsedRealtime(); + mCurrentConnectionEvent.mRealStartTime = mClock.elapsedRealtime(); 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.elapsedRealtime(); 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.elapsedRealtime() / 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 mWifiLogProto.toByteArray(mWifiLogProto); + mWifiLogProto.recordDurationSec = (int) ((mClock.elapsedRealtime() / 1000) + - mRecordStartTimeSec); } } @@ -981,6 +978,7 @@ public class WifiMetrics { } mScanReturnEntries.clear(); mWifiSystemStateEntries.clear(); + mRecordStartTimeSec = mClock.elapsedRealtime() / 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. |