softAp UI changes

Remove channel settings
Add subtext error handling
Remove WEP, keep WPA2 only for now

Bug: 2413908
Change-Id: Ie867e84a0705f0d2185eeb3a4c86a8227446a338
This commit is contained in:
Irfan Sheriff
2010-03-10 08:27:15 -08:00
parent 233880225a
commit 47ebb78954
6 changed files with 70 additions and 123 deletions

View File

@@ -49,6 +49,9 @@ class WifiApDialog extends AlertDialog implements View.OnClickListener,
private final DialogInterface.OnClickListener mListener;
private static final int OPEN_INDEX = 0;
private static final int WPA_INDEX = 1;
private View mView;
private TextView mSsid;
private int mSecurityType = AccessPoint.SECURITY_NONE;
@@ -76,22 +79,6 @@ class WifiApDialog extends AlertDialog implements View.OnClickListener,
config.allowedKeyManagement.set(KeyMgmt.NONE);
return config;
case AccessPoint.SECURITY_WEP:
config.allowedKeyManagement.set(KeyMgmt.NONE);
config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
if (mPassword.length() != 0) {
int length = mPassword.length();
String password = mPassword.getText().toString();
// WEP-40, WEP-104, and 256-bit WEP (WEP-232?)
if ((length == 10 || length == 26 || length == 58) &&
password.matches("[0-9A-Fa-f]*")) {
config.wepKeys[0] = password;
} else {
config.wepKeys[0] = '"' + password + '"';
}
}
return config;
case AccessPoint.SECURITY_PSK:
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
@@ -130,14 +117,18 @@ class WifiApDialog extends AlertDialog implements View.OnClickListener,
if (mWifiConfig != null) {
mSsid.setText(mWifiConfig.SSID);
switch (mSecurityType) {
case AccessPoint.SECURITY_WEP:
mPassword.setText(mWifiConfig.wepKeys[0]);
case AccessPoint.SECURITY_NONE:
mSecurity.setSelection(OPEN_INDEX);
break;
case AccessPoint.SECURITY_PSK:
mPassword.setText(mWifiConfig.preSharedKey);
String str = mWifiConfig.preSharedKey;
if (!str.matches("[0-9A-Fa-f]{64}")) {
str = str.substring(1,str.length()-1);
}
mPassword.setText(str);
mSecurity.setSelection(WPA_INDEX);
break;
}
mSecurity.setSelection(mSecurityType);
}
mSsid.addTextChangedListener(this);
@@ -153,7 +144,6 @@ class WifiApDialog extends AlertDialog implements View.OnClickListener,
private void validate() {
if ((mSsid != null && mSsid.length() == 0) ||
(mSecurityType == AccessPoint.SECURITY_WEP && mPassword.length() == 0) ||
(mSecurityType == AccessPoint.SECURITY_PSK && mPassword.length() < 8)) {
getButton(BUTTON_SUBMIT).setEnabled(false);
} else {
@@ -179,7 +169,10 @@ class WifiApDialog extends AlertDialog implements View.OnClickListener,
}
public void onItemSelected(AdapterView parent, View view, int position, long id) {
mSecurityType = position;
if(position == OPEN_INDEX)
mSecurityType = AccessPoint.SECURITY_NONE;
else
mSecurityType = AccessPoint.SECURITY_PSK;
showSecurityFields();
validate();
}