diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-08-14 04:56:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-08-14 04:56:39 +0000 |
commit | 319ffa57dcac297d6abf7c492b55c369aff663b7 (patch) | |
tree | f251989f46407cadcf736b41ed570abc8d96e9b5 /tests | |
parent | a5dd8bd03bd02dd67f6853fb730948e401118afa (diff) | |
parent | b46e815669ba3f376f7dda2a24479f84bad0b4a8 (diff) |
Merge "WifiServiceImpl: Allow setWifiEnabled for system apps" into qt-qpr1-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 37 |
1 files changed, 37 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 af624da11..4f0ddc036 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -620,6 +620,24 @@ public class WifiServiceImplTest { } /** + * Verify that wifi can be enabled by the system apps targeting Q SDK. + */ + @Test + public void testSetWifiEnabledSuccessForSystemAppsTargetingQSDK() throws Exception { + doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) + .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); + when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), + eq(Build.VERSION_CODES.Q))).thenReturn(false); + mApplicationInfo.flags = ApplicationInfo.FLAG_SYSTEM; + + when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true); + when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); + assertTrue(mWifiServiceImpl.setWifiEnabled(TEST_PACKAGE_NAME, true)); + + verify(mWifiController).sendMessage(eq(CMD_WIFI_TOGGLED)); + } + + /** * Verify that wifi can be enabled by the apps targeting pre-Q SDK. */ @Test @@ -866,6 +884,25 @@ public class WifiServiceImplTest { } /** + * Verify that wifi can be disabled by the system apps targeting Q SDK. + */ + @Test + public void testSetWifiDisabledSuccessForSystemAppsTargetingQSDK() throws Exception { + doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) + .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); + when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), + eq(Build.VERSION_CODES.Q))).thenReturn(false); + mApplicationInfo.flags = ApplicationInfo.FLAG_SYSTEM; + + when(mSettingsStore.handleWifiToggled(eq(false))).thenReturn(true); + when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); + assertTrue(mWifiServiceImpl.setWifiEnabled(TEST_PACKAGE_NAME, false)); + + verify(mWifiController).sendMessage(eq(CMD_WIFI_TOGGLED)); + } + + + /** * Verify that wifi can be disabled by the apps targeting pre-Q SDK. */ @Test |