summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-04-26 21:22:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-04-26 21:22:32 +0000
commit5d028baa92b741ffcf82363c6983c208482d3f29 (patch)
treecf732ac6f6397b156f56cd33c7e9da4b8e1b8e82 /tests
parent7daee3fabb13a50a788fb2eb7aaec1f9ebc62efc (diff)
parent0a8b73a22306e8644d4ca3afdb42f9d94a9efc8d (diff)
Merge "ScanRequestProxy: Bypass scan throttling for setup wizard" into pi-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java32
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java20
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java b/tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java
index b42f53648..e18429599 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java
@@ -147,6 +147,18 @@ public class ScanRequestProxyTest {
validateScanSettings(mScanSettingsArgumentCaptor.getValue(), false, true);
}
+ /**
+ * Verify scan request will forwarded to wifiscanner if wifiscanner is present.
+ */
+ @Test
+ public void testStartScanSuccessFromAppWithNetworkSetupWizard() {
+ when(mWifiPermissionsUtil.checkNetworkSetupWizardPermission(TEST_UID)).thenReturn(true);
+ assertTrue(mScanRequestProxy.startScan(TEST_UID, TEST_PACKAGE_NAME_1));
+ mInOrder.verify(mWifiScanner).startScan(any(), any(), any());
+
+ assertTrue(mWorkSourceArgumentCaptor.getValue().equals(new WorkSource(TEST_UID)));
+ validateScanSettings(mScanSettingsArgumentCaptor.getValue(), false, true);
+ }
/**
* Verify that hidden network list is not retrieved when hidden network scanning is disabled.
@@ -529,6 +541,26 @@ public class ScanRequestProxyTest {
}
/**
+ * Ensure new scan requests from the same app with NETWORK_SETUP_WIZARD permission are not
+ * throttled.
+ */
+ @Test
+ public void testSuccessiveScanRequestFromSameAppWithNetworkSetupWizardPermissionNotThrottled() {
+ when(mWifiPermissionsUtil.checkNetworkSetupWizardPermission(TEST_UID)).thenReturn(true);
+
+ long firstRequestMs = 782;
+ when(mClock.getElapsedSinceBootMillis()).thenReturn(firstRequestMs);
+ for (int i = 0; i < SCAN_REQUEST_THROTTLE_MAX_IN_TIME_WINDOW_FG_APPS; i++) {
+ when(mClock.getElapsedSinceBootMillis()).thenReturn(firstRequestMs + i);
+ assertTrue(mScanRequestProxy.startScan(TEST_UID, TEST_PACKAGE_NAME_1));
+ mInOrder.verify(mWifiScanner).startScan(any(), any(), any());
+ }
+ // Make next scan request from the same package name & ensure that it is not throttled.
+ assertTrue(mScanRequestProxy.startScan(TEST_UID, TEST_PACKAGE_NAME_1));
+ mInOrder.verify(mWifiScanner).startScan(any(), any(), any());
+ }
+
+ /**
* Ensure new scan requests from different apps are not throttled.
*/
@Test
diff --git a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
index bfe660c9d..1e7bbd284 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
@@ -474,6 +474,26 @@ public class WifiPermissionsUtilTest {
}
/**
+ * Verifies the helper method exposed for checking NETWORK_SETUP_WIZARD permission.
+ */
+ @Test
+ public void testCheckNetworkSetupWizard() throws Exception {
+ setupMocks();
+ WifiPermissionsUtil wifiPermissionsUtil = new WifiPermissionsUtil(mMockPermissionsWrapper,
+ mMockContext, mMockWifiSettingsStore, mMockUserManager, mWifiInjector);
+
+ when(mMockPermissionsWrapper.getUidPermission(
+ android.Manifest.permission.NETWORK_SETUP_WIZARD, MANAGED_PROFILE_UID))
+ .thenReturn(PackageManager.PERMISSION_DENIED);
+ assertFalse(wifiPermissionsUtil.checkNetworkSetupWizardPermission(MANAGED_PROFILE_UID));
+
+ when(mMockPermissionsWrapper.getUidPermission(
+ android.Manifest.permission.NETWORK_SETUP_WIZARD, MANAGED_PROFILE_UID))
+ .thenReturn(PackageManager.PERMISSION_GRANTED);
+ assertTrue(wifiPermissionsUtil.checkNetworkSetupWizardPermission(MANAGED_PROFILE_UID));
+ }
+
+ /**
* Test case setting: caller does not have Location permission.
* Expect a SecurityException
*/