Merge change 24646 into eclair

* changes:
  Aggregate the security settings for WiFi network configuration.
This commit is contained in:
Android (Google) Code Review
2009-09-16 06:26:54 -04:00
5 changed files with 77 additions and 205 deletions

View File

@@ -105,17 +105,6 @@
<Spinner android:id="@+id/client_certificate_spinner" <Spinner android:id="@+id/client_certificate_spinner"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView android:id="@+id/private_key_passwd_text"
style="?android:attr/textAppearanceSmallInverse"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dip"
android:text="@string/please_type_private_key_passwd" />
<EditText android:id="@+id/private_key_passwd_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:singleLine="true" />
<TextView android:id="@+id/identity_text" <TextView android:id="@+id/identity_text"
style="?android:attr/textAppearanceSmallInverse" style="?android:attr/textAppearanceSmallInverse"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View File

@@ -179,13 +179,9 @@
<!-- Do not translate. The Wi-Fi network has WEP security. --> <!-- Do not translate. The Wi-Fi network has WEP security. -->
<item>WEP</item> <item>WEP</item>
<!-- The Wi-Fi network has WPA personal security. WPA Personal is a tech term, and might be better left untranslated? --> <!-- The Wi-Fi network has WPA personal security. WPA Personal is a tech term, and might be better left untranslated? -->
<item>WPA personal</item> <item>WPA/WPA2 PSK</item>
<!-- The Wi-Fi network has WPA2 personal security. WPA Personal is a tech term, and might be better left untranslated? -->
<item>WPA2 personal</item>
<!-- The Wi-Fi network has WPA EAP extensible authentication protocol. --> <!-- The Wi-Fi network has WPA EAP extensible authentication protocol. -->
<item>WPA-EAP</item> <item>802.1x Enterprise</item>
<!-- IEEE 802.1X key management -->
<item>IEEE 802.1x</item>
</string-array> </string-array>
<!-- Match this with code. --> <skip /> <!-- Match this with code. --> <skip />
@@ -196,14 +192,9 @@
<!-- Do not translate. The Wi-Fi network has WEP security. --> <!-- Do not translate. The Wi-Fi network has WEP security. -->
<item>WEP</item> <item>WEP</item>
<!-- The Wi-Fi network has WPA personal security. WPA Personal is a tech term, and might be better left untranslated? --> <!-- The Wi-Fi network has WPA personal security. WPA Personal is a tech term, and might be better left untranslated? -->
<item>WPA personal</item> <item>WPA/WPA2 PSK</item>
<!-- The Wi-Fi network has WPA2 personal security. WPA Personal is a tech term, and might be better left untranslated? -->
<item>WPA2 personal</item>
<!-- The Wi-Fi network has WPA enterprise security. WPA Enterprise is a tech term, and might be better left untranslated? --> <!-- The Wi-Fi network has WPA enterprise security. WPA Enterprise is a tech term, and might be better left untranslated? -->
<!-- The Wi-Fi network has WPA EAP extensible authentication protocol. --> <item>802.1x Enterprise</item>
<item>WPA-EAP</item>
<!-- IEEE 802.1X key management -->
<item>IEEE 802.1x</item>
</string-array> </string-array>
<!-- Match this with code. --> <skip /> <!-- Match this with code. --> <skip />

View File

