Aggregate the security settings for WiFi network configuration.
* Merge WPA and WPA2 PSK. * Merge WPA-EAP and IEEE8021X. * Remove unused field "private key password" in EAP configuration.
This commit is contained in:
@@ -73,10 +73,8 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
private static final int SECURITY_AUTO = 0;
|
||||
private static final int SECURITY_NONE = 1;
|
||||
private static final int SECURITY_WEP = 2;
|
||||
private static final int SECURITY_WPA_PERSONAL = 3;
|
||||
private static final int SECURITY_WPA2_PERSONAL = 4;
|
||||
private static final int SECURITY_WPA_EAP = 5;
|
||||
private static final int SECURITY_IEEE8021X = 6;
|
||||
private static final int SECURITY_PSK = 3;
|
||||
private static final int SECURITY_EAP = 4;
|
||||
|
||||
private static final int[] WEP_TYPE_VALUES = {
|
||||
AccessPointState.WEP_PASSWORD_AUTO, AccessPointState.WEP_PASSWORD_ASCII,
|
||||
@@ -118,8 +116,6 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
private Spinner mCaCertSpinner;
|
||||
private TextView mClientCertText;
|
||||
private Spinner mClientCertSpinner;
|
||||
private TextView mPrivateKeyPasswdText;
|
||||
private EditText mPrivateKeyPasswdEdit;
|
||||
private EditText[] mEnterpriseTextFields;
|
||||
|
||||
|
||||
@@ -221,7 +217,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
updateCertificateSelection();
|
||||
setGenericPasswordVisible(true);
|
||||
// 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 */
|
||||
@@ -370,8 +366,6 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
mClientCertText =
|
||||
(TextView) view.findViewById(R.id.client_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);
|
||||
mEapSpinner = (Spinner) view.findViewById(R.id.eap_spinner);
|
||||
mEapSpinner.setOnItemSelectedListener(this);
|
||||
@@ -398,7 +392,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
setSpinnerAdapter(mCaCertSpinner, getAllCaCertificateKeys());
|
||||
|
||||
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.configured) {
|
||||
updateEnterpriseFields(
|
||||
AccessPointState.WPA_EAP.equals(mState.security) ?
|
||||
SECURITY_WPA_EAP : SECURITY_IEEE8021X);
|
||||
updateEnterpriseFields();
|
||||
}
|
||||
}
|
||||
updatePasswordField();
|
||||
@@ -575,13 +567,8 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
}
|
||||
|
||||
switch (securityType) {
|
||||
case SECURITY_WPA_PERSONAL: {
|
||||
mState.setSecurity(AccessPointState.WPA);
|
||||
break;
|
||||
}
|
||||
|
||||
case SECURITY_WPA2_PERSONAL: {
|
||||
mState.setSecurity(AccessPointState.WPA2);
|
||||
case SECURITY_PSK: {
|
||||
mState.setSecurity(AccessPointState.PSK);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -596,12 +583,8 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
break;
|
||||
}
|
||||
|
||||
case SECURITY_WPA_EAP:
|
||||
mState.setSecurity(AccessPointState.WPA_EAP);
|
||||
break;
|
||||
|
||||
case SECURITY_IEEE8021X:
|
||||
mState.setSecurity(AccessPointState.IEEE8021X);
|
||||
case SECURITY_EAP:
|
||||
mState.setSecurity(AccessPointState.EAP);
|
||||
break;
|
||||
|
||||
case SECURITY_NONE:
|
||||
@@ -611,9 +594,7 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
}
|
||||
|
||||
if (mState.isEnterprise() && !mState.configured) {
|
||||
updateEnterpriseFields(
|
||||
AccessPointState.WPA_EAP.equals(mState.security) ?
|
||||
SECURITY_WPA_EAP : SECURITY_IEEE8021X);
|
||||
updateEnterpriseFields();
|
||||
}
|
||||
|
||||
if (!mWifiLayer.saveNetwork(mState)) {
|
||||
@@ -641,14 +622,13 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
getContext().getResources().getStringArray(arrayResId), selection);
|
||||
}
|
||||
|
||||
private void updateEnterpriseFields(int securityType) {
|
||||
private void updateEnterpriseFields() {
|
||||
int i;
|
||||
String value;
|
||||
for (i = AccessPointState.IDENTITY ;
|
||||
i <= AccessPointState.PRIVATE_KEY_PASSWD ; i++) {
|
||||
i <= AccessPointState.ANONYMOUS_IDENTITY ; i++) {
|
||||
value = mEnterpriseTextFields[i].getText().toString();
|
||||
if (!TextUtils.isEmpty(value) ||
|
||||
(i == AccessPointState.PRIVATE_KEY_PASSWD)) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
mState.setEnterpriseField(i, value);
|
||||
}
|
||||
}
|
||||
@@ -677,21 +657,9 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
BLOB_HEADER + value);
|
||||
}
|
||||
}
|
||||
switch (securityType) {
|
||||
case SECURITY_IEEE8021X:
|
||||
case SECURITY_WPA_EAP: {
|
||||
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);
|
||||
}
|
||||
mState.setSecurity(AccessPointState.EAP);
|
||||
mState.setEap(mEapSpinner.getSelectedItemPosition());
|
||||
mState.setPhase2((String)mPhase2Spinner.getSelectedItem());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -784,20 +752,18 @@ public class AccessPointDialog extends AlertDialog implements DialogInterface.On
|
||||
setWepVisible(false);
|
||||
setGenericPasswordVisible(mState.hasSecurity());
|
||||
// Shows the generic 'wireless password'
|
||||
updatePasswordCaption(AccessPointState.WPA);
|
||||
updatePasswordCaption(AccessPointState.PSK);
|
||||
break;
|
||||
}
|
||||
|
||||
case SECURITY_WPA_PERSONAL:
|
||||
case SECURITY_WPA2_PERSONAL: {
|
||||
|
||||
case SECURITY_PSK: {
|
||||
setWepVisible(false);
|
||||
setGenericPasswordVisible(true);
|
||||
// Both WPA and WPA2 show the same caption, so either is ok
|
||||
updatePasswordCaption(AccessPointState.WPA);
|
||||
updatePasswordCaption(AccessPointState.PSK);
|
||||
break;
|
||||
}
|
||||
case SECURITY_WPA_EAP:
|
||||
case SECURITY_IEEE8021X: {
|
||||
case SECURITY_EAP: {
|
||||
// Unlock the keystore if it is not unlocked yet.
|
||||
if (Keystore.getInstance().getState() != Keystore.UNLOCKED) {
|
||||
getContext().startActivity(new Intent(
|
||||
|
Reference in New Issue
Block a user