Update the WifiConfig each time evalutor return a candidate.

Bug: 145020223
Test: atest android.net.wifi
Test: atest com.android.server.wifi

Merged-In: I2b454af0cb2850c86d142ec170b1c3de7724121f
Change-Id: I2b454af0cb2850c86d142ec170b1c3de7724121f
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java
index ec8a009..148af39 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java
@@ -231,24 +231,20 @@
         if (existingNetwork != null) {
             WifiConfiguration.NetworkSelectionStatus status =
                     existingNetwork.getNetworkSelectionStatus();
-            if (!status.isNetworkEnabled()) {
-                boolean isSuccess = mWifiConfigManager.tryEnableNetwork(existingNetwork.networkId);
-                if (isSuccess) {
-                    return existingNetwork;
-                }
+            if (!status.isNetworkEnabled()
+                    && !mWifiConfigManager.tryEnableNetwork(existingNetwork.networkId)) {
                 localLog("Current configuration for the Passpoint AP " + config.SSID
                         + " is disabled, skip this candidate");
                 return null;
             }
-            return existingNetwork;
         }
 
-        // Add the newly created WifiConfiguration to WifiConfigManager.
+        // Add or update with the newly created WifiConfiguration to WifiConfigManager.
         NetworkUpdateResult result =
                 mWifiConfigManager.addOrUpdateNetwork(config, Process.WIFI_UID);
         if (!result.isSuccess()) {
             localLog("Failed to add passpoint network");
-            return null;
+            return existingNetwork;
         }
         mWifiConfigManager.enableNetwork(result.getNetworkId(), false, Process.WIFI_UID);
         mWifiConfigManager.setNetworkCandidateScanResult(result.getNetworkId(),