diff options
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 9 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 25 |
2 files changed, 34 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 48dfc2fd1..eaa6a107a 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -34,6 +34,7 @@ import android.net.wifi.WifiEnterpriseConfig; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.net.wifi.WifiScanner; +import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; @@ -613,6 +614,14 @@ public class WifiConfigManager { * @param ignoreLockdown Ignore the configuration lockdown checks for connection attempts. */ private boolean canModifyNetwork(WifiConfiguration config, int uid, boolean ignoreLockdown) { + // Passpoint configurations are generated and managed by PasspointManager. They can be + // added by either PasspointNetworkEvaluator (for auto connection) or Settings app + // (for manual connection), and need to be removed once the connection is completed. + // Since it is "owned" by us, so always allow us to modify them. + if (config.isPasspoint() && uid == Process.WIFI_UID) { + return true; + } + final DevicePolicyManagerInternal dpmi = LocalServices.getService( DevicePolicyManagerInternal.class); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 61c74180e..20b89dfc3 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -35,6 +35,7 @@ import android.net.wifi.WifiEnterpriseConfig; import android.net.wifi.WifiManager; import android.net.wifi.WifiScanner; import android.net.wifi.WifiSsid; +import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.telephony.TelephonyManager; @@ -477,6 +478,30 @@ public class WifiConfigManagerTest { } /** + * Verify that a Passpoint network that's added by an app with {@link #TEST_CREATOR_UID} can + * be removed by WiFi Service with {@link Process#WIFI_UID}. + * + * @throws Exception + */ + @Test + public void testRemovePasspointNetworkAddedByOther() throws Exception { + WifiConfiguration passpointNetwork = WifiConfigurationTestUtil.createPasspointNetwork(); + + // Passpoint network is added using TEST_CREATOR_UID. + verifyAddPasspointNetworkToWifiConfigManager(passpointNetwork); + // Ensure that configured network list is not empty. + assertFalse(mWifiConfigManager.getConfiguredNetworks().isEmpty()); + + assertTrue(mWifiConfigManager.removeNetwork(passpointNetwork.networkId, Process.WIFI_UID)); + + // Verify keys are not being removed. + verify(mWifiKeyStore, never()).removeKeys(any(WifiEnterpriseConfig.class)); + verifyNetworkRemoveBroadcast(passpointNetwork); + // Ensure that the write was not invoked for Passpoint network remove. + mContextConfigStoreMockOrder.verify(mWifiConfigStore, never()).write(anyBoolean()); + + } + /** * Verifies the addition & update of multiple networks using * {@link WifiConfigManager#addOrUpdateNetwork(WifiConfiguration, int)} and the * removal of networks using |