diff options
author | Roshan Pius <rpius@google.com> | 2020-04-22 16:07:13 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2020-04-22 16:11:31 -0700 |
commit | d3233e508ebb6c1919ec1dd1559e2516873f1611 (patch) | |
tree | d08b98a03614d48e67b1478b0e1ee22f00bb7d72 /tests | |
parent | b774c31798b0abe4910cd8658304fe12ae0b3160 (diff) |
WifiServiceImpl: Restore the system alert bypass for legacy API surface
This was prematurely removed in R even though we later changed that
decision.
Bug: 153615530
Test: atest com.android.server.wifi
Change-Id: I8373e0f287102dd3d29a1b7c2c7d4b75a8c36433
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index a11fc6dcb..45f49615a 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -4253,6 +4253,30 @@ public class WifiServiceImplTest extends WifiBaseTest { } /** + * Verify that add or update networks is allowed for apps holding system alert permission. + */ + @Test + public void testAddOrUpdateNetworkIsAllowedForAppsWithSystemAlertPermission() throws Exception { + doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) + .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); + when(mWifiConfigManager.addOrUpdateNetwork(any(), anyInt(), any())).thenReturn( + new NetworkUpdateResult(0)); + + when(mWifiPermissionsUtil.checkSystemAlertWindowPermission( + Process.myUid(), TEST_PACKAGE_NAME)).thenReturn(true); + + WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); + mLooper.startAutoDispatch(); + assertEquals(0, mWifiServiceImpl.addOrUpdateNetwork(config, TEST_PACKAGE_NAME)); + mLooper.stopAutoDispatchAndIgnoreExceptions(); + + verifyCheckChangePermission(TEST_PACKAGE_NAME); + verify(mWifiPermissionsUtil).checkSystemAlertWindowPermission(anyInt(), anyString()); + verify(mWifiConfigManager).addOrUpdateNetwork(any(), anyInt(), any()); + verify(mWifiMetrics).incrementNumAddOrUpdateNetworkCalls(); + } + + /** * Verify that add or update networks is allowed for DeviceOwner app. */ @Test |