use of android.net.vpn.OpenvpnProfile in project android_packages_apps_Settings by LineageOS.
the class OpenvpnEditor method loadExtraPreferencesTo.
@Override
protected void loadExtraPreferencesTo(PreferenceGroup subpanel) {
final Context c = subpanel.getContext();
final OpenvpnProfile profile = (OpenvpnProfile) getProfile();
mUserAuth = new CheckBoxPreference(c);
mUserAuth.setTitle(R.string.vpn_openvpn_userauth);
mUserAuth.setSummary(R.string.vpn_openvpn_userauth_summary);
mUserAuth.setChecked(profile.getUserAuth());
mUserAuth.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference pref, Object newValue) {
boolean enabled = (Boolean) newValue;
profile.setUserAuth(enabled);
mUserAuth.setChecked(enabled);
return true;
}
});
subpanel.addPreference(mUserAuth);
mCACert = createList(c, R.string.vpn_ca_certificate_title, profile.getCAName(), mKeyStore.saw(Credentials.CA_CERTIFICATE), new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference pref, Object newValue) {
String f = (String) newValue;
profile.setCAName(f);
setSummary(mCACert, R.string.vpn_ca_certificate, profile.getCAName());
return true;
}
});
setSummary(mCACert, R.string.vpn_ca_certificate, profile.getCAName());
subpanel.addPreference(mCACert);
mCert = createList(c, R.string.vpn_user_certificate_title, profile.getCertName(), mKeyStore.saw(Credentials.USER_CERTIFICATE), new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference pref, Object newValue) {
String f = (String) newValue;
profile.setCertName(f);
setSummary(mCert, R.string.vpn_user_certificate, profile.getCertName());
return true;
}
});
setSummary(mCert, R.string.vpn_user_certificate, profile.getCertName());
subpanel.addPreference(mCert);
}
use of android.net.vpn.OpenvpnProfile in project android_packages_apps_Settings by LineageOS.
the class OpenvpnEditor method onActivityResult.
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
if (requestCode != REQUEST_ADVANCED)
return;
OpenvpnProfile p = (OpenvpnProfile) getProfile();
OpenvpnProfile newP = data.getParcelableExtra(KEY_PROFILE);
if (newP == null) {
Log.e(TAG, "no profile from advanced settings");
return;
}
// manually copy across all advanced settings
p.setPort(newP.getPort());
p.setProto(newP.getProto());
p.setDevice(newP.getDevice());
p.setUseCompLzo(newP.getUseCompLzo());
p.setRedirectGateway(newP.getRedirectGateway());
p.setSupplyAddr(newP.getSupplyAddr());
p.setLocalAddr(newP.getLocalAddr());
p.setRemoteAddr(newP.getRemoteAddr());
p.setCipher(newP.getCipher());
p.setKeySize(newP.getKeySize());
p.setExtra(newP.getExtra());
}
Aggregations