From cc018db319baff34c9d36928d04c2c420257498f Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Tue, 22 Mar 2016 10:31:03 -0700 Subject: WifiConfigManager: Write ipconfig.txt for new configs We need to write the ipconfig.txt file for all new config additions. The |writeIpAndProxyConfigurationsOnChange| method is modified to force update the ipconfig.txt for new networks. While there, 1. Move the log indicating that we're updating ipconfig.txt to the place where we actually update the file. 2. Remove the redundant config change update broadcast from |writeIpAndProxyConfigurationsOnChange|. This is anyway being done in saveNetwork & addOrUpdateNetwork. BUG: 27697450 Change-Id: Ie2b8d51ed218ac8809a726ca169f2e61ef185593 TEST: Verified that the ipconfig.txt is written for new configs. --- .../com/android/server/wifi/WifiConfigManager.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 60abbca7e..b371bdd9a 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -2251,7 +2251,8 @@ public class WifiConfigManager { mConfiguredNetworks.put(currentConfig); - NetworkUpdateResult result = writeIpAndProxyConfigurationsOnChange(currentConfig, config); + NetworkUpdateResult result = + writeIpAndProxyConfigurationsOnChange(currentConfig, config, newNetwork); result.setIsNewNetwork(newNetwork); result.setNetworkId(netId); @@ -2850,16 +2851,11 @@ public class WifiConfigManager { /* Compare current and new configuration and write to file on change */ private NetworkUpdateResult writeIpAndProxyConfigurationsOnChange( WifiConfiguration currentConfig, - WifiConfiguration newConfig) { + WifiConfiguration newConfig, + boolean isNewNetwork) { boolean ipChanged = false; boolean proxyChanged = false; - if (VDBG) { - loge("writeIpAndProxyConfigurationsOnChange: " + currentConfig.SSID + " -> " + - newConfig.SSID + " path: " + ipConfigFile); - } - - switch (newConfig.getIpAssignment()) { case STATIC: if (currentConfig.getIpAssignment() != newConfig.getIpAssignment()) { @@ -2927,10 +2923,12 @@ public class WifiConfigManager { } } - if (ipChanged || proxyChanged) { + if (ipChanged || proxyChanged || isNewNetwork) { + if (VDBG) { + logd("writeIpAndProxyConfigurationsOnChange: " + currentConfig.SSID + " -> " + + newConfig.SSID + " path: " + ipConfigFile); + } writeIpAndProxyConfigurations(); - sendConfiguredNetworksChangedBroadcast(currentConfig, - WifiManager.CHANGE_REASON_CONFIG_CHANGE); } return new NetworkUpdateResult(ipChanged, proxyChanged); } -- cgit v1.2.3