summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server/wifi/scanner
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-01-18 18:24:52 -0800
committerRoshan Pius <rpius@google.com>2018-01-23 14:27:10 -0800
commit3feac6fe9249c1b7bf284c7a9bfa65a86b973154 (patch)
tree6078876a3014a80e93b7ec188b1c3ca22ad69c7c /tests/wifitests/src/com/android/server/wifi/scanner
parentb39dea09cec69c6e0c1b4b1f16cbef58b01c1532 (diff)
downloadandroid_frameworks_opt_net_wifi-3feac6fe9249c1b7bf284c7a9bfa65a86b973154.tar.gz
android_frameworks_opt_net_wifi-3feac6fe9249c1b7bf284c7a9bfa65a86b973154.tar.bz2
android_frameworks_opt_net_wifi-3feac6fe9249c1b7bf284c7a9bfa65a86b973154.zip
WifiScanningService: Plumb DBS scan params from/to Wificond
a) Plumb the scan type to wificond from WifiScanner. Note: Scans with different types will not be coalesced together. b) Plumb the scan result radio chain info from wificond to WifiScanner. Bug: 68335251 Test: Unit tests Test: Manual Tests (Scans still work) Change-Id: Ief135715f70dedc71600f1c575e8a5eaf4ba7097
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/scanner')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java46
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java121
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java2
5 files changed, 155 insertions, 22 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java
index e02fe776e..6e4768adc 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java
@@ -416,7 +416,7 @@ public class BackgroundScanSchedulerTest {
@Test
public void singleExponentialBackOffRequest() {
Collection<ScanSettings> requests = Collections.singleton(createRequest(
- WifiScanner.WIFI_BAND_BOTH, 30000, 160000, 2, 0, 20,
+ WifiScanner.TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_BOTH, 30000, 160000, 2, 0, 20,
WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN
));
@@ -433,8 +433,8 @@ public class BackgroundScanSchedulerTest {
@Test
public void exponentialBackOffAndRegularRequests() {
Collection<ScanSettings> requests = new ArrayList<>();
- requests.add(createRequest(WifiScanner.WIFI_BAND_BOTH, 30000, 200000, 1,
- 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN));
+ requests.add(createRequest(WifiScanner.TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_BOTH, 30000,
+ 200000, 1, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN));
requests.add(createRequest(channelsToSpec(5175), 30000, 0, 20,
WifiScanner.REPORT_EVENT_AFTER_BUFFER_FULL));
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java
index 5ec63afc8..7c3927896 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/BaseWifiScannerImplTest.java
@@ -120,7 +120,8 @@ public abstract class BaseWifiScannerImplTest {
WifiScanner.WIFI_BAND_24_GHZ)
.build();
- doSuccessfulSingleScanTest(settings, expectedBandScanFreqs(WifiScanner.WIFI_BAND_24_GHZ),
+ doSuccessfulSingleScanTest(settings,
+ expectedBandScanFreqs(WifiScanner.WIFI_BAND_24_GHZ),
new HashSet<String>(),
ScanResults.create(0, isAllChannelsScanned(WifiScanner.WIFI_BAND_24_GHZ),
2400, 2450, 2450, 2400, 2450, 2450, 2400, 2450, 2450), false);
@@ -140,6 +141,20 @@ public abstract class BaseWifiScannerImplTest {
}
@Test
+ public void singleScanSuccessWithChannelsAndHighAccuracyType() {
+ WifiNative.ScanSettings settings = new NativeScanSettingsBuilder()
+ .withType(WifiNative.SCAN_TYPE_HIGH_ACCURACY)
+ .withBasePeriod(10000)
+ .withMaxApPerScan(10)
+ .addBucketWithChannels(20000, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, 5650)
+ .build();
+
+ doSuccessfulSingleScanTest(settings, createFreqSet(5650),
+ new HashSet<String>(),
+ ScanResults.create(0, 5650, 5650, 5650, 5650, 5650, 5650, 5650, 5650), false);
+ }
+
+ @Test
public void singleScanSuccessWithFullResults() {
WifiNative.ScanSettings settings = new NativeScanSettingsBuilder()
.withBasePeriod(10000)
@@ -226,7 +241,7 @@ public abstract class BaseWifiScannerImplTest {
WifiNative.ScanEventHandler eventHandler2 = mock(WifiNative.ScanEventHandler.class);
// scan start succeeds
- when(mWifiNative.scan(eq(IFACE_NAME), any(), any(Set.class))).thenReturn(true);
+ when(mWifiNative.scan(eq(IFACE_NAME), anyInt(), any(), any(Set.class))).thenReturn(true);
assertTrue(mScanner.startSingleScan(settings, eventHandler));
assertFalse("second scan while first scan running should fail immediately",
@@ -249,7 +264,7 @@ public abstract class BaseWifiScannerImplTest {
InOrder order = inOrder(eventHandler, mWifiNative);
// scan fails
- when(mWifiNative.scan(eq(IFACE_NAME), any(), any(Set.class))).thenReturn(false);
+ when(mWifiNative.scan(eq(IFACE_NAME), anyInt(), any(), any(Set.class))).thenReturn(false);
// start scan
assertTrue(mScanner.startSingleScan(settings, eventHandler));
@@ -279,7 +294,7 @@ public abstract class BaseWifiScannerImplTest {
InOrder order = inOrder(eventHandler, mWifiNative);
// scan succeeds
- when(mWifiNative.scan(eq(IFACE_NAME), any(), any(Set.class))).thenReturn(true);
+ when(mWifiNative.scan(eq(IFACE_NAME), anyInt(), any(), any(Set.class))).thenReturn(true);
// start scan
assertTrue(mScanner.startSingleScan(settings, eventHandler));
@@ -313,7 +328,7 @@ public abstract class BaseWifiScannerImplTest {
InOrder order = inOrder(eventHandler, mWifiNative);
// scan succeeds
- when(mWifiNative.scan(eq(IFACE_NAME), any(), any(Set.class))).thenReturn(true);
+ when(mWifiNative.scan(eq(IFACE_NAME), anyInt(), any(), any(Set.class))).thenReturn(true);
// start scan
assertTrue(mScanner.startSingleScan(settings, eventHandler));
@@ -357,6 +372,7 @@ public abstract class BaseWifiScannerImplTest {
WifiScanner.WIFI_BAND_24_GHZ)
.build();
WifiNative.ScanSettings settings2 = new NativeScanSettingsBuilder()
+ .withType(WifiNative.SCAN_TYPE_LOW_POWER)
.withBasePeriod(10000)
.withMaxApPerScan(10)
.addBucketWithBand(10000, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN,
@@ -367,12 +383,12 @@ public abstract class BaseWifiScannerImplTest {
InOrder order = inOrder(eventHandler, mWifiNative);
// scans succeed
- when(mWifiNative.scan(eq(IFACE_NAME), any(), any(Set.class))).thenReturn(true);
+ when(mWifiNative.scan(eq(IFACE_NAME), anyInt(), any(), any(Set.class))).thenReturn(true);
// start first scan
assertTrue(mScanner.startSingleScan(settings, eventHandler));
- expectSuccessfulSingleScan(order, eventHandler,
+ expectSuccessfulSingleScan(order, WifiNative.SCAN_TYPE_LOW_LATENCY, eventHandler,
expectedBandScanFreqs(WifiScanner.WIFI_BAND_24_GHZ),
new HashSet<String>(),
ScanResults.create(0, isAllChannelsScanned(WifiScanner.WIFI_BAND_24_GHZ),
@@ -381,7 +397,7 @@ public abstract class BaseWifiScannerImplTest {
// start second scan
assertTrue(mScanner.startSingleScan(settings2, eventHandler));
- expectSuccessfulSingleScan(order, eventHandler,
+ expectSuccessfulSingleScan(order, WifiNative.SCAN_TYPE_LOW_POWER, eventHandler,
expectedBandScanFreqs(WifiScanner.WIFI_BAND_BOTH_WITH_DFS),
new HashSet<String>(),
ScanResults.create(0, true,
@@ -440,12 +456,12 @@ public abstract class BaseWifiScannerImplTest {
InOrder order = inOrder(eventHandler, mWifiNative);
// scan succeeds
- when(mWifiNative.scan(eq(IFACE_NAME), any(), any(Set.class))).thenReturn(true);
+ when(mWifiNative.scan(eq(IFACE_NAME), anyInt(), any(), any(Set.class))).thenReturn(true);
// start scan
assertTrue(mScanner.startSingleScan(settings, eventHandler));
- order.verify(mWifiNative).scan(eq(IFACE_NAME), eq(expectedScan), any(Set.class));
+ order.verify(mWifiNative).scan(eq(IFACE_NAME), anyInt(), eq(expectedScan), any(Set.class));
when(mWifiNative.getScanResults(eq(IFACE_NAME))).thenReturn(rawResults);
@@ -492,22 +508,22 @@ public abstract class BaseWifiScannerImplTest {
InOrder order = inOrder(eventHandler, mWifiNative);
// scan succeeds
- when(mWifiNative.scan(eq(IFACE_NAME), any(), any(Set.class))).thenReturn(true);
+ when(mWifiNative.scan(eq(IFACE_NAME), anyInt(), any(), any(Set.class))).thenReturn(true);
// start scan
assertTrue(mScanner.startSingleScan(settings, eventHandler));
- expectSuccessfulSingleScan(order, eventHandler, expectedScan, expectedHiddenNetSSIDs,
- results, expectFullResults);
+ expectSuccessfulSingleScan(order, settings.scanType, eventHandler, expectedScan,
+ expectedHiddenNetSSIDs, results, expectFullResults);
verifyNoMoreInteractions(eventHandler);
}
protected void expectSuccessfulSingleScan(InOrder order,
- WifiNative.ScanEventHandler eventHandler, Set<Integer> expectedScan,
+ int scanType, WifiNative.ScanEventHandler eventHandler, Set<Integer> expectedScan,
Set<String> expectedHiddenNetSSIDs, ScanResults results, boolean expectFullResults) {
order.verify(mWifiNative).scan(
- eq(IFACE_NAME), eq(expectedScan), eq(expectedHiddenNetSSIDs));
+ eq(IFACE_NAME), eq(scanType), eq(expectedScan), eq(expectedHiddenNetSSIDs));
when(mWifiNative.getScanResults(
eq(IFACE_NAME))).thenReturn(results.getScanDetailArrayList());
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 9cb2992c9..a083eceb6 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
@@ -752,6 +752,51 @@ public class WifiScanningServiceTest {
}
/**
+ * Do a single scan with invalid scan type set.
+ * Expect a scan failure.
+ */
+ @Test
+ public void sendSingleScanRequestWithInvalidScanType()
+ throws Exception {
+ WifiScanner.ScanSettings requestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0,
+ 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ int requestId = 33;
+ requestSettings.type = 100; // invalid scan type
+ WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set
+
+ startServiceAndLoadDriver();
+ mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog);
+
+ Handler handler = mock(Handler.class);
+ BidirectionalAsyncChannel controlChannel = connectChannel(handler);
+ InOrder order = inOrder(handler, mWifiScannerImpl);
+
+ // successful start
+ when(mWifiScannerImpl.startSingleScan(any(WifiNative.ScanSettings.class),
+ any(WifiNative.ScanEventHandler.class))).thenReturn(true);
+
+ sendSingleScanRequest(controlChannel, requestId, requestSettings, null);
+
+ // Scan is successfully queued
+ mLooper.dispatchAll();
+
+ // but then fails to execute
+ verifyFailedResponse(order, handler, requestId,
+ WifiScanner.REASON_INVALID_REQUEST, "bad request");
+ assertDumpContainsCallbackLog("singleScanInvalidRequest", requestId,
+ "bad request");
+
+ assertEquals(mWifiMetrics.getOneshotScanCount(), 1);
+ assertEquals(mWifiMetrics.getScanReturnEntry(
+ WifiMetricsProto.WifiLog.SCAN_FAILURE_INVALID_CONFIGURATION), 1);
+
+ // Ensure that no scan was triggered to the lower layers.
+ verify(mBatteryStats, never()).noteWifiScanStoppedFromSource(eq(workSource));
+ verify(mWifiScannerImpl, never()).startSingleScan(any(WifiNative.ScanSettings.class),
+ any(WifiNative.ScanEventHandler.class));
+ }
+
+ /**
* Do a single scan from a non-privileged app with no privileged params set.
*/
@Test
@@ -1077,6 +1122,76 @@ public class WifiScanningServiceTest {
assertEquals(mWifiMetrics.getScanReturnEntry(WifiMetricsProto.WifiLog.SCAN_SUCCESS), 2);
}
+ /**
+ * Send a single scan request and then a second one not satisfied by the first before the first
+ * completes. Verify that both are scheduled and succeed.
+ */
+ @Test
+ public void sendSingleScanRequestWhilePreviousScanRunningWithDifferentType() {
+ // Create identitical scan requests other than the types being different.
+ WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0,
+ 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ requestSettings1.type = WifiScanner.TYPE_LOW_LATENCY;
+ int requestId1 = 12;
+ ScanResults results1 = ScanResults.create(0, true, 2400);
+
+ WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2400), 0,
+ 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ requestSettings2.type = WifiScanner.TYPE_HIGH_ACCURACY;
+ int requestId2 = 13;
+ ScanResults results2 = ScanResults.create(0, true, 2400);
+
+ startServiceAndLoadDriver();
+ mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog);
+
+ when(mWifiScannerImpl.startSingleScan(any(WifiNative.ScanSettings.class),
+ any(WifiNative.ScanEventHandler.class))).thenReturn(true);
+
+ Handler handler = mock(Handler.class);
+ BidirectionalAsyncChannel controlChannel = connectChannel(handler);
+ InOrder handlerOrder = inOrder(handler);
+ InOrder nativeOrder = inOrder(mWifiScannerImpl);
+
+ // Run scan 1
+ sendSingleScanRequest(controlChannel, requestId1, requestSettings1, null);
+
+ mLooper.dispatchAll();
+ WifiNative.ScanEventHandler eventHandler1 = verifyStartSingleScan(nativeOrder,
+ computeSingleScanNativeSettings(requestSettings1));
+ verifySuccessfulResponse(handlerOrder, handler, requestId1);
+
+ // Queue scan 2 (will not run because previous is in progress)
+ sendSingleScanRequest(controlChannel, requestId2, requestSettings2, null);
+ mLooper.dispatchAll();
+ verifySuccessfulResponse(handlerOrder, handler, requestId2);
+
+ // dispatch scan 1 results
+ when(mWifiScannerImpl.getLatestSingleScanResults())
+ .thenReturn(results1.getScanData());
+ eventHandler1.onScanStatus(WifiNative.WIFI_SCAN_RESULTS_AVAILABLE);
+
+ mLooper.dispatchAll();
+ verifyScanResultsReceived(handlerOrder, handler, requestId1, results1.getScanData());
+ verifySingleScanCompletedReceived(handlerOrder, handler, requestId1);
+ verify(mContext).sendBroadcastAsUser(any(Intent.class), eq(UserHandle.ALL));
+
+ // now that the first scan completed we expect the second one to start
+ WifiNative.ScanEventHandler eventHandler2 = verifyStartSingleScan(nativeOrder,
+ computeSingleScanNativeSettings(requestSettings2));
+
+ // dispatch scan 2 results
+ when(mWifiScannerImpl.getLatestSingleScanResults())
+ .thenReturn(results2.getScanData());
+ eventHandler2.onScanStatus(WifiNative.WIFI_SCAN_RESULTS_AVAILABLE);
+
+ mLooper.dispatchAll();
+ verifyScanResultsReceived(handlerOrder, handler, requestId2, results2.getScanData());
+ verifySingleScanCompletedReceived(handlerOrder, handler, requestId2);
+ verify(mContext, times(2)).sendBroadcastAsUser(any(Intent.class), eq(UserHandle.ALL));
+ assertEquals(mWifiMetrics.getOneshotScanCount(), 2);
+ assertEquals(mWifiMetrics.getScanReturnEntry(WifiMetricsProto.WifiLog.SCAN_SUCCESS), 2);
+ }
+
/**
* Send a single scan request and then two more before the first completes. Neither are
@@ -1198,12 +1313,14 @@ public class WifiScanningServiceTest {
ScanResults results5GHz = ScanResults.create(0, 5150, 5150, 5175);
ScanResults resultsBoth = ScanResults.merge(results24GHz, results5GHz);
- WifiScanner.ScanSettings requestSettings1 = createRequest(WifiScanner.WIFI_BAND_BOTH, 0,
+ WifiScanner.ScanSettings requestSettings1 = createRequest(
+ WifiScanner.TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_BOTH, 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
int requestId1 = 12;
ScanResults results1 = resultsBoth;
- WifiScanner.ScanSettings requestSettings2 = createRequest(WifiScanner.WIFI_BAND_24_GHZ, 0,
+ WifiScanner.ScanSettings requestSettings2 = createRequest(
+ WifiScanner.TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_24_GHZ, 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
int requestId2 = 13;
ScanResults results2 = results24GHz;
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java
index 06dcba4a8..40b5c030c 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java
@@ -176,7 +176,7 @@ public class WificondPnoScannerTest {
WifiNative.PnoSettings pnoSettings, WifiNative.ScanEventHandler scanEventHandler,
WifiNative.PnoEventHandler pnoEventHandler) {
// Scans succeed
- when(mWifiNative.scan(eq(IFACE_NAME), any(), any(Set.class))).thenReturn(true);
+ when(mWifiNative.scan(eq(IFACE_NAME), anyInt(), any(), any(Set.class))).thenReturn(true);
when(mWifiNative.startPnoScan(eq(IFACE_NAME), any(WifiNative.PnoSettings.class)))
.thenReturn(true);
when(mWifiNative.stopPnoScan(IFACE_NAME)).thenReturn(true);
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java
index 50f5019d9..180d43e6b 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java
@@ -81,7 +81,7 @@ public class WificondScannerTest extends BaseWifiScannerImplTest {
mLooper.dispatchAll();
// No scan is issued to WifiNative.
- verify(mWifiNative, never()).scan(any(), any(), any(Set.class));
+ verify(mWifiNative, never()).scan(any(), anyInt(), any(), any(Set.class));
// A scan failed event must be reported.
verify(eventHandler).onScanStatus(WifiNative.WIFI_SCAN_FAILED);
}