summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com/android/server/wifi/scanner
diff options
context:
space:
mode:
authorNingyuan Wang <nywang@google.com>2017-11-16 15:49:17 -0800
committerNingyuan Wang <nywang@google.com>2017-12-04 15:39:07 -0800
commitfc0ee31f8c7aaa9116299d08bf953f4d70fad1dc (patch)
tree3a757e60e63633c67152a56f71e7556a4cfffd6f /tests/wifitests/src/com/android/server/wifi/scanner
parent88207ee7bd254347036f620b2090fe08e6d28e88 (diff)
downloadandroid_frameworks_opt_net_wifi-fc0ee31f8c7aaa9116299d08bf953f4d70fad1dc.tar.gz
android_frameworks_opt_net_wifi-fc0ee31f8c7aaa9116299d08bf953f4d70fad1dc.tar.bz2
android_frameworks_opt_net_wifi-fc0ee31f8c7aaa9116299d08bf953f4d70fad1dc.zip
Decouple single scan and pno scan
This removes all the logic handling PNO scan pause and resume. This also removes all the logic and unit tests for PNO scan debouncer. Details includes split LastScanSettings to LastScanSettings and LastPnoScanSettings. Also since we no longer need to pause a PNO scan, this removes mPnoSettings and mPnoEventHandler because mLastPnoScanSettings could replace them. Bug: 64576221 Bug: 67467255 Test: compile, unit tests Test: integration tests Test: manually test wifi scans works Change-Id: I4803355ba82cfccb9eb8750caa8133645941009e
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/scanner')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java192
1 files changed, 0 insertions, 192 deletions
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 73ea14374..15dfcccc5 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondPnoScannerTest.java
@@ -17,7 +17,6 @@
package com.android.server.wifi.scanner;
import static com.android.server.wifi.ScanTestUtil.NativeScanSettingsBuilder;
-import static com.android.server.wifi.ScanTestUtil.assertScanDataEquals;
import static com.android.server.wifi.ScanTestUtil.setupMockChannels;
import static org.junit.Assert.*;
@@ -45,7 +44,6 @@ import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import java.util.Arrays;
import java.util.Set;
/**
@@ -104,89 +102,6 @@ public class WificondPnoScannerTest {
}
/**
- * Verify that we pause & resume HW PNO scan when a single scan is scheduled and invokes the
- * OnPnoNetworkFound callback when the scan results are received.
- */
- @Test
- public void pauseResumeHwDisconnectedPnoScanForSingleScan() {
- createScannerWithHwPnoScanSupport();
-
- WifiNative.PnoEventHandler pnoEventHandler = mock(WifiNative.PnoEventHandler.class);
- WifiNative.PnoSettings pnoSettings = createDummyPnoSettings(false);
- WifiNative.ScanEventHandler eventHandler = mock(WifiNative.ScanEventHandler.class);
- WifiNative.ScanSettings settings = createDummyScanSettings(false);
- ScanResults scanResults = createDummyScanResults(false);
-
- InOrder order = inOrder(eventHandler, mWifiNative);
- // Start PNO scan
- startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
- // Start single scan
- assertTrue(mScanner.startSingleScan(settings, eventHandler));
- // Verify that the PNO scan was paused and single scan runs successfully
- expectSuccessfulSingleScanWithHwPnoEnabled(order, eventHandler,
- expectedBandScanFreqs(WifiScanner.WIFI_BAND_24_GHZ), scanResults);
- verifyNoMoreInteractions(eventHandler);
-
- order = inOrder(pnoEventHandler, mWifiNative);
- // Resume PNO scan after the single scan results are received and PNO monitor debounce
- // alarm fires.
- assertTrue("dispatch pno monitor alarm",
- mAlarmManager.dispatch(
- WificondScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
- assertEquals("dispatch message after alarm", 1, mLooper.dispatchAll());
- // Now verify that PNO scan is resumed successfully
- expectSuccessfulHwDisconnectedPnoScan(order, pnoSettings, pnoEventHandler, scanResults);
- verifyNoMoreInteractions(pnoEventHandler);
- }
-
- /**
- * Verify that the HW PNO delayed failure cleans up the scan settings cleanly.
- * 1. Start Hw PNO.
- * 2. Start Single Scan which should pause PNO scan.
- * 3. Fail the PNO scan resume and verify that the OnPnoScanFailed callback is invoked.
- * 4. Now restart a new PNO scan to ensure that the failure was cleanly handled.
- */
- @Test
- public void delayedHwDisconnectedPnoScanFailure() {
- createScannerWithHwPnoScanSupport();
-
- WifiNative.PnoEventHandler pnoEventHandler = mock(WifiNative.PnoEventHandler.class);
- WifiNative.PnoSettings pnoSettings = createDummyPnoSettings(false);
- WifiNative.ScanEventHandler eventHandler = mock(WifiNative.ScanEventHandler.class);
- WifiNative.ScanSettings settings = createDummyScanSettings(false);
- ScanResults scanResults = createDummyScanResults(false);
-
- InOrder order = inOrder(eventHandler, mWifiNative);
- // Start PNO scan
- startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
- // Start single scan
- assertTrue(mScanner.startSingleScan(settings, eventHandler));
- // Verify that the PNO scan was paused and single scan runs successfully
- expectSuccessfulSingleScanWithHwPnoEnabled(order, eventHandler,
- expectedBandScanFreqs(WifiScanner.WIFI_BAND_24_GHZ), scanResults);
- verifyNoMoreInteractions(eventHandler);
-
- // Fail the PNO resume and check that the OnPnoScanFailed callback is invoked.
- order = inOrder(pnoEventHandler, mWifiNative);
- when(mWifiNative.startPnoScan(any(WifiNative.PnoSettings.class))).thenReturn(false);
- assertTrue("dispatch pno monitor alarm",
- mAlarmManager.dispatch(
- WificondScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
- assertEquals("dispatch message after alarm", 1, mLooper.dispatchAll());
- order.verify(pnoEventHandler).onPnoScanFailed();
- verifyNoMoreInteractions(pnoEventHandler);
-
- // Add a new PNO scan request
- startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
- assertTrue("dispatch pno monitor alarm",
- mAlarmManager.dispatch(
- WificondScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
- assertEquals("dispatch message after alarm", 1, mLooper.dispatchAll());
- expectSuccessfulHwDisconnectedPnoScan(order, pnoSettings, pnoEventHandler, scanResults);
- verifyNoMoreInteractions(pnoEventHandler);
- }
-
- /**
* Verify that the HW PNO scan stop failure still resets the PNO scan state.
* 1. Start Hw PNO.
* 2. Stop Hw PNO scan which raises a stop command to WifiNative which is failed.
@@ -205,17 +120,11 @@ public class WificondPnoScannerTest {
// Fail the PNO stop.
when(mWifiNative.stopPnoScan()).thenReturn(false);
assertTrue(mScanner.resetHwPnoList());
- assertTrue("dispatch pno monitor alarm",
- mAlarmManager.dispatch(
- WificondScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
mLooper.dispatchAll();
verify(mWifiNative).stopPnoScan();
// Add a new PNO scan request and ensure it runs successfully.
startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
- assertTrue("dispatch pno monitor alarm",
- mAlarmManager.dispatch(
- WificondScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
mLooper.dispatchAll();
InOrder order = inOrder(pnoEventHandler, mWifiNative);
ScanResults scanResults = createDummyScanResults(false);
@@ -223,84 +132,6 @@ public class WificondPnoScannerTest {
verifyNoMoreInteractions(pnoEventHandler);
}
- /**
- * Verify that the HW PNO scan is forcefully stopped (bypass debounce logic) and restarted when
- * settings change.
- * 1. Start Hw PNO.
- * 2. Stop Hw PNO .
- * 3. Now restart a new PNO scan with different settings.
- * 4. Ensure that the stop was issued before we start again.
- */
- @Test
- public void forceRestartHwDisconnectedPnoScanWhenSettingsChange() {
- createScannerWithHwPnoScanSupport();
-
- WifiNative.PnoEventHandler pnoEventHandler = mock(WifiNative.PnoEventHandler.class);
- WifiNative.PnoSettings pnoSettings = createDummyPnoSettings(false);
- InOrder order = inOrder(pnoEventHandler, mWifiNative);
-
- // Start PNO scan
- startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
- expectHwDisconnectedPnoScanStart(order, pnoSettings);
-
- // Stop PNO now. This should trigger the debounce timer and not stop PNO.
- assertTrue(mScanner.resetHwPnoList());
- assertTrue(mAlarmManager.isPending(
- WificondScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
- order.verify(mWifiNative, never()).stopPnoScan();
-
- // Now restart PNO scan with an extra network in settings.
- pnoSettings.networkList =
- Arrays.copyOf(pnoSettings.networkList, pnoSettings.networkList.length + 1);
- pnoSettings.networkList[pnoSettings.networkList.length - 1] =
- createDummyPnoNetwork("ssid_pno_new");
- startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
-
- // This should bypass the debounce timer and stop PNO scan immediately and then start
- // a new debounce timer for the start.
- order.verify(mWifiNative).stopPnoScan();
-
- // Trigger the debounce timer and ensure we start PNO scan again.
- mAlarmManager.dispatch(WificondScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG);
- mLooper.dispatchAll();
- order.verify(mWifiNative).startPnoScan(pnoSettings);
- }
-
- /**
- * Verify that the HW PNO scan is not forcefully stopped (bypass debounce logic) when
- * settings don't change.
- * 1. Start Hw PNO.
- * 2. Stop Hw PNO .
- * 3. Now restart a new PNO scan with same settings.
- * 4. Ensure that the stop was never issued.
- */
- @Test
- public void noForceRestartHwDisconnectedPnoScanWhenNoSettingsChange() {
- createScannerWithHwPnoScanSupport();
-
- WifiNative.PnoEventHandler pnoEventHandler = mock(WifiNative.PnoEventHandler.class);
- WifiNative.PnoSettings pnoSettings = createDummyPnoSettings(false);
- InOrder order = inOrder(pnoEventHandler, mWifiNative);
-
- // Start PNO scan
- startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
- expectHwDisconnectedPnoScanStart(order, pnoSettings);
-
- // Stop PNO now. This should trigger the debounce timer and not stop PNO.
- assertTrue(mScanner.resetHwPnoList());
- assertTrue(mAlarmManager.isPending(
- WificondScannerImpl.HwPnoDebouncer.PNO_DEBOUNCER_ALARM_TAG));
- order.verify(mWifiNative, never()).stopPnoScan();
-
- // Now restart PNO scan with the same settings.
- startSuccessfulPnoScan(null, pnoSettings, null, pnoEventHandler);
-
- // Trigger the debounce timer and ensure that we neither stop/start.
- mLooper.dispatchAll();
- order.verify(mWifiNative, never()).startPnoScan(any(WifiNative.PnoSettings.class));
- order.verify(mWifiNative, never()).stopPnoScan();
- }
-
private void createScannerWithHwPnoScanSupport() {
mResources.setBoolean(R.bool.config_wifi_background_scan_support, true);
mScanner = new WificondScannerImpl(mContext, mWifiNative, mWifiMonitor,
@@ -389,27 +220,4 @@ public class WificondPnoScannerTest {
order.verify(eventHandler).onPnoNetworkFound(scanResults.getRawScanResults());
}
- /**
- * Verify that the single scan results were delivered and that the PNO scan was paused and
- * resumed either side of it.
- */
- private void expectSuccessfulSingleScanWithHwPnoEnabled(InOrder order,
- WifiNative.ScanEventHandler eventHandler, Set<Integer> expectedScanFreqs,
- ScanResults scanResults) {
- // Pause PNO scan first
- order.verify(mWifiNative).stopPnoScan();
-
- order.verify(mWifiNative).scan(eq(expectedScanFreqs), any(Set.class));
-
- when(mWifiNative.getPnoScanResults()).thenReturn(scanResults.getScanDetailArrayList());
- when(mWifiNative.getScanResults()).thenReturn(scanResults.getScanDetailArrayList());
-
- // Notify scan has finished
- mWifiMonitor.sendMessage(mWifiNative.getInterfaceName(), WifiMonitor.SCAN_RESULTS_EVENT);
- assertEquals("dispatch message after results event", 1, mLooper.dispatchAll());
-
- order.verify(eventHandler).onScanStatus(WifiNative.WIFI_SCAN_RESULTS_AVAILABLE);
- assertScanDataEquals(scanResults.getScanData(), mScanner.getLatestSingleScanResults());
- }
-
}