Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45e6fec2 authored by Paul Stewart's avatar Paul Stewart
Browse files

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
parent c21f84dd
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -329,7 +329,8 @@ public class SettingsBackupAgent extends BackupAgentHelper {
        final HashSet<Network> mKnownNetworks = new HashSet<Network>();
        final ArrayList<Network> mNetworks = new ArrayList<Network>(8);

        public void readNetworks(BufferedReader in, List<WifiConfiguration> whitelist) {
        public void readNetworks(BufferedReader in, List<WifiConfiguration> 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:");