package com.android.settings.vpn;
import com.android.settings.R;
import android.content.Context;
import android.net.vpn.L2tpIpsecProfile;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.security.Credentials;
import android.security.KeyStore;
import android.text.TextUtils;
private static final String TAG = L2tpIpsecEditor.class.getSimpleName();
private KeyStore mKeyStore = KeyStore.getInstance();
private ListPreference mUserCertificate;
private ListPreference mCaCertificate;
private L2tpIpsecProfile mProfile;
super(p);
mProfile = p;
}
@Override
protected void (PreferenceGroup subpanel) {
super.loadExtraPreferencesTo(subpanel);
Context c = subpanel.getContext();
subpanel.addPreference(createUserCertificatePreference(c));
subpanel.addPreference(createCaCertificatePreference(c));
}
@Override
String result = super.validate();
if (result == null) {
result = validate(mUserCertificate, R.string.vpn_a_user_certificate);
}
if (result == null) {
result = validate(mCaCertificate, R.string.vpn_a_ca_certificate);
}
return result;
}
mUserCertificate = createListPreference(c,
R.string.vpn_user_certificate_title,
mProfile.getUserCertificate(),
mKeyStore.saw(Credentials.USER_CERTIFICATE),
new Preference.OnPreferenceChangeListener() {
Preference pref, Object newValue) {
mProfile.setUserCertificate((String) newValue);
setSummary(pref, R.string.vpn_user_certificate,
(String) newValue);
return true;
}
});
setSummary(mUserCertificate, R.string.vpn_user_certificate,
mProfile.getUserCertificate());
return mUserCertificate;
}
mCaCertificate = createListPreference(c,
R.string.vpn_ca_certificate_title,
mProfile.getCaCertificate(),
mKeyStore.saw(Credentials.CA_CERTIFICATE),
new Preference.OnPreferenceChangeListener() {
Preference pref, Object newValue) {
mProfile.setCaCertificate((String) newValue);
setSummary(pref, R.string.vpn_ca_certificate,
(String) newValue);
return true;
}
});
setSummary(mCaCertificate, R.string.vpn_ca_certificate,
mProfile.getCaCertificate());
return mCaCertificate;
}
String text, String[] keys,
Preference.OnPreferenceChangeListener listener) {
ListPreference pref = new ListPreference(c);
pref.setTitle(titleResId);
pref.setDialogTitle(titleResId);
pref.setPersistent(true);
pref.setEntries(keys);
pref.setEntryValues(keys);
pref.setValue(text);
pref.setOnPreferenceChangeListener(listener);
return pref;
}
}