summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-10-10 08:20:38 -0700
committerRoshan Pius <rpius@google.com>2019-10-10 14:14:21 -0700
commita9c9e836f1b573725146b06b8a0b7cef4b867747 (patch)
treec8a02181e2a3af98135b396dcf33d42438a9559d /tests
parent3674b62a25b3853eb897ae5e4385c9d8debe1fa0 (diff)
WifiScanningServiceImpl: Handle race on iface removal
If there is a scan completion event as the iface is being removed, mScannerImpls will contain an empty list when trying to report the results. Return a scan failure instead because we can't fetch the real scan results since the iface is no longer there. Bug: 142469675 Test: atest com.android.server.wifi.scanner Change-Id: I673e7562196fdb9660e74c520478a10ad5d05e45
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
index 931335205..67a54ba82 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
@@ -1088,6 +1088,46 @@ public class WifiScanningServiceTest extends WifiBaseTest {
}
/**
+ * Send a single scan request and then disable Wi-Fi before it completes
+ */
+ @Test
+ public void sendSingleScanRequestThenDisableWifiAfterScanCompleteButBeforeReportingResults() {
+ WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400), 0,
+ 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ ScanResults results = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400);
+ int requestId = 2293;
+
+ startServiceAndLoadDriver();
+ mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog);
+
+ when(mWifiScannerImpl0.startSingleScan(any(WifiNative.ScanSettings.class),
+ any(WifiNative.ScanEventHandler.class))).thenReturn(true);
+
+ Handler handler = mock(Handler.class);
+ BidirectionalAsyncChannel controlChannel = connectChannel(handler);
+ InOrder order = inOrder(handler, mWifiScannerImpl0);
+
+ // Run scan 1
+ sendSingleScanRequest(controlChannel, requestId, requestSettings, null);
+ mLooper.dispatchAll();
+ WifiNative.ScanEventHandler eventHandler = verifyStartSingleScan(order,
+ computeSingleScanNativeSettings(requestSettings));
+ verifySuccessfulResponse(order, handler, requestId);
+
+ // disable wifi
+ controlChannel.sendMessage(Message.obtain(null, WifiScanner.CMD_DISABLE));
+ // scan results complete event
+ when(mWifiScannerImpl0.getLatestSingleScanResults())
+ .thenReturn(results.getScanData());
+ eventHandler.onScanStatus(WifiNative.WIFI_SCAN_RESULTS_AVAILABLE);
+
+ mLooper.dispatchAll();
+ verifyFailedResponse(order, handler, requestId, WifiScanner.REASON_UNSPECIFIED,
+ "Scan was interrupted");
+ verifyNoMoreInteractions(handler);
+ }
+
+ /**
* Send a single scan request, schedule a second pending scan and disable Wi-Fi before the first
* scan completes.
*/