diff options
author | Roshan Pius <rpius@google.com> | 2020-05-28 22:45:34 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-05-28 22:45:34 +0000 |
commit | f8ee42f7b6e2600a7de0c779d054293698ecd877 (patch) | |
tree | 99509688a0cd336e09742935b9d10d5226d5f46f | |
parent | 75f16940174b144426004977efaead4a95a1e6a0 (diff) | |
parent | e8c065166a74a62ce5ed0533e997e3a63cab6ae9 (diff) |
Merge "WifiBackupRestore: Parse auth_alg from supplicant backup data" into rvc-dev
-rw-r--r-- | service/java/com/android/server/wifi/WifiBackupRestore.java | 15 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java | 12 |
2 files changed, 26 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiBackupRestore.java b/service/java/com/android/server/wifi/WifiBackupRestore.java index c55236ee4..ab46bb62f 100644 --- a/service/java/com/android/server/wifi/WifiBackupRestore.java +++ b/service/java/com/android/server/wifi/WifiBackupRestore.java @@ -466,6 +466,8 @@ public class WifiBackupRestore { public static final String SUPPLICANT_KEY_SSID = WifiConfiguration.ssidVarName; public static final String SUPPLICANT_KEY_HIDDEN = WifiConfiguration.hiddenSSIDVarName; public static final String SUPPLICANT_KEY_KEY_MGMT = WifiConfiguration.KeyMgmt.varName; + public static final String SUPPLICANT_KEY_AUTH_ALG = + WifiConfiguration.AuthAlgorithm.varName; public static final String SUPPLICANT_KEY_CLIENT_CERT = WifiEnterpriseConfig.CLIENT_CERT_KEY; public static final String SUPPLICANT_KEY_CA_CERT = WifiEnterpriseConfig.CA_CERT_KEY; @@ -535,6 +537,7 @@ public class WifiBackupRestore { private String mParsedSSIDLine; private String mParsedHiddenLine; private String mParsedKeyMgmtLine; + private String mParsedAuthAlgLine; private String mParsedPskLine; private String[] mParsedWepKeyLines = new String[4]; private String mParsedWepTxKeyIdxLine; @@ -581,6 +584,8 @@ public class WifiBackupRestore { if (line.contains("EAP")) { isEap = true; } + } else if (line.startsWith(SUPPLICANT_KEY_AUTH_ALG + "=")) { + mParsedAuthAlgLine = line; } else if (line.startsWith(SUPPLICANT_KEY_CLIENT_CERT + "=")) { certUsed = true; } else if (line.startsWith(SUPPLICANT_KEY_CA_CERT + "=")) { @@ -660,6 +665,16 @@ public class WifiBackupRestore { } } } + if (mParsedAuthAlgLine != null) { + if (mParsedAuthAlgLine.contains("OPEN")) { + configuration.allowedAuthAlgorithms.set( + WifiConfiguration.AuthAlgorithm.OPEN); + } + if (mParsedAuthAlgLine.contains("SHARED")) { + configuration.allowedAuthAlgorithms.set( + WifiConfiguration.AuthAlgorithm.SHARED); + } + } if (mParsedPskLine != null) { configuration.preSharedKey = mParsedPskLine.substring(mParsedPskLine.indexOf('=') + 1); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java index a2a1a4595..6b01f8e45 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java @@ -832,11 +832,13 @@ public class WifiBackupRestoreTest extends WifiBaseTest { List<WifiConfiguration> configurations = new ArrayList<>(); WifiConfiguration wepNetwork = WifiConfigurationTestUtil.createWepNetwork(); + wepNetwork.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); wepNetwork.setIpConfiguration( WifiConfigurationTestUtil.createDHCPIpConfigurationWithPacProxy()); configurations.add(wepNetwork); WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork(); + pskNetwork.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); pskNetwork.setIpConfiguration( WifiConfigurationTestUtil.createStaticIpConfigurationWithPacProxy()); configurations.add(pskNetwork); @@ -1113,10 +1115,10 @@ public class WifiBackupRestoreTest extends WifiBaseTest { throws IOException { out.write("network={\n"); out.write(" " + "ssid=" + configuration.SSID + "\n"); - String allowedKeyManagement = ""; if (configuration.hiddenSSID) { out.write(" " + "scan_ssid=1" + "\n"); } + String allowedKeyManagement = ""; if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.NONE)) { allowedKeyManagement += "NONE"; } @@ -1130,6 +1132,14 @@ public class WifiBackupRestoreTest extends WifiBaseTest { allowedKeyManagement += "IEEE8021X "; } out.write(" " + "key_mgmt=" + allowedKeyManagement + "\n"); + String allowedAuthAlgorithm = ""; + if (configuration.allowedAuthAlgorithms.get(WifiConfiguration.AuthAlgorithm.OPEN)) { + allowedAuthAlgorithm += "OPEN "; + } + if (configuration.allowedAuthAlgorithms.get(WifiConfiguration.AuthAlgorithm.SHARED)) { + allowedAuthAlgorithm += "SHARED "; + } + out.write(" " + "auth_alg=" + allowedAuthAlgorithm + "\n"); if (configuration.preSharedKey != null) { out.write(" " + "psk=" + configuration.preSharedKey + "\n"); } |