summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/wifi/WifiConfigController.java
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2013-01-11 14:12:54 -0800
committerIrfan Sheriff <isheriff@android.com>2013-02-15 15:36:51 -0800
commitf3a0201202bb97a62067e9473e0a09afa2efe1ff (patch)
tree158ae1388a91a177310fee9f4fb0b0d934a529a8 /src/com/android/settings/wifi/WifiConfigController.java
parent1ef6a106d50f6fce2e2a810075a55bb264fa5c23 (diff)
downloadpackages_apps_Settings-f3a0201202bb97a62067e9473e0a09afa2efe1ff.tar.gz
packages_apps_Settings-f3a0201202bb97a62067e9473e0a09afa2efe1ff.tar.bz2
packages_apps_Settings-f3a0201202bb97a62067e9473e0a09afa2efe1ff.zip
Update enterprise API usage
Also, remove the unnecessary keystore lock/unlock checks since these are now controlled at lockscreen Change-Id: If65c4029d4cf2b8377fbc3512c9f691572125995
Diffstat (limited to 'src/com/android/settings/wifi/WifiConfigController.java')
-rw-r--r--src/com/android/settings/wifi/WifiConfigController.java87
1 files changed, 22 insertions, 65 deletions
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 2598a0e25..bf5f6423d 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -63,10 +63,6 @@ import java.util.Iterator;
*/
public class WifiConfigController implements TextWatcher,
View.OnClickListener, AdapterView.OnItemSelectedListener {
- private static final String KEYSTORE_SPACE = WifiConfiguration.KEYSTORE_URI;
-
- private static final String PHASE2_PREFIX = "auth=";
-
private final WifiConfigUiBase mConfigUi;
private final View mView;
private final AccessPoint mAccessPoint;
@@ -79,6 +75,8 @@ public class WifiConfigController implements TextWatcher,
private int mAccessPointSecurity;
private TextView mPasswordView;
+ private String unspecifiedCert = "unspecified";
+
private Spinner mSecuritySpinner;
private Spinner mEapMethodSpinner;
private Spinner mEapCaCertSpinner;
@@ -124,22 +122,6 @@ public class WifiConfigController implements TextWatcher,
private final Handler mTextViewChangedHandler;
- static boolean requireKeyStore(WifiConfiguration config) {
- if (config == null) {
- return false;
- }
- if (!TextUtils.isEmpty(config.key_id.value())) {
- return true;
- }
- String values[] = { config.ca_cert.value(), config.client_cert.value() };
- for (String value : values) {
- if (value != null && value.startsWith(KEYSTORE_SPACE)) {
- return true;
- }
- }
- return false;
- }
-
public WifiConfigController(
WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit) {
mConfigUi = parent;
@@ -155,6 +137,7 @@ public class WifiConfigController implements TextWatcher,
final Context context = mConfigUi.getContext();
final Resources resources = context.getResources();
+ unspecifiedCert = context.getString(R.string.wifi_unspecified);
mIpSettingsSpinner = (Spinner) mView.findViewById(R.id.ip_settings);
mIpSettingsSpinner.setOnItemSelectedListener(this);
mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
@@ -356,29 +339,18 @@ public class WifiConfigController implements TextWatcher,
case AccessPoint.SECURITY_EAP:
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
- config.eap.setValue((String) mEapMethodSpinner.getSelectedItem());
-
- config.phase2.setValue((mPhase2Spinner.getSelectedItemPosition() == 0) ? "" :
- PHASE2_PREFIX + mPhase2Spinner.getSelectedItem());
- config.ca_cert.setValue((mEapCaCertSpinner.getSelectedItemPosition() == 0) ? "" :
- KEYSTORE_SPACE + Credentials.CA_CERTIFICATE +
- (String) mEapCaCertSpinner.getSelectedItem());
- config.client_cert.setValue((mEapUserCertSpinner.getSelectedItemPosition() == 0) ?
- "" : KEYSTORE_SPACE + Credentials.USER_CERTIFICATE +
- (String) mEapUserCertSpinner.getSelectedItem());
- final boolean isEmptyKeyId = (mEapUserCertSpinner.getSelectedItemPosition() == 0);
- config.key_id.setValue(isEmptyKeyId ? "" : Credentials.USER_PRIVATE_KEY +
- (String) mEapUserCertSpinner.getSelectedItem());
- config.engine.setValue(isEmptyKeyId ? WifiConfiguration.ENGINE_DISABLE :
- WifiConfiguration.ENGINE_ENABLE);
- config.engine_id.setValue(isEmptyKeyId ? "" : WifiConfiguration.KEYSTORE_ENGINE_ID);
- config.identity.setValue((mEapIdentityView.length() == 0) ? "" :
- mEapIdentityView.getText().toString());
- config.anonymous_identity.setValue((mEapAnonymousView.length() == 0) ? "" :
+ config.enterpriseConfig.setEapMethod(mEapMethodSpinner.getSelectedItemPosition());
+ config.enterpriseConfig.setPhase2Method(mPhase2Spinner.getSelectedItemPosition());
+ String caCert = (String) mEapCaCertSpinner.getSelectedItem();
+ if (caCert.equals(unspecifiedCert)) caCert = "";
+ String clientCert = (String) mEapUserCertSpinner.getSelectedItem();
+ if (clientCert.equals(unspecifiedCert)) clientCert = "";
+ config.enterpriseConfig.setCaCertificate(caCert);
+ config.enterpriseConfig.setClientCertificate(clientCert);
+ config.enterpriseConfig.setIdentity(mEapIdentityView.getText().toString());
+ config.enterpriseConfig.setAnonymousIdentity(
mEapAnonymousView.getText().toString());
- if (mPasswordView.length() != 0) {
- config.password.setValue(mPasswordView.getText().toString());
- }
+ config.enterpriseConfig.setPassword(mPasswordView.getText().toString());
break;
default:
@@ -549,21 +521,13 @@ public class WifiConfigController implements TextWatcher,
if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
WifiConfiguration config = mAccessPoint.getConfig();
- setSelection(mEapMethodSpinner, config.eap.value());
-
- final String phase2Method = config.phase2.value();
- if (phase2Method != null && phase2Method.startsWith(PHASE2_PREFIX)) {
- setSelection(mPhase2Spinner, phase2Method.substring(PHASE2_PREFIX.length()));
- } else {
- setSelection(mPhase2Spinner, phase2Method);
- }
+ mEapMethodSpinner.setSelection(config.enterpriseConfig.getEapMethod());
+ mPhase2Spinner.setSelection(config.enterpriseConfig.getPhase2Method());
- setCertificate(mEapCaCertSpinner, KEYSTORE_SPACE + Credentials.CA_CERTIFICATE,
- config.ca_cert.value());
- setCertificate(mEapUserCertSpinner, Credentials.USER_PRIVATE_KEY,
- config.key_id.value());
- mEapIdentityView.setText(config.identity.value());
- mEapAnonymousView.setText(config.anonymous_identity.value());
+ setSelection(mEapCaCertSpinner, config.enterpriseConfig.getCaCertificate());
+ setSelection(mEapUserCertSpinner, config.enterpriseConfig.getClientCertificate());
+ mEapIdentityView.setText(config.enterpriseConfig.getIdentity());
+ mEapAnonymousView.setText(config.enterpriseConfig.getAnonymousIdentity());
}
}
@@ -675,14 +639,13 @@ public class WifiConfigController implements TextWatcher,
private void loadCertificates(Spinner spinner, String prefix) {
final Context context = mConfigUi.getContext();
- final String unspecified = context.getString(R.string.wifi_unspecified);
String[] certs = KeyStore.getInstance().saw(prefix);
if (certs == null || certs.length == 0) {
- certs = new String[] {unspecified};
+ certs = new String[] {unspecifiedCert};
} else {
final String[] array = new String[certs.length + 1];
- array[0] = unspecified;
+ array[0] = unspecifiedCert;
System.arraycopy(certs, 0, array, 1, certs.length);
certs = array;
}
@@ -693,12 +656,6 @@ public class WifiConfigController implements TextWatcher,
spinner.setAdapter(adapter);
}
- private void setCertificate(Spinner spinner, String prefix, String cert) {
- if (cert != null && cert.startsWith(prefix)) {
- setSelection(spinner, cert.substring(prefix.length()));
- }
- }
-
private void setSelection(Spinner spinner, String value) {
if (value != null) {
@SuppressWarnings("unchecked")