summaryrefslogtreecommitdiffstats
path: root/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2013-01-17 08:58:14 -0800
committerIrfan Sheriff <isheriff@google.com>2013-01-19 09:53:46 -0800
commite095675c872f40f630aa3f9189eb5c02f3cfee6d (patch)
tree22928f4eeb0c04801eaecd1f74f85f1ce0e5053b /wifi/java/android/net/wifi/WifiEnterpriseConfig.java
parentf2488b63283dca1d0bb9ca97961d9785ae2c64d8 (diff)
downloadframeworks_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/java/android/net/wifi/WifiEnterpriseConfig.java')
-rw-r--r--wifi/java/android/net/wifi/WifiEnterpriseConfig.java35
1 files changed, 21 insertions, 14 deletions
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;
}