OSDN Git Service

Don't back up / restore EAP network definitions
authorChristopher Tate <ctate@google.com>
Wed, 18 Nov 2015 02:01:52 +0000 (18:01 -0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 20 Jul 2016 09:53:31 +0000 (17:53 +0800)
Bug 25725016

Change-Id: Idfef9dd53f2403bbe4c950493a0ab8fa66a3b7d4
(cherry picked from commit 9bc2f472e9cf204c737025b5d7101ba16c43b356)
Tracked-On: https://jira01.devtools.intel.com/browse/OAM-26648
Reviewed-on: https://android.intel.com:443/486879

packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java

index b9a9c24..2e96f18 100644 (file)
@@ -159,6 +159,7 @@ public class SettingsBackupAgent extends BackupAgentHelper {
         String key_mgmt = "";
         boolean certUsed = false;
         boolean hasWepKey = false;
+        boolean isEap = false;
         final ArrayList<String> rawLines = new ArrayList<String>();
 
         public static Network readFromStream(BufferedReader in) {
@@ -189,6 +190,9 @@ public class SettingsBackupAgent extends BackupAgentHelper {
                 ssid = line;
             } else if (line.startsWith("key_mgmt=")) {
                 key_mgmt = line;
+                if (line.contains("EAP")) {
+                    isEap = true;
+                }
             } else if (line.startsWith("client_cert=")) {
                 certUsed = true;
             } else if (line.startsWith("ca_cert=")) {
@@ -197,6 +201,8 @@ public class SettingsBackupAgent extends BackupAgentHelper {
                 certUsed = true;
             } else if (line.startsWith("wep_")) {
                 hasWepKey = true;
+            } else if (line.startsWith("eap=")) {
+                isEap = true;
             }
         }
 
@@ -325,6 +331,13 @@ public class SettingsBackupAgent extends BackupAgentHelper {
                                     continue;
                                 }
                             }
+                            // Don't propagate EAP network definitions
+                            if (net.isEap) {
+                                if (DEBUG_BACKUP) {
+                                    Log.v(TAG, "Skipping EAP network " + net.ssid + " / " + net.key_mgmt);
+                                }
+                                continue;
+                            }
                             if (! mKnownNetworks.contains(net)) {
                                 if (DEBUG_BACKUP) {
                                     Log.v(TAG, "Adding " + net.ssid + " / " + net.key_mgmt);
@@ -353,6 +366,12 @@ public class SettingsBackupAgent extends BackupAgentHelper {
                     continue;
                 }
 
+                if (net.isEap) {
+                    // Similarly, omit EAP network definitions to avoid propagating
+                    // controlled enterprise network definitions.
+                    continue;
+                }
+
                 net.write(w);
             }
         }