summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOscar Shu <xshu@google.com>2018-04-17 20:53:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-04-17 20:53:13 +0000
commit3a48dfd8ab53cf4050a17009afd829e6483369bb (patch)
treeb028c5375a87448780fa12ea55fd9183b8122c3b
parentdd06605ed8c1249718eb881e3ebde3ee6da82eca (diff)
parent1f2ef2776476457b3eb2df70e39d53770c6b2b77 (diff)
Merge "metrics: count connection failures after watchdog trigger" into pi-dev
-rw-r--r--service/java/com/android/server/wifi/WifiLastResortWatchdog.java4
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java10
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java40
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java6
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 1d23cc350..ea04f2f73 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -1134,6 +1134,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 4a3239065..665b60b46 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -229,6 +229,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;
@@ -475,6 +476,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);
@@ -777,6 +781,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++) {