@@ -644,13 +644,10 @@
<!-- Value for the wifi security --> <!-- Value for the wifi security -->
<string name="wifi_security_wep">WEP</string> <string name="wifi_security_wep">WEP</string>
<!-- Value for the wifi security --> <!-- Value for the wifi security -->
<string name="wifi_security_wpa">WPA</string> <string name="wifi_security_psk">WPA/WPA2 PSK</string>
<!-- Value for the wifi security --> <!-- Value for the wifi security -->
<string name="wifi_security_wpa2">WPA2</string> <string name="wifi_security_eap">Enterprise(802.1x)</string>
<!-- Value for the wifi security --> <!-- Value for the wifi security -->
<string name="wifi_security_wpa_eap">WPA-EAP</string>
<!-- Value for the wifi security -->
<string name="wifi_security_ieee8021x">IEEE8021X</string>
<!-- Value for the wifi security when it is unknown --> <!-- Value for the wifi security when it is unknown -->
<string name="wifi_security_unknown">Unknown</string> <string name="wifi_security_unknown">Unknown</string>
@@ -659,14 +656,10 @@
<!-- Verbose security type of a wifi network. Capitalized by app. --> <!-- Verbose security type of a wifi network. Capitalized by app. -->
<string name="wifi_security_verbose_wep">secured with WEP</string> <string name="wifi_security_verbose_wep">secured with WEP</string>
<!-- Verbose security type of a wifi network. Capitalized by app. --> <!-- Verbose security type of a wifi network. Capitalized by app. -->
<string name="wifi_security_verbose_wpa">secured with WPA</string> <string name="wifi_security_verbose_psk">secured with WPA/WPA2 PSK</string>
<!-- Verbose security type of a wifi network. Capitalized by app. --> <!-- Verbose security type of a wifi network. Capitalized by app. -->
<string name="wifi_security_verbose_wpa2">secured with WPA2</string> <string name="wifi_security_verbose_eap">secured with 802.1x EAP</string>
<!-- Verbose security type of a wifi network. Capitalized by app. --> <!-- Wi-Fi IP addrress label -->
<string name="wifi_security_verbose_wpa_eap">secured with WPA-EAP</string>
<!-- Verbose security type of a wifi network. Capitalized by app. -->
<string name="wifi_security_verbose_ieee8021x">secured with IEEE 802.1x</string>
<!-- Wi-Fi IP addrress label -->
<string name="ip_address">IP address</string> <string name="ip_address">IP address</string>
<!-- Label for the signal strength --> <!-- Label for the signal strength -->
<string name="signal">Signal strength</string> <string name="signal">Signal strength</string>
@@ -702,8 +695,6 @@
<string name="please_select_client_certificate">Client certificate</string> <string name="please_select_client_certificate">Client certificate</string>
<!-- Caption for the ca certificate --> <!-- Caption for the ca certificate -->
<string name="please_select_ca_certificate">CA certificate</string> <string name="please_select_ca_certificate">CA certificate</string>
<!-- Caption for the Private Key -->
<string name="please_type_private_key_passwd">Private key password</string>
<!-- Caption for the wireless password --> <!-- Caption for the wireless password -->
<string name="please_type_passphrase">Wireless password</string> <string name="please_type_passphrase">Wireless password</string>
<!--Wi-Fi settings screen, connect to network dialog box, field label and hint text --> <!--Wi-Fi settings screen, connect to network dialog box, field label and hint text -->

View File

