Merge "Fix connectivitymanagertest"

This commit is contained in:
Irfan Sheriff
2013-01-15 10:36:40 -08:00
committed by Android (Google) Code Review

View File

@@ -28,6 +28,7 @@ import android.net.wifi.WifiConfiguration.AuthAlgorithm;
import android.net.wifi.WifiConfiguration.IpAssignment; import android.net.wifi.WifiConfiguration.IpAssignment;
import android.net.wifi.WifiConfiguration.KeyMgmt; import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiConfiguration.ProxySettings; import android.net.wifi.WifiConfiguration.ProxySettings;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.LinkAddress; import android.net.LinkAddress;
import android.net.LinkProperties; import android.net.LinkProperties;
import android.net.RouteInfo; import android.net.RouteInfo;
@@ -67,7 +68,6 @@ import java.util.List;
* networkprefixlength. * networkprefixlength.
*/ */
public class AccessPointParserHelper { public class AccessPointParserHelper {
private static final String KEYSTORE_SPACE = "keystore://";
private static final String TAG = "AccessPointParserHelper"; private static final String TAG = "AccessPointParserHelper";
static final int NONE = 0; static final int NONE = 0;
static final int WEP = 1; static final int WEP = 1;
@@ -212,14 +212,11 @@ public class AccessPointParserHelper {
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP); config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X); config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
// Initialize other fields. // Initialize other fields.
config.phase2.setValue(""); config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE);
config.ca_cert.setValue(""); config.enterpriseConfig.setCaCertificate("");
config.client_cert.setValue(""); config.enterpriseConfig.setClientCertificate("");
config.engine.setValue(""); config.enterpriseConfig.setIdentity("");
config.engine_id.setValue(""); config.enterpriseConfig.setAnonymousIdentity("");
config.key_id.setValue("");
config.identity.setValue("");
config.anonymous_identity.setValue("");
break; break;
default: default:
throw new SAXException(); throw new SAXException();
@@ -246,7 +243,7 @@ public class AccessPointParserHelper {
config.preSharedKey = '"' + passwordStr + '"'; config.preSharedKey = '"' + passwordStr + '"';
} }
} else if (securityType == EAP) { } else if (securityType == EAP) {
config.password.setValue(passwordStr); config.enterpriseConfig.setPassword(passwordStr);
} else { } else {
throw new SAXException(); throw new SAXException();
} }
@@ -257,33 +254,46 @@ public class AccessPointParserHelper {
if (!validateEapValue(eapValue)) { if (!validateEapValue(eapValue)) {
throw new SAXException(); throw new SAXException();
} }
config.eap.setValue(eapValue); if (eapValue.equals("TLS")) {
config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS);
} else if (eapValue.equals("TTLS")) {
config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TTLS);
} else if (eapValue.equals("PEAP")) {
config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.PEAP);
}
eap = false; eap = false;
} }
if (phase2) { if (phase2) {
String phase2Value = new String(ch, start, length); String phase2Value = new String(ch, start, length);
config.phase2.setValue("auth=" + phase2Value); if (phase2Value.equals("PAP")) {
config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.PAP);
} else if (phase2Value.equals("MSCHAP")) {
config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.MSCHAP);
} else if (phase2Value.equals("MSCHAPV2")) {
config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.MSCHAPV2);
} else if (phase2Value.equals("GTC")) {
config.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.GTC);
}
phase2 = false; phase2 = false;
} }
if (identity) { if (identity) {
String identityValue = new String(ch, start, length); String identityValue = new String(ch, start, length);
config.identity.setValue(identityValue); config.enterpriseConfig.setIdentity(identityValue);
identity = false; identity = false;
} }
if (anonymousidentity) { if (anonymousidentity) {
String anonyId = new String(ch, start, length); String anonyId = new String(ch, start, length);
config.anonymous_identity.setValue(anonyId); config.enterpriseConfig.setAnonymousIdentity(anonyId);
anonymousidentity = false; anonymousidentity = false;
} }
if (cacert) { if (cacert) {
String cacertValue = new String(ch, start, length); String cacertValue = new String(ch, start, length);
// need to install the credentail to "keystore://" config.enterpriseConfig.setCaCertificate(cacertValue);
config.ca_cert.setValue(KEYSTORE_SPACE);
cacert = false; cacert = false;
} }
if (usercert) { if (usercert) {
String usercertValue = new String(ch, start, length); String usercertValue = new String(ch, start, length);
config.client_cert.setValue(KEYSTORE_SPACE); config.enterpriseConfig.setClientCertificate(usercertValue);
usercert = false; usercert = false;
} }
if (ip) { if (ip) {