summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-11-20 16:29:04 -0800
committerxshu <xshu@google.com>2019-11-21 16:26:43 -0800
commit6f4ff4c473aabac4312925e6ea7634a363f7f164 (patch)
tree0f2fedf7e44ebae1d4fb8cf0cccf02471c30d279 /tests
parentab76156ea09cd07865322a077801d86b99b5ea25 (diff)
Cache the last connection timestamp in scorecard
Caches the timestamp of the last successful L2 connection. This information will be used to detect frequent disconnects. Bug: 139287182 Test: atest FrameworksWifiTests Change-Id: I6ce7ed07f552a4980a0aa13a96a0d5ed5934dd53
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java5
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java16
2 files changed, 20 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
index 16eb976ea..1f42d45b6 100644
--- a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
@@ -249,10 +249,12 @@ public class BssidBlocklistMonitorTest {
}
/**
- * Verify that handleBssidConnectionSuccess resets appropriate blocklist streak counts.
+ * Verify that handleBssidConnectionSuccess resets appropriate blocklist streak counts, and
+ * notifies WifiScorecard of the successful connection.
*/
@Test
public void testNetworkConnectionResetsBlocklistStreak() {
+ when(mClock.getWallClockMillis()).thenReturn(100L);
mBssidBlocklistMonitor.handleBssidConnectionSuccess(TEST_BSSID_1, TEST_SSID_1);
verify(mWifiScoreCard).resetBssidBlocklistStreak(TEST_SSID_1, TEST_BSSID_1,
BssidBlocklistMonitor.REASON_AP_UNABLE_TO_HANDLE_NEW_STA);
@@ -266,6 +268,7 @@ public class BssidBlocklistMonitorTest {
BssidBlocklistMonitor.REASON_ASSOCIATION_TIMEOUT);
verify(mWifiScoreCard).resetBssidBlocklistStreak(TEST_SSID_1, TEST_BSSID_1,
BssidBlocklistMonitor.REASON_AUTHENTICATION_FAILURE);
+ verify(mWifiScoreCard).setBssidConnectionTimeMs(TEST_SSID_1, TEST_BSSID_1, 100L);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
index c02ecf0f8..135a71ee2 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
@@ -194,6 +194,22 @@ public class WifiScoreCardTest extends WifiBaseTest {
}
/**
+ * Test the update and retrieval of the last connection time to a BSSID.
+ */
+ @Test
+ public void testSetBssidConnectionTimestampMs() {
+ mWifiInfo.setSSID(TEST_SSID_1);
+ mWifiInfo.setBSSID(TEST_BSSID_1.toString());
+ mWifiScoreCard.noteIpConfiguration(mWifiInfo);
+
+ String ssid = mWifiInfo.getSSID();
+ String bssid = mWifiInfo.getBSSID();
+ assertEquals(0L, mWifiScoreCard.getBssidConnectionTimestampMs(ssid, bssid));
+ assertEquals(0L, mWifiScoreCard.setBssidConnectionTimestampMs(ssid, bssid, 100L));
+ assertEquals(100L, mWifiScoreCard.getBssidConnectionTimestampMs(ssid, bssid));
+ }
+
+ /**
* Test identifiers.
*/
@Test