diff options
author | Irfan Sheriff <isheriff@google.com> | 2013-01-17 08:58:14 -0800 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2013-01-19 09:53:46 -0800 |
commit | e095675c872f40f630aa3f9189eb5c02f3cfee6d (patch) | |
tree | 22928f4eeb0c04801eaecd1f74f85f1ce0e5053b /wifi | |
parent | f2488b63283dca1d0bb9ca97961d9785ae2c64d8 (diff) | |
download | frameworks_base-e095675c872f40f630aa3f9189eb5c02f3cfee6d.zip frameworks_base-e095675c872f40f630aa3f9189eb5c02f3cfee6d.tar.gz frameworks_base-e095675c872f40f630aa3f9189eb5c02f3cfee6d.tar.bz2 |
eix enterprise config storage bugs
Reading empty and not updating was resulting in retaining old values
in a config. Also, fix matching phase2 entries.
Additionally, allow configuring subset of enterprise fields. Necessary
since password cannot be read back from supplicant.
Change-Id: I83a01690a0cf7cad1457a674f50f1e3a1a0441b5
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 35 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiEnterpriseConfig.java | 35 |
2 files changed, 42 insertions, 28 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index ac53eb2..66c2f3f 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -1089,17 +1089,19 @@ class WifiConfigStore { break setVariables; } - HashMap<String, String> enterpriseFields = config.enterpriseConfig.getFields(); - for (String key : enterpriseFields.keySet()) { - String value = enterpriseFields.get(key); - if (!mWifiNative.setNetworkVariable( - netId, - key, - value)) { - loge(config.SSID + ": failed to set " + key + - ": " + value); - break setVariables; - } + if (config.enterpriseConfig != null) { + HashMap<String, String> enterpriseFields = config.enterpriseConfig.getFields(); + for (String key : enterpriseFields.keySet()) { + String value = enterpriseFields.get(key); + if (!mWifiNative.setNetworkVariable( + netId, + key, + value)) { + loge(config.SSID + ": failed to set " + key + + ": " + value); + break setVariables; + } + } } updateFailed = false; } @@ -1398,11 +1400,16 @@ class WifiConfigStore { } } - HashMap<String, String> entepriseFields = config.enterpriseConfig.getFields(); - for (String key : entepriseFields.keySet()) { + if (config.enterpriseConfig == null) { + config.enterpriseConfig = new WifiEnterpriseConfig(); + } + HashMap<String, String> enterpriseFields = config.enterpriseConfig.getFields(); + for (String key : WifiEnterpriseConfig.getSupplicantKeys()) { value = mWifiNative.getNetworkVariable(netId, key); if (!TextUtils.isEmpty(value)) { - entepriseFields.put(key, removeDoubleQuotes(value)); + enterpriseFields.put(key, removeDoubleQuotes(value)); + } else { + enterpriseFields.put(key, WifiEnterpriseConfig.EMPTY_VALUE); } } diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java index 46e446e..4dca7ac 100644 --- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java +++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java @@ -74,18 +74,14 @@ public class WifiEnterpriseConfig implements Parcelable { /** This represents an empty value of an enterprise field. * NULL is used at wpa_supplicant to indicate an empty value */ - private static final String EMPTY_VALUE = "NULL"; + static final String EMPTY_VALUE = "NULL"; public WifiEnterpriseConfig() { - // Set the required defaults - mFields.put(EAP_KEY, Eap.strings[Eap.PEAP]); - mFields.put(ENGINE_KEY, ENGINE_DISABLE); + // Do not set defaults so that the enterprise fields that are not changed + // by API are not changed underneath + // This is essential because an app may not have all fields like password + // available. It allows modification of subset of fields. - for (String key : new String[] {PHASE2_KEY, IDENTITY_KEY, ANON_IDENTITY_KEY, - PASSWORD_KEY, CLIENT_CERT_KEY, ENGINE_ID_KEY, PRIVATE_KEY_ID_KEY, - CA_CERT_KEY, SUBJECT_MATCH_KEY}) { - mFields.put(key, EMPTY_VALUE); - } } /** Copy constructor */ @@ -128,6 +124,8 @@ public class WifiEnterpriseConfig implements Parcelable { }; public static final class Eap { + /* NONE represents an empty enterprise config */ + public static final int NONE = -1; public static final int PEAP = 0; public static final int TLS = 1; public static final int TTLS = 2; @@ -152,6 +150,13 @@ public class WifiEnterpriseConfig implements Parcelable { return mFields; } + /** Internal use only @hide */ + public static String[] getSupplicantKeys() { + return new String[] { EAP_KEY, PHASE2_KEY, IDENTITY_KEY, ANON_IDENTITY_KEY, PASSWORD_KEY, + CLIENT_CERT_KEY, CA_CERT_KEY, SUBJECT_MATCH_KEY, ENGINE_KEY, ENGINE_ID_KEY, + PRIVATE_KEY_ID_KEY }; + } + /** * Set the EAP authentication method. * @param eapMethod is one {@link Eap#PEAP}, {@link Eap#TLS}, {@link Eap#TTLS} or @@ -177,7 +182,7 @@ public class WifiEnterpriseConfig implements Parcelable { */ public int getEapMethod() { String eapMethod = mFields.get(EAP_KEY); - return getStringIndex(Eap.strings, eapMethod, Eap.PEAP); + return getStringIndex(Eap.strings, eapMethod, Eap.NONE); } /** @@ -211,7 +216,11 @@ public class WifiEnterpriseConfig implements Parcelable { * @return a phase 2 method defined at {@link Phase2} * */ public int getPhase2Method() { - String phase2Method = mFields.get(PHASE2_KEY); + String phase2Method = removeDoubleQuotes(mFields.get(PHASE2_KEY)); + // Remove auth= prefix + if (phase2Method.startsWith(Phase2.PREFIX)) { + phase2Method = phase2Method.substring(Phase2.PREFIX.length()); + } return getStringIndex(Phase2.strings, phase2Method, Phase2.NONE); } @@ -387,9 +396,7 @@ public class WifiEnterpriseConfig implements Parcelable { */ private int getStringIndex(String arr[], String toBeFound, int defaultIndex) { for (int i = 0; i < arr.length; i++) { - // toBeFound can be formatted with a prefix. For example, phase2 - // string has "auth=" as the prefix. - if (toBeFound.contains(arr[i])) return i; + if (toBeFound.equals(arr[i])) return i; } return defaultIndex; } |