diff options
author | xshu <xshu@google.com> | 2018-03-15 16:48:17 -0700 |
---|---|---|
committer | xshu <xshu@google.com> | 2018-04-18 11:12:38 -0700 |
commit | 338d87ce46cf0766005f747bb82ac590ceaff54d (patch) | |
tree | b3d83a312a879e5624f75916a0407bdb5b41faa9 /service | |
parent | 3a48dfd8ab53cf4050a17009afd829e6483369bb (diff) |
metrics: Watchdog success delay
Tracks how long it takes for wifi to connect after a watchdog trigger.
Bug: 75001353
Test: compile, run ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: Iad9a20b38ad92d76cfc46d9fd01f2f565e9a22d0
Diffstat (limited to 'service')
3 files changed, 19 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 82f7d6cb2..3ebfe2ccd 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -284,8 +284,8 @@ public class WifiInjector { mSettingsStore, mWifiServiceHandlerThread.getLooper(), mFrameworkFacade, mWifiStateMachinePrime); mSelfRecovery = new SelfRecovery(mWifiController, mClock); - mWifiLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mWifiMetrics, - mWifiStateMachine, wifiStateMachineLooper); + mWifiLastResortWatchdog = new WifiLastResortWatchdog(mSelfRecovery, mClock, + mWifiMetrics, mWifiStateMachine, wifiStateMachineLooper); mWifiMulticastLockManager = new WifiMulticastLockManager( mWifiStateMachine.getMcastLockManagerFilterController(), BatteryStatsService.getService()); diff --git a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java index f759b1782..38f1be092 100644 --- a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java +++ b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java @@ -90,16 +90,19 @@ public class WifiLastResortWatchdog { // Is Watchdog allowed to trigger now? Set to false after triggering. Set to true after // successfully connecting or a new network (SSID) becomes available to connect to. private boolean mWatchdogAllowedToTrigger = true; + private long mTimeLastTrigger; private SelfRecovery mSelfRecovery; private WifiMetrics mWifiMetrics; private WifiStateMachine mWifiStateMachine; private Looper mWifiStateMachineLooper; private double mBugReportProbability = PROB_TAKE_BUGREPORT_DEFAULT; + private Clock mClock; - WifiLastResortWatchdog(SelfRecovery selfRecovery, WifiMetrics wifiMetrics, + WifiLastResortWatchdog(SelfRecovery selfRecovery, Clock clock, WifiMetrics wifiMetrics, WifiStateMachine wsm, Looper wifiStateMachineLooper) { mSelfRecovery = selfRecovery; + mClock = clock; mWifiMetrics = wifiMetrics; mWifiStateMachine = wsm; mWifiStateMachineLooper = wifiStateMachineLooper; @@ -223,6 +226,7 @@ public class WifiLastResortWatchdog { Log.e(TAG, "Watchdog triggering recovery"); mSsidAvailableAtFailure.clear(); mSsidAvailableAtFailure.addAll(mSsidFailureCount.keySet()); + mTimeLastTrigger = mClock.getElapsedSinceBootMillis(); mSelfRecovery.trigger(SelfRecovery.REASON_LAST_RESORT_WATCHDOG); // increment various watchdog trigger count stats incrementWifiMetricsTriggerCounts(); @@ -249,6 +253,8 @@ public class WifiLastResortWatchdog { // WiFi has connected after a Watchdog trigger, without any new networks becoming // available, log a Watchdog success in wifi metrics mWifiMetrics.incrementNumLastResortWatchdogSuccesses(); + long durationMs = mClock.getElapsedSinceBootMillis() - mTimeLastTrigger; + mWifiMetrics.setWatchdogSuccessTimeDurationMs(durationMs); if (mSsidAvailableAtFailure.contains(ssid)) { Log.e(TAG, "Wifi failed to connect on " + mSsidAvailableAtFailure.size() + " networks but was able to reconnect to one of them after a restart."); diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index ea04f2f73..584e51043 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -1144,6 +1144,16 @@ public class WifiMetrics { } /** + * Sets the time taken for wifi to connect after a watchdog triggers a restart. + * @param milliseconds + */ + public void setWatchdogSuccessTimeDurationMs(long ms) { + synchronized (mLock) { + mWifiLogProto.watchdogTriggerToConnectionSuccessDurationMs = ms; + } + } + + /** * Increments the count of alerts by alert reason. * * @param reason The cause of the alert. The reason values are driver-specific. |