summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGlen Kuhne <kuh@google.com>2016-07-26 14:14:23 -0700
committerGlen Kuhne <kuh@google.com>2016-08-29 16:22:11 -0700
commit1c50de232acb3d6148c454941a6b9a79e0663b81 (patch)
treeeef902512f84616e429816f55cd364ed24673ff0 /tests
parenta284841edf33e4070748816a034c47f996bfeb81 (diff)
downloadandroid_frameworks_opt_net_wifi-1c50de232acb3d6148c454941a6b9a79e0663b81.tar.gz
android_frameworks_opt_net_wifi-1c50de232acb3d6148c454941a6b9a79e0663b81.tar.bz2
android_frameworks_opt_net_wifi-1c50de232acb3d6148c454941a6b9a79e0663b81.zip
WiFiMetrics: Add LastResortWatchdog success metric
Added a metric that tracks how often WifiLastResortWatchdog triggers successfully fix wifi, allowing wifi to connect to a network after triggering. It does not count a success, if the connection occurs after a new network becomes available. BUG=30407550 TEST=Unit Tests Change-Id: I68d1f003fee9eb8074c04db141bd7b5c3089d57b
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java56
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java6
2 files changed, 60 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
index 237fc666d..08163e7f2 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLastResortWatchdogTest.java
@@ -1440,7 +1440,7 @@ public class WifiLastResortWatchdogTest {
int[] levels = {-60, -86, -50, -62, -60};
boolean[] isEphemeral = {false, false, false, false, false};
boolean[] hasEverConnected = {true, false, false, false, false};
- // Buffer potential candidates 1,2,3 & 4
+ // Buffer potential candidates 1,2,3,4 & 5
List<Pair<ScanDetail, WifiConfiguration>> candidates = createFilteredQnsCandidates(ssids,
bssids, frequencies, caps, levels, isEphemeral, hasEverConnected);
mLastResortWatchdog.updateAvailableNetworks(candidates);
@@ -1450,7 +1450,7 @@ public class WifiLastResortWatchdogTest {
assertFailureCountEquals(bssids[i], 0, 0, 0);
}
- //Increment failure count for the first test network ssid & bssid
+ //Increment failure counts
for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD; i++) {
mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
ssids[1], bssids[1], WifiLastResortWatchdog.FAILURE_CODE_AUTHENTICATION);
@@ -1478,6 +1478,58 @@ public class WifiLastResortWatchdogTest {
verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogTriggersWithBadAssociation();
verify(mWifiMetrics, times(1)).addCountToNumLastResortWatchdogBadDhcpNetworksTotal(3);
verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogTriggersWithBadDhcp();
+
+ // Simulate wifi connecting after triggering
+ mLastResortWatchdog.connectedStateTransition(true);
+
+ // Verify that WifiMetrics counted this as a Watchdog success
+ verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses();
+
+ // Simulate wifi disconnecting
+ mLastResortWatchdog.connectedStateTransition(false);
+
+ // Verify that WifiMetrics has still only counted one success
+ verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses();
+
+ // Remove the fifth network from candidates
+ candidates = createFilteredQnsCandidates(Arrays.copyOfRange(mSsids, 0, 4),
+ Arrays.copyOfRange(mBssids, 0, 4),
+ Arrays.copyOfRange(mFrequencies, 0, 4),
+ Arrays.copyOfRange(mCaps, 0, 4),
+ Arrays.copyOfRange(mLevels, 0, 4),
+ Arrays.copyOfRange(mIsEphemeral, 0, 4));
+
+ // Age out the fifth network
+ for (int i = 0; i < WifiLastResortWatchdog.MAX_BSSID_AGE; i++) {
+ mLastResortWatchdog.updateAvailableNetworks(candidates);
+ }
+
+ //Increment failure counts
+ for (int i = 0; i < WifiLastResortWatchdog.FAILURE_THRESHOLD; i++) {
+ mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
+ ssids[1], bssids[1], WifiLastResortWatchdog.FAILURE_CODE_AUTHENTICATION);
+ mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
+ ssids[2], bssids[2], WifiLastResortWatchdog.FAILURE_CODE_DHCP);
+ mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
+ ssids[3], bssids[3], WifiLastResortWatchdog.FAILURE_CODE_DHCP);
+ mLastResortWatchdog.noteConnectionFailureAndTriggerIfNeeded(
+ ssids[0], bssids[0], WifiLastResortWatchdog.FAILURE_CODE_ASSOCIATION);
+ }
+
+ // Add network #5 back into the candidates
+ candidates = createFilteredQnsCandidates(ssids,
+ bssids, frequencies, caps, levels, isEphemeral, hasEverConnected);
+
+ // LastResortWatchdog should reactivate because there is a new network (#5) available,
+ // Not because it was successful
+ mLastResortWatchdog.updateAvailableNetworks(candidates);
+
+ // Simulate wifi connecting
+ mLastResortWatchdog.connectedStateTransition(true);
+
+ // Verify that WifiMetrics did not count another success, as the connection could be due
+ // to the newly available network #5
+ verify(mWifiMetrics, times(1)).incrementNumLastResortWatchdogSuccesses();
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index b10f5734a..0b4e49846 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -171,6 +171,7 @@ public class WifiMetricsTest {
private static final int NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_AUTHENTICATION = 8;
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 NUM_RSSI_LEVELS_TO_INCREMENT = 20;
private static final int FIRST_RSSI_LEVEL = -80;
/**
@@ -255,6 +256,9 @@ public class WifiMetricsTest {
for (int i = 0; i < NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_OTHER; i++) {
mWifiMetrics.incrementNumLastResortWatchdogTriggersWithBadOther();
}
+ for (int i = 0; i < NUM_LAST_RESORT_WATCHDOG_SUCCESSES; i++) {
+ mWifiMetrics.incrementNumLastResortWatchdogSuccesses();
+ }
for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) {
for (int j = 0; j <= i; j++) {
mWifiMetrics.incrementRssiPollRssiCount(FIRST_RSSI_LEVEL + i);
@@ -343,6 +347,8 @@ public class WifiMetricsTest {
mDeserializedWifiMetrics.numLastResortWatchdogTriggersWithBadDhcp);
assertEquals(NUM_LAST_RESORT_WATCHDOG_TRIGGERS_WITH_BAD_OTHER,
mDeserializedWifiMetrics.numLastResortWatchdogTriggersWithBadOther);
+ assertEquals(NUM_LAST_RESORT_WATCHDOG_SUCCESSES,
+ mDeserializedWifiMetrics.numLastResortWatchdogSuccesses);
assertEquals(TEST_RECORD_DURATION_SEC,
mDeserializedWifiMetrics.recordDurationSec);
for (int i = 0; i < NUM_RSSI_LEVELS_TO_INCREMENT; i++) {