summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2020-06-17 17:43:53 -0700
committerxshu <xshu@google.com>2020-06-17 19:26:40 -0700
commitef4f7dc4ea5619b713bcfaa4985338ec07b9f479 (patch)
tree33f3613a17df314f4f323e2bd8d21e3c8824a12e /tests
parent41c8058406f2de77c0105cd4a82c4ad1dd00fcfa (diff)
Fix NPE in BssidBlocklistMonitor
Due to unexpected orderings of events happening in ClientModeImpl, sometimes invalid inputs are being passed to BssidBlocklistMonitor to cause a NPE. This patch fixes the crash but does not address the root cause. Bug: 159183809 Test: atest com.android.server.wifi Change-Id: I6991b29949f9799662b8d29a4e0621fed9ff8cf2
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
index 4369a831b..8cb2e376a 100644
--- a/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/BssidBlocklistMonitorTest.java
@@ -662,4 +662,24 @@ public class BssidBlocklistMonitorTest {
assertEquals(0, mBssidBlocklistMonitor.updateAndGetBssidBlocklist().size());
assertEquals(2, mBssidBlocklistMonitor.getBssidStatusHistoryLoggerSize());
}
+
+ /**
+ * Verify that invalid inputs are handled and result in no-op.
+ */
+ @Test
+ public void testBlockBssidForDurationMsInvalidInputs() {
+ // test invalid BSSID
+ when(mClock.getWallClockMillis()).thenReturn(0L);
+ long testDuration = 5500L;
+ mBssidBlocklistMonitor.blockBssidForDurationMs(null, TEST_SSID_1, testDuration);
+ assertEquals(0, mBssidBlocklistMonitor.updateAndGetBssidBlocklist().size());
+
+ // test invalid SSID
+ mBssidBlocklistMonitor.blockBssidForDurationMs(TEST_BSSID_1, null, testDuration);
+ assertEquals(0, mBssidBlocklistMonitor.updateAndGetBssidBlocklist().size());
+
+ // test invalid duration
+ mBssidBlocklistMonitor.blockBssidForDurationMs(TEST_BSSID_1, TEST_SSID_1, -1);
+ assertEquals(0, mBssidBlocklistMonitor.updateAndGetBssidBlocklist().size());
+ }
}