diff options
author | Antoan Angelov <arangelov@google.com> | 2020-06-24 18:45:18 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-24 18:45:18 +0000 |
commit | 0c1240fbf6e6043f1e59757923ea2a8e079ebae5 (patch) | |
tree | aa162a6297f9079b38afedf477902964e5995b6b | |
parent | f5a1794ec14fe6c329e6ed0af630c698fb94416c (diff) | |
parent | 273c4e562d1cdbed562811c617b56b568883bd39 (diff) |
Merge "Allow NETWORK_MANAGED_PROVISIONING to modify proxy settings." into rvc-dev am: 273c4e562d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/wifi/+/11971138
Change-Id: I7a54fe8fb60cdfdac774d8402bc0aed0ad9cae28
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 4 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 36 |
2 files changed, 36 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 99de9277e..6d04b7a68 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -3240,9 +3240,11 @@ public class WifiConfigManager { mWifiPermissionsUtil.checkNetworkSettingsPermission(uid); final boolean hasNetworkSetupWizardPermission = mWifiPermissionsUtil.checkNetworkSetupWizardPermission(uid); + final boolean hasNetworkManagedProvisioningPermission = + mWifiPermissionsUtil.checkNetworkManagedProvisioningPermission(uid); // If |uid| corresponds to the device owner, allow all modifications. if (isProfileOwner || isDeviceOwner || hasNetworkSettingsPermission - || hasNetworkSetupWizardPermission) { + || hasNetworkSetupWizardPermission || hasNetworkManagedProvisioningPermission) { return true; } if (mVerboseLoggingEnabled) { diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 815b3ad0b..d2584adbc 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -4003,6 +4003,33 @@ public class WifiConfigManagerTest extends WifiBaseTest { true, // assertSuccess WifiConfiguration.INVALID_NETWORK_ID); // Update networkID } + + /** + * Verifies that adding a network with a PAC or STATIC proxy, while having the + * {@link android.Manifest.permission#NETWORK_MANAGED_PROVISIONING} permission is successful + */ + @Test + public void testAddNetworkWithProxyWithNetworkManagedPermission() { + verifyAddOrUpdateNetworkWithProxySettingsAndPermissions( + false, // withNetworkSettings + false, // withNetworkSetupWizard + true, // withNetworkManagedProvisioning + false, // withProfileOwnerPolicy + false, // withDeviceOwnerPolicy + WifiConfigurationTestUtil.createDHCPIpConfigurationWithPacProxy(), + true, // assertSuccess + WifiConfiguration.INVALID_NETWORK_ID); // Update networkID + verifyAddOrUpdateNetworkWithProxySettingsAndPermissions( + false, // withNetworkSettings + false, // withNetworkSetupWizard + true, // withNetworkManagedProvisioning + false, // withProfileOwnerPolicy + false, // withDeviceOwnerPolicy + WifiConfigurationTestUtil.createDHCPIpConfigurationWithStaticProxy(), + true, // assertSuccess + WifiConfiguration.INVALID_NETWORK_ID); // Update networkID + } + /** * Verifies that updating a network (that has no proxy) and adding a PAC or STATIC proxy fails * without being able to override configs, or holding Device or Profile owner policies. @@ -4052,7 +4079,7 @@ public class WifiConfigManagerTest extends WifiBaseTest { verifyAddOrUpdateNetworkWithProxySettingsAndPermissions( false, // withNetworkSettings true, // withNetworkSetupWizard - false, // withProfileOwnerPolicy + false, false, // withProfileOwnerPolicy false, // withDeviceOwnerPolicy WifiConfigurationTestUtil.createDHCPIpConfigurationWithPacProxy(), true, // assertSuccess @@ -4633,13 +4660,14 @@ public class WifiConfigManagerTest extends WifiBaseTest { boolean assertSuccess, int networkId) { return verifyAddOrUpdateNetworkWithProxySettingsAndPermissions(withNetworkSettings, - false, withProfileOwnerPolicy, withDeviceOwnerPolicy, ipConfiguration, + false, false, withProfileOwnerPolicy, withDeviceOwnerPolicy, ipConfiguration, assertSuccess, networkId); } private NetworkUpdateResult verifyAddOrUpdateNetworkWithProxySettingsAndPermissions( boolean withNetworkSettings, boolean withNetworkSetupWizard, + boolean withNetworkManagedProvisioning, boolean withProfileOwnerPolicy, boolean withDeviceOwnerPolicy, IpConfiguration ipConfiguration, @@ -4660,7 +4688,9 @@ public class WifiConfigManagerTest extends WifiBaseTest { .thenReturn(withNetworkSettings); when(mWifiPermissionsUtil.checkNetworkSetupWizardPermission(anyInt())) .thenReturn(withNetworkSetupWizard); - int uid = withNetworkSettings || withNetworkSetupWizard + when(mWifiPermissionsUtil.checkNetworkManagedProvisioningPermission(anyInt())) + .thenReturn(withNetworkManagedProvisioning); + int uid = withNetworkSettings || withNetworkSetupWizard || withNetworkManagedProvisioning ? TEST_CREATOR_UID : TEST_NO_PERM_UID; NetworkUpdateResult result = addNetworkToWifiConfigManager(network, uid); |