summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-08-23 03:40:33 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-08-23 03:40:33 +0000
commit6c3ff83eaa491a9cf54140d718bc114efd45e19f (patch)
tree8edfadbf0065b743008c2f57c35dc02756e87164
parentd0488bb459312e3ba198490b7df7c80996b712d1 (diff)
parent32a993fb54905edc9d14ef6768856089a805e556 (diff)
Merge cherrypicks of [9256784, 9257496, 9256447] into qt-release
Change-Id: Ia436c880379a9b49361ac6622da60ab22e0c6c00
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java37
2 files changed, 39 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 6bb36b3b9..a4639924b 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -875,7 +875,8 @@ public class WifiServiceImpl extends BaseWifiService {
}
boolean isPrivileged = isPrivileged(Binder.getCallingPid(), Binder.getCallingUid());
if (!isPrivileged
- && !mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q)) {
+ && !mWifiPermissionsUtil.isTargetSdkLessThan(packageName, Build.VERSION_CODES.Q)
+ && !isSystem(packageName)) {
mLog.info("setWifiEnabled not allowed for uid=%")
.c(Binder.getCallingUid()).flush();
return false;
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index b69fba78b..378d6cf2e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -600,6 +600,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
@@ -812,6 +830,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