diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java | 32 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java | 20 |
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 */ |