@@ -73,10 +73,8 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
private static final int SECURITY_AUTO = 0; private static final int SECURITY_AUTO = 0;
private static final int SECURITY_NONE = 1; private static final int SECURITY_NONE = 1;
private static final int SECURITY_WEP = 2; private static final int SECURITY_WEP = 2;
private static final int SECURITY_WPA_PERSONAL = 3; private static final int SECURITY_PSK = 3;
private static final int SECURITY_WPA2_PERSONAL = 4; private static final int SECURITY_EAP = 4;
private static final int SECURITY_WPA_EAP = 5;
private static final int SECURITY_IEEE8021X = 6;
private static final int[] WEP_TYPE_VALUES = { private static final int[] WEP_TYPE_VALUES = {
AccessPointState.WEP_PASSWORD_AUTO, AccessPointState.WEP_PASSWORD_ASCII, AccessPointState.WEP_PASSWORD_AUTO, AccessPointState.WEP_PASSWORD_ASCII,
@@ -118,8 +116,6 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
private Spinner mCaCertSpinner; private Spinner mCaCertSpinner;
private TextView mClientCertText; private TextView mClientCertText;
private Spinner mClientCertSpinner; private Spinner mClientCertSpinner;
private TextView mPrivateKeyPasswdText;
private EditText mPrivateKeyPasswdEdit;
private EditText[] mEnterpriseTextFields; private EditText[] mEnterpriseTextFields;
@@ -221,7 +217,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
updateCertificateSelection(); updateCertificateSelection();
setGenericPasswordVisible(true); setGenericPasswordVisible(true);
// Both WPA and WPA2 show the same caption, so either is ok // Both WPA and WPA2 show the same caption, so either is ok
updatePasswordCaption(AccessPointState.WPA); updatePasswordCaption(AccessPointState.PSK);
} }
/** Called after flags are set, the dialog's layout/etc should be set up here */ /** Called after flags are set, the dialog's layout/etc should be set up here */
@@ -370,8 +366,6 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
mClientCertText = mClientCertText =
(TextView) view.findViewById(R.id.client_certificate_text); (TextView) view.findViewById(R.id.client_certificate_text);
mCaCertText = (TextView) view.findViewById(R.id.ca_certificate_text); mCaCertText = (TextView) view.findViewById(R.id.ca_certificate_text);
mPrivateKeyPasswdEdit =
(EditText) view.findViewById(R.id.private_key_passwd_edit);
mEapText = (TextView) view.findViewById(R.id.eap_text); mEapText = (TextView) view.findViewById(R.id.eap_text);
mEapSpinner = (Spinner) view.findViewById(R.id.eap_spinner); mEapSpinner = (Spinner) view.findViewById(R.id.eap_spinner);
mEapSpinner.setOnItemSelectedListener(this); mEapSpinner.setOnItemSelectedListener(this);
@@ -398,7 +392,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
setSpinnerAdapter(mCaCertSpinner, getAllCaCertificateKeys()); setSpinnerAdapter(mCaCertSpinner, getAllCaCertificateKeys());
mEnterpriseTextFields = new EditText[] { mEnterpriseTextFields = new EditText[] {
mIdentityEdit, mAnonymousIdentityEdit, mPrivateKeyPasswdEdit mIdentityEdit, mAnonymousIdentityEdit
}; };
} }
@@ -517,9 +511,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
if (mState.isEnterprise()) { if (mState.isEnterprise()) {
if(!mState.configured) { if(!mState.configured) {
updateEnterpriseFields( updateEnterpriseFields();
AccessPointState.WPA_EAP.equals(mState.security) ?
SECURITY_WPA_EAP : SECURITY_IEEE8021X);
} }
} }
updatePasswordField(); updatePasswordField();
@@ -575,13 +567,8 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
} }
switch (securityType) { switch (securityType) {
case SECURITY_WPA_PERSONAL: { case SECURITY_PSK: {
mState.setSecurity(AccessPointState.WPA); mState.setSecurity(AccessPointState.PSK);
break;
}
case SECURITY_WPA2_PERSONAL: {
mState.setSecurity(AccessPointState.WPA2);
break; break;
} }
@@ -596,12 +583,8 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
break; break;
} }
case SECURITY_WPA_EAP: case SECURITY_EAP:
mState.setSecurity(AccessPointState.WPA_EAP); mState.setSecurity(AccessPointState.EAP);
break;
case SECURITY_IEEE8021X:
mState.setSecurity(AccessPointState.IEEE8021X);
break; break;
case SECURITY_NONE: case SECURITY_NONE:
@@ -611,9 +594,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
} }
if (mState.isEnterprise() && !mState.configured) { if (mState.isEnterprise() && !mState.configured) {
updateEnterpriseFields( updateEnterpriseFields();
AccessPointState.WPA_EAP.equals(mState.security) ?
SECURITY_WPA_EAP : SECURITY_IEEE8021X);
} }
if (!mWifiLayer.saveNetwork(mState)) { if (!mWifiLayer.saveNetwork(mState)) {
@@ -641,14 +622,13 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
getContext().getResources().getStringArray(arrayResId), selection); getContext().getResources().getStringArray(arrayResId), selection);
} }
private void updateEnterpriseFields(int securityType) { private void updateEnterpriseFields() {
int i; int i;
String value; String value;
for (i = AccessPointState.IDENTITY ; for (i = AccessPointState.IDENTITY ;
i <= AccessPointState.PRIVATE_KEY_PASSWD ; i++) { i <= AccessPointState.ANONYMOUS_IDENTITY ; i++) {
value = mEnterpriseTextFields[i].getText().toString(); value = mEnterpriseTextFields[i].getText().toString();
if (!TextUtils.isEmpty(value) || if (!TextUtils.isEmpty(value)) {
(i == AccessPointState.PRIVATE_KEY_PASSWD)) {
mState.setEnterpriseField(i, value); mState.setEnterpriseField(i, value);
} }
} }
@@ -677,21 +657,9 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
BLOB_HEADER + value); BLOB_HEADER + value);
} }
} }
switch (securityType) { mState.setSecurity(AccessPointState.EAP);
case SECURITY_IEEE8021X: mState.setEap(mEapSpinner.getSelectedItemPosition());
case SECURITY_WPA_EAP: { mState.setPhase2((String)mPhase2Spinner.getSelectedItem());
if (securityType == SECURITY_WPA_EAP) {
mState.setSecurity(AccessPointState.WPA_EAP);
} else {
mState.setSecurity(AccessPointState.IEEE8021X);
}
mState.setEap(mEapSpinner.getSelectedItemPosition());
mState.setPhase2((String)mPhase2Spinner.getSelectedItem());
break;
}
default:
mState.setSecurity(AccessPointState.OPEN);
}
} }
/** /**
@@ -784,20 +752,18 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
setWepVisible(false); setWepVisible(false);
setGenericPasswordVisible(mState.hasSecurity()); setGenericPasswordVisible(mState.hasSecurity());
// Shows the generic 'wireless password' // Shows the generic 'wireless password'
updatePasswordCaption(AccessPointState.WPA); updatePasswordCaption(AccessPointState.PSK);
break; break;
} }
case SECURITY_WPA_PERSONAL: case SECURITY_PSK: {
case SECURITY_WPA2_PERSONAL: {
setWepVisible(false); setWepVisible(false);
setGenericPasswordVisible(true); setGenericPasswordVisible(true);
// Both WPA and WPA2 show the same caption, so either is ok // Both WPA and WPA2 show the same caption, so either is ok
updatePasswordCaption(AccessPointState.WPA); updatePasswordCaption(AccessPointState.PSK);
break; break;
} }
case SECURITY_WPA_EAP: case SECURITY_EAP: {
case SECURITY_IEEE8021X: {
// Unlock the keystore if it is not unlocked yet. // Unlock the keystore if it is not unlocked yet.
if (Keystore.getInstance().getState() != Keystore.UNLOCKED) { if (Keystore.getInstance().getState() != Keystore.UNLOCKED) {
getContext().startActivity(new Intent( getContext().startActivity(new Intent(

View File

@@ -38,15 +38,11 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
private static final String TAG = "AccessPointState"; private static final String TAG = "AccessPointState";
// Constants used for different security types // Constants used for different security types
public static final String WPA2 = "WPA2"; public static final String PSK = "PSK";
public static final String WPA = "WPA";
public static final String WEP = "WEP"; public static final String WEP = "WEP";
public static final String EAP = "EAP";
public static final String OPEN = "Open"; public static final String OPEN = "Open";
/* For EAP Enterprise fields */
public static final String WPA_EAP = "-EAP";
public static final String IEEE8021X = "IEEE8021X";
public static final String[] EAP_METHOD = { "PEAP", "TLS", "TTLS" }; public static final String[] EAP_METHOD = { "PEAP", "TLS", "TTLS" };
/** String present in capabilities if the scan result is ad-hoc */ /** String present in capabilities if the scan result is ad-hoc */
@@ -103,11 +99,10 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
/* Enterprise Fields */ /* Enterprise Fields */
public static final int IDENTITY = 0; public static final int IDENTITY = 0;
public static final int ANONYMOUS_IDENTITY = 1; public static final int ANONYMOUS_IDENTITY = 1;
public static final int PRIVATE_KEY_PASSWD = 2; public static final int CLIENT_CERT = 2;
public static final int CLIENT_CERT = 3; public static final int CA_CERT = 3;
public static final int CA_CERT = 4; public static final int PRIVATE_KEY = 4;
public static final int PRIVATE_KEY = 5; public static final int MAX_ENTRPRISE_FIELD = 5;
public static final int MAX_ENTRPRISE_FIELD = 6;
private String mEnterpriseFields[] = new String[MAX_ENTRPRISE_FIELD]; private String mEnterpriseFields[] = new String[MAX_ENTRPRISE_FIELD];
private String mEap; private String mEap;
private String mPhase2; private String mPhase2;
@@ -278,8 +273,7 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
} }
public boolean isEnterprise() { public boolean isEnterprise() {
return (WPA_EAP.equals(security) || return (AccessPointState.EAP.equals(security));
AccessPointState.IEEE8021X.equals(security));
} }
public void setSecurity(String security) { public void setSecurity(String security) {
@@ -296,10 +290,8 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
public String getHumanReadableSecurity() { public String getHumanReadableSecurity() {
if (security.equals(OPEN)) return mContext.getString(R.string.wifi_security_open); if (security.equals(OPEN)) return mContext.getString(R.string.wifi_security_open);
else if (security.equals(WEP)) return mContext.getString(R.string.wifi_security_wep); else if (security.equals(WEP)) return mContext.getString(R.string.wifi_security_wep);
else if (security.equals(WPA)) return mContext.getString(R.string.wifi_security_wpa); else if (security.equals(PSK)) return mContext.getString(R.string.wifi_security_psk);
else if (security.equals(WPA2)) return mContext.getString(R.string.wifi_security_wpa2); else if (security.equals(EAP)) return mContext.getString(R.string.wifi_security_eap);
else if (security.equals(WPA_EAP)) return mContext.getString(R.string.wifi_security_wpa_eap);
else if (security.equals(IEEE8021X)) return mContext.getString(R.string.wifi_security_ieee8021x);
return mContext.getString(R.string.wifi_security_unknown); return mContext.getString(R.string.wifi_security_unknown);
} }
@@ -325,7 +317,7 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
*/ */
public static String getScanResultSecurity(ScanResult scanResult) { public static String getScanResultSecurity(ScanResult scanResult) {
final String cap = scanResult.capabilities; final String cap = scanResult.capabilities;
final String[] securityModes = { WEP, WPA, WPA2, WPA_EAP, IEEE8021X }; final String[] securityModes = { WEP, PSK, EAP };
for (int i = securityModes.length - 1; i >= 0; i--) { for (int i = securityModes.length - 1; i >= 0; i--) {
if (cap.contains(securityModes[i])) { if (cap.contains(securityModes[i])) {
return securityModes[i]; return securityModes[i];
@@ -427,31 +419,14 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
* @return The security of a given {@link WifiConfiguration}. * @return The security of a given {@link WifiConfiguration}.
*/ */
public static String getWifiConfigurationSecurity(WifiConfiguration wifiConfig) { public static String getWifiConfigurationSecurity(WifiConfiguration wifiConfig) {
if (!TextUtils.isEmpty(wifiConfig.eap.value())) {
if (wifiConfig.allowedKeyManagement.get(KeyMgmt.NONE)) { return EAP;
// If we never set group ciphers, wpa_supplicant puts all of them. } else if (!TextUtils.isEmpty(wifiConfig.preSharedKey)) {
// For open, we don't set group ciphers. return PSK;
// For WEP, we specifically only set WEP40 and WEP104, so CCMP } else if (!TextUtils.isEmpty(wifiConfig.wepKeys[0])) {
// and TKIP should not be there. return WEP;
if (!wifiConfig.allowedGroupCiphers.get(GroupCipher.CCMP)
&& (wifiConfig.allowedGroupCiphers.get(GroupCipher.WEP40)
|| wifiConfig.allowedGroupCiphers.get(GroupCipher.WEP104))) {
return WEP;
} else {
return OPEN;
}
} else if (wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_EAP)) {
return WPA_EAP;
} else if (wifiConfig.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) {
return IEEE8021X;
} else if (wifiConfig.allowedProtocols.get(Protocol.RSN)) {
return WPA2;
} else if (wifiConfig.allowedProtocols.get(Protocol.WPA)) {
return WPA;
} else {
Log.w(TAG, "Unknown security type from WifiConfiguration, falling back on open.");
return OPEN;
} }
return OPEN;
} }
public void updateFromWifiInfo(WifiInfo wifiInfo, NetworkInfo.DetailedState state) { public void updateFromWifiInfo(WifiInfo wifiInfo, NetworkInfo.DetailedState state) {
@@ -504,51 +479,43 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
config.priority = priority; config.priority = priority;
config.hiddenSSID = hiddenSsid; config.hiddenSSID = hiddenSsid;
config.SSID = convertToQuotedString(ssid); config.SSID = convertToQuotedString(ssid);
/* config.eap.setValue(mEap);
config.eap = mEap;
if (!TextUtils.isEmpty(mPhase2)) { if (!TextUtils.isEmpty(mPhase2)) {
config.phase2 = convertToQuotedString("auth=" + mPhase2); config.phase2.setValue(convertToQuotedString("auth=" + mPhase2));
} else { } else {
config.phase2 = null; config.phase2.setValue(null);
} }
if (!TextUtils.isEmpty(mEnterpriseFields[IDENTITY])) { if (!TextUtils.isEmpty(mEnterpriseFields[IDENTITY])) {
config.identity = config.identity.setValue(
convertToQuotedString(mEnterpriseFields[IDENTITY]); convertToQuotedString(mEnterpriseFields[IDENTITY]));
} else { } else {
config.identity = null; config.identity.setValue(null);
} }
if (!TextUtils.isEmpty(mEnterpriseFields[ANONYMOUS_IDENTITY])) { if (!TextUtils.isEmpty(mEnterpriseFields[ANONYMOUS_IDENTITY])) {
config.anonymousIdentity = convertToQuotedString( config.anonymous_identity.setValue(convertToQuotedString(
mEnterpriseFields[ANONYMOUS_IDENTITY]); mEnterpriseFields[ANONYMOUS_IDENTITY]));
} else { } else {
config.anonymousIdentity = null; config.anonymous_identity.setValue(null);
} }
if (!TextUtils.isEmpty(mEnterpriseFields[CLIENT_CERT])) { if (!TextUtils.isEmpty(mEnterpriseFields[CLIENT_CERT])) {
config.clientCert = convertToQuotedString( config.client_cert.setValue(convertToQuotedString(
mEnterpriseFields[CLIENT_CERT]); mEnterpriseFields[CLIENT_CERT]));
} else { } else {
config.clientCert = null; config.client_cert.setValue(null);
} }
if (!TextUtils.isEmpty(mEnterpriseFields[CA_CERT])) { if (!TextUtils.isEmpty(mEnterpriseFields[CA_CERT])) {
config.caCert = convertToQuotedString( config.ca_cert.setValue(convertToQuotedString(
mEnterpriseFields[CA_CERT]); mEnterpriseFields[CA_CERT]));
} else { } else {
config.caCert = null; config.ca_cert.setValue(null);
} }
if (!TextUtils.isEmpty(mEnterpriseFields[PRIVATE_KEY])) { if (!TextUtils.isEmpty(mEnterpriseFields[PRIVATE_KEY])) {
config.privateKey = convertToQuotedString( config.private_key.setValue(convertToQuotedString(
mEnterpriseFields[PRIVATE_KEY]); mEnterpriseFields[PRIVATE_KEY]));
} else { } else {
config.privateKey = null; config.private_key.setValue(null);
} }
if (!TextUtils.isEmpty(mEnterpriseFields[PRIVATE_KEY_PASSWD])) {
config.privateKeyPasswd = convertToQuotedString(
mEnterpriseFields[PRIVATE_KEY_PASSWD]);
} else {
config.privateKeyPasswd = null;
}
*/
setupSecurity(config); setupSecurity(config);
} }
@@ -565,7 +532,6 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
} }
if (security.equals(WEP)) { if (security.equals(WEP)) {
// If password is empty, it should be left untouched // If password is empty, it should be left untouched
if (!TextUtils.isEmpty(mPassword)) { if (!TextUtils.isEmpty(mPassword)) {
if (mWepPasswordType == WEP_PASSWORD_AUTO) { if (mWepPasswordType == WEP_PASSWORD_AUTO) {
@@ -580,28 +546,9 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
: mPassword; : mPassword;
} }
} }
config.wepTxKeyIndex = 0;
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
config.allowedKeyManagement.set(KeyMgmt.NONE); config.allowedKeyManagement.set(KeyMgmt.NONE);
config.wepTxKeyIndex = 0;
config.allowedGroupCiphers.set(GroupCipher.WEP40); } else if (security.equals(PSK)){
config.allowedGroupCiphers.set(GroupCipher.WEP104);
} else if (security.equals(WPA) || security.equals(WPA2)){
config.allowedGroupCiphers.set(GroupCipher.TKIP);
config.allowedGroupCiphers.set(GroupCipher.CCMP);
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedPairwiseCiphers.set(PairwiseCipher.CCMP);
config.allowedPairwiseCiphers.set(PairwiseCipher.TKIP);
config.allowedProtocols.set(security.equals(WPA2) ? Protocol.RSN : Protocol.WPA);
// If password is empty, it should be left untouched // If password is empty, it should be left untouched
if (!TextUtils.isEmpty(mPassword)) { if (!TextUtils.isEmpty(mPassword)) {
if (mPassword.length() == 64 && isHex(mPassword)) { if (mPassword.length() == 64 && isHex(mPassword)) {
@@ -612,20 +559,14 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
config.preSharedKey = convertToQuotedString(mPassword); config.preSharedKey = convertToQuotedString(mPassword);
} }
} }
} else if (security.equals(EAP)) {
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
if (!TextUtils.isEmpty(mPassword)) {
config.password.setValue(convertToQuotedString(mPassword));
}
} else if (security.equals(OPEN)) { } else if (security.equals(OPEN)) {
config.allowedKeyManagement.set(KeyMgmt.NONE); config.allowedKeyManagement.set(KeyMgmt.NONE);
} else if (security.equals(WPA_EAP) || security.equals(IEEE8021X)) {
config.allowedGroupCiphers.set(GroupCipher.TKIP);
config.allowedGroupCiphers.set(GroupCipher.CCMP);
if (security.equals(WPA_EAP)) {
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
} else {
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
}
if (!TextUtils.isEmpty(mPassword)) {
// config.password = convertToQuotedString(mPassword);
}
} }
} }
@@ -827,16 +768,10 @@ public final class AccessPointState implements Comparable<AccessPointState>, Par
private String getVerboseSecurity() { private String getVerboseSecurity() {
if (WEP.equals(security)) { if (WEP.equals(security)) {
return mContext.getString(R.string.wifi_security_verbose_wep); return mContext.getString(R.string.wifi_security_verbose_wep);
} else if (WPA.equals(security)) { } else if (PSK.equals(security)) {
return mContext.getString(R.string.wifi_security_verbose_wpa); return mContext.getString(R.string.wifi_security_verbose_psk);
} else if (WPA2.equals(security)) { } else if (EAP.equals(security)) {
return mContext.getString(R.string.wifi_security_verbose_wpa2); return mContext.getString(R.string.wifi_security_verbose_eap);
} else if (OPEN.equals(security)) {
return mContext.getString(R.string.wifi_security_verbose_open);
} else if (WPA_EAP.equals(security)) {
return mContext.getString(R.string.wifi_security_verbose_wpa_eap);
} else if (IEEE8021X.equals(security)) {
return mContext.getString(R.string.wifi_security_verbose_ieee8021x);
} else { } else {
return null; return null;
} }