From 45e6fec2cfdb148b48100e65d9e7e207b8cdcf64 Mon Sep 17 00:00:00 2001 From: Paul Stewart Date: Fri, 20 May 2016 08:14:30 -0700 Subject: [PATCH] Don't remove existing EAP configurations When merging backed-up configurations with the current supplicant configuration, we read both configurations into a instance of WifiNetworkSettings. No EAP configurations should be restored as per b/25725016, however existing EAP configurations that already reside in wpa_supplicant.conf (presumably configured in SUW) should not be removed in the process. This CL adds a parameter to the "readNetworks" method to allow it to select whether or not EAP configurations should be read in. It is used to allow the "restoreWifiSupplicant" method to copy in EAP configurations from the existing wpa_supplicant.conf, but not out of the backup data. BUG: 28873992 Change-Id: I8b3e0c1a6629b3f1ca5055b1b2190e6b3ca4c033 --- .../providers/settings/SettingsBackupAgent.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index 029a1259cd1b6..f8fb1e5794461 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -329,7 +329,8 @@ public class SettingsBackupAgent extends BackupAgentHelper { final HashSet mKnownNetworks = new HashSet(); final ArrayList mNetworks = new ArrayList(8); - public void readNetworks(BufferedReader in, List whitelist) { + public void readNetworks(BufferedReader in, List whitelist, + boolean acceptEapNetworks) { try { String line; while (in.ready()) { @@ -348,7 +349,7 @@ public class SettingsBackupAgent extends BackupAgentHelper { } } // Don't propagate EAP network definitions - if (net.isEap) { + if (net.isEap && !acceptEapNetworks) { if (DEBUG_BACKUP) { Log.v(TAG, "Skipping EAP network " + net.ssid + " / " + net.key_mgmt); } @@ -1176,7 +1177,7 @@ public class SettingsBackupAgent extends BackupAgentHelper { WifiNetworkSettings fromFile = new WifiNetworkSettings(); br = new BufferedReader(new FileReader(file)); - fromFile.readNetworks(br, configs); + fromFile.readNetworks(br, configs, false); // Write the parsed networks into a packed byte array if (fromFile.mKnownNetworks.size() > 0) { @@ -1204,7 +1205,7 @@ public class SettingsBackupAgent extends BackupAgentHelper { if (supplicantFile.exists()) { // Retain the existing APs; we'll append the restored ones to them BufferedReader in = new BufferedReader(new FileReader(FILE_WIFI_SUPPLICANT)); - supplicantImage.readNetworks(in, null); + supplicantImage.readNetworks(in, null, true); in.close(); supplicantFile.delete(); @@ -1215,7 +1216,7 @@ public class SettingsBackupAgent extends BackupAgentHelper { char[] restoredAsBytes = new char[size]; for (int i = 0; i < size; i++) restoredAsBytes[i] = (char) bytes[i]; BufferedReader in = new BufferedReader(new CharArrayReader(restoredAsBytes)); - supplicantImage.readNetworks(in, null); + supplicantImage.readNetworks(in, null, false); if (DEBUG_BACKUP) { Log.v(TAG, "Final AP list:"); @@ -1371,4 +1372,4 @@ public class SettingsBackupAgent extends BackupAgentHelper { } return WifiManager.WIFI_STATE_UNKNOWN; } -} \ No newline at end of file +}