diff options
-rw-r--r-- | service/java/com/android/server/wifi/NetworkSuggestionNominator.java | 21 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java | 12 |
2 files changed, 16 insertions, 17 deletions
diff --git a/service/java/com/android/server/wifi/NetworkSuggestionNominator.java b/service/java/com/android/server/wifi/NetworkSuggestionNominator.java index 61afce1ea..bc5873484 100644 --- a/service/java/com/android/server/wifi/NetworkSuggestionNominator.java +++ b/service/java/com/android/server/wifi/NetworkSuggestionNominator.java @@ -177,8 +177,8 @@ public class NetworkSuggestionNominator implements WifiNetworkSelector.NetworkNo ExtendedWifiNetworkSuggestion matchingExtNetworkSuggestion = matchingExtNetworkSuggestionsFromSamePackage.stream().findFirst().get(); // Update the WifiConfigManager with the latest WifiConfig - WifiConfiguration config = createConfigForAddingToWifiConfigManager( - matchingExtNetworkSuggestion, true); + WifiConfiguration config = + matchingExtNetworkSuggestion.createInternalWifiConfiguration(); NetworkUpdateResult result = mWifiConfigManager.addOrUpdateNetwork( config, matchingExtNetworkSuggestion.perAppInfo.uid, @@ -224,8 +224,7 @@ public class NetworkSuggestionNominator implements WifiNetworkSelector.NetworkNo if (!ewns.wns.isUserAllowedToManuallyConnect) { continue; } - WifiConfiguration config = - createConfigForAddingToWifiConfigManager(ewns, false); + WifiConfiguration config = ewns.createInternalWifiConfiguration(); WifiConfiguration wCmConfiguredNetwork = mWifiConfigManager.getConfiguredNetwork(config.getKey()); NetworkUpdateResult result = mWifiConfigManager.addOrUpdateNetwork( @@ -256,8 +255,7 @@ public class NetworkSuggestionNominator implements WifiNetworkSelector.NetworkNo // Returns the copy of WifiConfiguration with the allocated network ID filled in. private WifiConfiguration addCandidateToWifiConfigManager( @NonNull ExtendedWifiNetworkSuggestion ewns) { - WifiConfiguration wifiConfiguration = - createConfigForAddingToWifiConfigManager(ewns, true); + WifiConfiguration wifiConfiguration = ewns.createInternalWifiConfiguration(); NetworkUpdateResult result = mWifiConfigManager.addOrUpdateNetwork(wifiConfiguration, ewns.perAppInfo.uid, ewns.perAppInfo.packageName); @@ -274,17 +272,6 @@ public class NetworkSuggestionNominator implements WifiNetworkSelector.NetworkNo return mWifiConfigManager.getConfiguredNetwork(candidateNetworkId); } - private WifiConfiguration createConfigForAddingToWifiConfigManager( - ExtendedWifiNetworkSuggestion ewns, boolean allowAutojoin) { - WifiConfiguration wifiConfiguration = new WifiConfiguration(ewns.wns.wifiConfiguration); - // Mark the network ephemeral because we don't want these persisted by WifiConfigManager. - wifiConfiguration.ephemeral = true; - wifiConfiguration.fromWifiNetworkSuggestion = true; - wifiConfiguration.allowAutojoin = allowAutojoin; - wifiConfiguration.trusted = !ewns.wns.isNetworkUntrusted; - return wifiConfiguration; - } - @Override public @NominatorId int getId() { return NOMINATOR_ID_SUGGESTION; diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java index 176625087..ad7dc7abb 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java +++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java @@ -268,6 +268,18 @@ public class WifiNetworkSuggestionsManager { @NonNull PerAppInfo perAppInfo, boolean isAutoJoinEnabled) { return new ExtendedWifiNetworkSuggestion(wns, perAppInfo, isAutoJoinEnabled); } + + /** + * Create a {@link WifiConfiguration} from suggestion for framework internal use. + */ + public WifiConfiguration createInternalWifiConfiguration() { + WifiConfiguration config = new WifiConfiguration(wns.getWifiConfiguration()); + config.ephemeral = true; + config.fromWifiNetworkSuggestion = true; + config.allowAutojoin = isAutojoinEnabled; + config.trusted = !wns.isNetworkUntrusted; + return config; + } } /** |