From 3239bf0036fc81d2b8a9da3ff31647915e1fc02d Mon Sep 17 00:00:00 2001 From: Nate Jiang Date: Wed, 18 Mar 2020 13:53:30 -0700 Subject: Fix user saved passpoint network user disable issue For user saved passpoint network, only enable that network when framework added network is a new network. Bug: 151763983 Test: atest com.android.server.wifi Change-Id: Ie309e5f7f79804c543d8f2d9573f900f3c5cfe79 --- .../com/android/server/wifi/WifiConfigManager.java | 6 +++-- .../android/server/wifi/WifiConfigManagerTest.java | 27 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index c4cb51c0b..03f6da3b1 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -1265,8 +1265,10 @@ public class WifiConfigManager { Log.e(TAG, "Failed to add network to config map", e); return new NetworkUpdateResult(WifiConfiguration.INVALID_NETWORK_ID); } - // Add or update user saved network or saved passpoint network will re-enable network. - if (!newInternalConfig.fromWifiNetworkSuggestion) { + // Only re-enable network: 1. add or update user saved network; 2. add or update a user + // saved passpoint network framework consider it is a new network. + if (!newInternalConfig.fromWifiNetworkSuggestion + && (!newInternalConfig.isPasspoint() || newNetwork)) { userEnabledNetwork(newInternalConfig.networkId); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 82addc2b3..d830015b4 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -4715,6 +4715,33 @@ public class WifiConfigManagerTest extends WifiBaseTest { assertFalse(mWifiConfigManager.isNetworkTemporarilyDisabledByUser(openNetwork.SSID)); } + @Test + public void testUserAddPasspointNetworkEnableNetwork() { + WifiConfiguration passpointNetwork = WifiConfigurationTestUtil.createPasspointNetwork(); + List networks = new ArrayList<>(); + networks.add(passpointNetwork); + mWifiConfigManager.userTemporarilyDisabledNetwork(passpointNetwork.FQDN); + assertTrue(mWifiConfigManager.isNetworkTemporarilyDisabledByUser(passpointNetwork.FQDN)); + // Add new passpoint network will enable the network. + NetworkUpdateResult result = addNetworkToWifiConfigManager(passpointNetwork); + assertTrue(result.getNetworkId() != WifiConfiguration.INVALID_NETWORK_ID); + assertTrue(result.isNewNetwork()); + + List retrievedNetworks = + mWifiConfigManager.getConfiguredNetworksWithPasswords(); + WifiConfigurationTestUtil.assertConfigurationsEqualForConfigManagerAddOrUpdate( + networks, retrievedNetworks); + assertFalse(mWifiConfigManager.isNetworkTemporarilyDisabledByUser(passpointNetwork.FQDN)); + + mWifiConfigManager.userTemporarilyDisabledNetwork(passpointNetwork.FQDN); + assertTrue(mWifiConfigManager.isNetworkTemporarilyDisabledByUser(passpointNetwork.FQDN)); + // Update a existing passpoint network will not enable network. + result = addNetworkToWifiConfigManager(passpointNetwork); + assertTrue(result.getNetworkId() != WifiConfiguration.INVALID_NETWORK_ID); + assertFalse(result.isNewNetwork()); + assertTrue(mWifiConfigManager.isNetworkTemporarilyDisabledByUser(passpointNetwork.FQDN)); + } + private void verifyExpiryOfTimeout(WifiConfiguration config) { // Disable the ephemeral network. long disableTimeMs = 546643L; -- cgit v1.2.3