diff options
author | xshu <xshu@google.com> | 2018-04-10 16:19:57 -0700 |
---|---|---|
committer | xshu <xshu@google.com> | 2018-04-13 13:15:51 -0700 |
commit | 1f2ef2776476457b3eb2df70e39d53770c6b2b77 (patch) | |
tree | bac40eb1f8c83835bc2ba3c41755e862d91f68b3 | |
parent | 3a2a2a79bce7ce0f8fe4f4f8de6d0ec478532141 (diff) |
metrics: count connection failures after watchdog trigger
Sometimes wifi would experience several more connection failures before
finally being able to connect after a watchdog restart trigger. Count
these failures to get a better understanding of how watchdog is
performing.
Bug: 75001353
Test: compile, unit test
Change-Id: Ibec913c0b2aadfb1aa2390966f4bfd8fff5a2cca
4 files changed, 60 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java index 8f249168c..f759b1782 100644 --- a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java +++ b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java @@ -208,6 +208,10 @@ public class WifiLastResortWatchdog { // Update failure count for the failing network updateFailureCountForNetwork(ssid, bssid, reason); + // If watchdog is not allowed to trigger it means a wifi restart is already triggered + if (!mWatchdogAllowedToTrigger) { + mWifiMetrics.incrementWatchdogTotalConnectionFailureCountAfterTrigger(); + } // Have we met conditions to trigger the Watchdog Wifi restart? boolean isRestartNeeded = checkTriggerCondition(); if (mVerboseLoggingEnabled) { diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java index 66605971c..0b25a8695 100644 --- a/service/java/com/android/server/wifi/WifiMetrics.java +++ b/service/java/com/android/server/wifi/WifiMetrics.java @@ -1130,6 +1130,16 @@ public class WifiMetrics { } /** + * Increment the count of network connection failures that happened after watchdog has been + * triggered. + */ + public void incrementWatchdogTotalConnectionFailureCountAfterTrigger() { + synchronized (mLock) { + mWifiLogProto.watchdogTotalConnectionFailureCountAfterTrigger++; + } + } + + /** * Increments the count of alerts by alert reason. * * @param reason The cause of the alert. The reason values are driver-specific. diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java index 4abc77f91..0cbc06ac2 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java @@ -1810,4 +1810,44 @@ public class WifiLastResortWatchdogTest { mLooper.dispatchAll(); verify(mWifiStateMachine, times(1)).takeBugReport(anyString(), anyString()); } + + + /** + * Test metrics incrementing connection failure count after watchdog has already been triggered + */ + @Test + public void testIncrementingWatchdogConnectionFailuresAfterTrigger() { + String[] ssids = {"\"test1\""}; + String[] bssids = {"6c:f3:7f:ae:8c:f3"}; + int[] frequencies = {2437}; + String[] caps = {"[WPA2-EAP-CCMP][ESS]"}; + int[] levels = {-60}; + boolean[] isEphemeral = {false}; + boolean[] hasEverConnected = {true}; + List<Pair<ScanDetail, WifiConfiguration>> candidates = createFilteredQnsCandidates(ssids, + bssids, frequencies, caps, levels, isEphemeral, hasEverConnected); + mLastResortWatchdog.updateAvailableNetworks(candidates); + + // Ensure new networks have zero'ed failure counts + for (int i = 0; i < ssids.length; i++) { + assertFailureCountEquals(bssids[i], 0, 0, 0); + } + + //Increment failure counts + for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD; i++) { + mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded( + ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION); + } + + // Verify relevant WifiMetrics calls were made once with appropriate arguments + verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogTriggers(); + + // Verify that failure count after trigger is not incremented yet + verify(mWifiMetrics, never()).incrementWatchdogTotalConnectionFailureCountAfterTrigger(); + + // Fail 1 more time and verify this time it's counted + mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded( + ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION); + verify(mWifiMetrics, times(1)).incrementWatchdogTotalConnectionFailureCountAfterTrigger(); + } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index c31ecb03d..c61db7693 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -228,6 +228,7 @@ public class WifiMetricsTest { private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_DHCP = 9; private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_OTHER = 10; private static final int NUM_LAST_RESORT_WATCHDOG_SUCCESSES = 5; + private static final int WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER = 6; private static final int NUM_RSSI_LEVELS_TO_INCREMENT = 20; private static final int FIRST_RSSI_LEVEL = -80; private static final int NUM_OPEN_NETWORK_SCAN_RESULTS = 1; @@ -473,6 +474,9 @@ public class WifiMetricsTest { for (int i = 0; i < NUM_LAST_RESORT_WATCHDOG_SUCCESSES; i++) { mWifiMetrics.incrementNumLastResortWatchdogSuccesses(); } + for (int i = 0; i < WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER; i++) { + mWifiMetrics.incrementWatchdogTotalConnectionFailureCountAfterTrigger(); + } for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) { for (int j = 0; j <= i; j++) { mWifiMetrics.incrementRssiPollRssiCount(MIN_RSSI_LEVEL + i); @@ -775,6 +779,8 @@ public class WifiMetricsTest { mDecodedProto.numLastResortWatchdogTriggersWithBadOther); assertEquals(NUM_LAST_RESORT_WATCHDOG_SUCCESSES, mDecodedProto.numLastResortWatchdogSuccesses); + assertEquals(WATCHDOG_TOTAL_CONNECTION_FAILURE_COUNT_AFTER_TRIGGER, + mDecodedProto.watchdogTotalConnectionFailureCountAfterTrigger); assertEquals(TEST_RECORD_DURATION_SEC, mDecodedProto.recordDurationSec); for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) { |