* Merge WPA and WPA2 PSK.
* Merge WPA-EAP and IEEE8021X.
* Remove unused field "private key password" in EAP configuration.
<Spinner android:id="@+id/client_certificate_spinner"
android:layout_width="fill_parent"
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"
style="?android:attr/textAppearanceSmallInverse"
android:layout_width="fill_parent"
<!-- Do not translate. The Wi-Fi network has WEP security. -->
<item>WEP</item>
<!-- The Wi-Fi network has WPA personal security. WPA Personal is a tech term, and might be better left untranslated? -->
- <item>WPA personal</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>
+ <item>WPA/WPA2 PSK</item>
<!-- The Wi-Fi network has WPA EAP extensible authentication protocol. -->
- <item>WPA-EAP</item>
- <!-- IEEE 802.1X key management -->
- <item>IEEE 802.1x</item>
+ <item>802.1x Enterprise</item>
</string-array>
<!-- Match this with code. --> <skip />
<!-- Do not translate. The Wi-Fi network has WEP security. -->
<item>WEP</item>
<!-- The Wi-Fi network has WPA personal security. WPA Personal is a tech term, and might be better left untranslated? -->
- <item>WPA personal</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>
+ <item>WPA/WPA2 PSK</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 EAP extensible authentication protocol. -->
- <item>WPA-EAP</item>
- <!-- IEEE 802.1X key management -->
- <item>IEEE 802.1x</item>
+ <item>802.1x Enterprise</item>
</string-array>
<!-- Match this with code. --> <skip />
<!-- Value for the wifi security -->
<string name="wifi_security_wep">WEP</string>
<!-- 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 -->
- <string name="wifi_security_wpa2">WPA2</string>
+ <string name="wifi_security_eap">Enterprise(802.1x)</string>
<!-- 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 -->
<string name="wifi_security_unknown">Unknown</string>
<!-- Verbose security type of a wifi network. Capitalized by app. -->
<string name="wifi_security_verbose_wep">secured with WEP</string>
<!-- Verbose security type of a wifi network. Capitalized by app. -->
- <string name="wifi_security_verbose_wpa">secured with WPA</string>
- <!-- Verbose security type of a wifi network. Capitalized by app. -->
- <string name="wifi_security_verbose_wpa2">secured with WPA2</string>
- <!-- Verbose security type of a wifi network. Capitalized by app. -->
- <string name="wifi_security_verbose_wpa_eap">secured with WPA-EAP</string>
+ <string name="wifi_security_verbose_psk">secured with WPA/WPA2 PSK</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="wifi_security_verbose_eap">secured with 802.1x EAP</string>
+ <!-- Wi-Fi IP addrress label -->
<string name="ip_address">IP address</string>
<!-- Label for the signal strength -->
<string name="signal">Signal strength</string>
<string name="please_select_client_certificate">Client certificate</string>
<!-- Caption for the ca certificate -->
<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 -->
<string name="please_type_passphrase">Wireless password</string>
<!--Wi-Fi settings screen, connect to network dialog box, field label and hint text -->
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,
private Spinner mCaCertSpinner;
private TextView mClientCertText;
private Spinner mClientCertSpinner;
- private TextView mPrivateKeyPasswdText;
- private EditText mPrivateKeyPasswdEdit;
private EditText[] mEnterpriseTextFields;
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 */
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);
setSpinnerAdapter(mCaCertSpinner, getAllCaCertificateKeys());
mEnterpriseTextFields = new EditText[] {
- mIdentityEdit, mAnonymousIdentityEdit, mPrivateKeyPasswdEdit
+ mIdentityEdit, mAnonymousIdentityEdit
};
}
if (mState.isEnterprise()) {
if(!mState.configured) {
- updateEnterpriseFields(
- AccessPointState.WPA_EAP.equals(mState.security) ?
- SECURITY_WPA_EAP : SECURITY_IEEE8021X);
+ updateEnterpriseFields();
}
}
updatePasswordField();
}
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;
}
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:
}
if (mState.isEnterprise() && !mState.configured) {
- updateEnterpriseFields(
- AccessPointState.WPA_EAP.equals(mState.security) ?
- SECURITY_WPA_EAP : SECURITY_IEEE8021X);
+ updateEnterpriseFields();
}
if (!mWifiLayer.saveNetwork(mState)) {
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);
}
}
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());
}
/**
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(
private static final String TAG = "AccessPointState";
// Constants used for different security types
- public static final String WPA2 = "WPA2";
- public static final String WPA = "WPA";
+ public static final String PSK = "PSK";
public static final String WEP = "WEP";
+ public static final String EAP = "EAP";
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" };
/** String present in capabilities if the scan result is ad-hoc */
/* Enterprise Fields */
public static final int IDENTITY = 0;
public static final int ANONYMOUS_IDENTITY = 1;
- public static final int PRIVATE_KEY_PASSWD = 2;
- public static final int CLIENT_CERT = 3;
- public static final int CA_CERT = 4;
- public static final int PRIVATE_KEY = 5;
- public static final int MAX_ENTRPRISE_FIELD = 6;
+ public static final int CLIENT_CERT = 2;
+ public static final int CA_CERT = 3;
+ public static final int PRIVATE_KEY = 4;
+ public static final int MAX_ENTRPRISE_FIELD = 5;
private String mEnterpriseFields[] = new String[MAX_ENTRPRISE_FIELD];
private String mEap;
private String mPhase2;
}
public boolean isEnterprise() {
- return (WPA_EAP.equals(security) ||
- AccessPointState.IEEE8021X.equals(security));
+ return (AccessPointState.EAP.equals(security));
}
public void setSecurity(String security) {
public String getHumanReadableSecurity() {
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(WPA)) return mContext.getString(R.string.wifi_security_wpa);
- else if (security.equals(WPA2)) return mContext.getString(R.string.wifi_security_wpa2);
- 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);
+ else if (security.equals(PSK)) return mContext.getString(R.string.wifi_security_psk);
+ else if (security.equals(EAP)) return mContext.getString(R.string.wifi_security_eap);
return mContext.getString(R.string.wifi_security_unknown);
}
*/
public static String getScanResultSecurity(ScanResult scanResult) {
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--) {
if (cap.contains(securityModes[i])) {
return securityModes[i];
* @return The security of a given {@link WifiConfiguration}.
*/
public static String getWifiConfigurationSecurity(WifiConfiguration wifiConfig) {
-
- if (wifiConfig.allowedKeyManagement.get(KeyMgmt.NONE)) {
- // If we never set group ciphers, wpa_supplicant puts all of them.
- // For open, we don't set group ciphers.
- // For WEP, we specifically only set WEP40 and WEP104, so CCMP
- // and TKIP should not be there.
- 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;
+ if (!TextUtils.isEmpty(wifiConfig.eap.value())) {
+ return EAP;
+ } else if (!TextUtils.isEmpty(wifiConfig.preSharedKey)) {
+ return PSK;
+ } else if (!TextUtils.isEmpty(wifiConfig.wepKeys[0])) {
+ return WEP;
}
+ return OPEN;
}
public void updateFromWifiInfo(WifiInfo wifiInfo, NetworkInfo.DetailedState state) {
config.priority = priority;
config.hiddenSSID = hiddenSsid;
config.SSID = convertToQuotedString(ssid);
-/*
- config.eap = mEap;
+ config.eap.setValue(mEap);
if (!TextUtils.isEmpty(mPhase2)) {
- config.phase2 = convertToQuotedString("auth=" + mPhase2);
+ config.phase2.setValue(convertToQuotedString("auth=" + mPhase2));
} else {
- config.phase2 = null;
+ config.phase2.setValue(null);
}
if (!TextUtils.isEmpty(mEnterpriseFields[IDENTITY])) {
- config.identity =
- convertToQuotedString(mEnterpriseFields[IDENTITY]);
+ config.identity.setValue(
+ convertToQuotedString(mEnterpriseFields[IDENTITY]));
} else {
- config.identity = null;
+ config.identity.setValue(null);
}
if (!TextUtils.isEmpty(mEnterpriseFields[ANONYMOUS_IDENTITY])) {
- config.anonymousIdentity = convertToQuotedString(
- mEnterpriseFields[ANONYMOUS_IDENTITY]);
+ config.anonymous_identity.setValue(convertToQuotedString(
+ mEnterpriseFields[ANONYMOUS_IDENTITY]));
} else {
- config.anonymousIdentity = null;
+ config.anonymous_identity.setValue(null);
}
if (!TextUtils.isEmpty(mEnterpriseFields[CLIENT_CERT])) {
- config.clientCert = convertToQuotedString(
- mEnterpriseFields[CLIENT_CERT]);
+ config.client_cert.setValue(convertToQuotedString(
+ mEnterpriseFields[CLIENT_CERT]));
} else {
- config.clientCert = null;
+ config.client_cert.setValue(null);
}
if (!TextUtils.isEmpty(mEnterpriseFields[CA_CERT])) {
- config.caCert = convertToQuotedString(
- mEnterpriseFields[CA_CERT]);
+ config.ca_cert.setValue(convertToQuotedString(
+ mEnterpriseFields[CA_CERT]));
} else {
- config.caCert = null;
+ config.ca_cert.setValue(null);
}
if (!TextUtils.isEmpty(mEnterpriseFields[PRIVATE_KEY])) {
- config.privateKey = convertToQuotedString(
- mEnterpriseFields[PRIVATE_KEY]);
+ config.private_key.setValue(convertToQuotedString(
+ mEnterpriseFields[PRIVATE_KEY]));
} 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);
}
}
if (security.equals(WEP)) {
-
// If password is empty, it should be left untouched
if (!TextUtils.isEmpty(mPassword)) {
if (mWepPasswordType == WEP_PASSWORD_AUTO) {
: mPassword;
}
}
-
- config.wepTxKeyIndex = 0;
-
- config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
- config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
-
config.allowedKeyManagement.set(KeyMgmt.NONE);
-
- config.allowedGroupCiphers.set(GroupCipher.WEP40);
- 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);
-
+ config.wepTxKeyIndex = 0;
+ } else if (security.equals(PSK)){
// If password is empty, it should be left untouched
if (!TextUtils.isEmpty(mPassword)) {
if (mPassword.length() == 64 && isHex(mPassword)) {
config.preSharedKey = convertToQuotedString(mPassword);
}
}
-
- } else if (security.equals(OPEN)) {
- 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);
- }
+ } else if (security.equals(EAP)) {
+ config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
+ config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
if (!TextUtils.isEmpty(mPassword)) {
-// config.password = convertToQuotedString(mPassword);
+ config.password.setValue(convertToQuotedString(mPassword));
}
+ } else if (security.equals(OPEN)) {
+ config.allowedKeyManagement.set(KeyMgmt.NONE);
}
}
private String getVerboseSecurity() {
if (WEP.equals(security)) {
return mContext.getString(R.string.wifi_security_verbose_wep);
- } else if (WPA.equals(security)) {
- return mContext.getString(R.string.wifi_security_verbose_wpa);
- } else if (WPA2.equals(security)) {
- return mContext.getString(R.string.wifi_security_verbose_wpa2);
- } 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 if (PSK.equals(security)) {
+ return mContext.getString(R.string.wifi_security_verbose_psk);
+ } else if (EAP.equals(security)) {
+ return mContext.getString(R.string.wifi_security_verbose_eap);
} else {
return null;
}