use of android.net.vpn.VpnProfile in project android_packages_apps_Settings by LineageOS.
the class VpnSettings method deleteProfile.
// position: position in mVpnProfileList
private void deleteProfile(final int position) {
if ((position < 0) || (position >= mVpnProfileList.size()))
return;
DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (which == OK_BUTTON) {
VpnProfile p = mVpnProfileList.remove(position);
VpnPreference pref = mVpnPreferenceMap.remove(p.getName());
mVpnListContainer.removePreference(pref);
removeProfileFromStorage(p);
}
}
};
mShowingDialog = new AlertDialog.Builder(this).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(R.string.vpn_confirm_profile_deletion).setPositiveButton(android.R.string.ok, onClickListener).setNegativeButton(R.string.vpn_no_button, onClickListener).create();
mShowingDialog.show();
}
use of android.net.vpn.VpnProfile in project android_packages_apps_Settings by LineageOS.
the class VpnSettings method setProfileId.
// Randomly generates an ID for the profile.
// The ID is unique and only set once when the profile is created.
private void setProfileId(VpnProfile profile) {
String id;
while (true) {
id = String.valueOf(Math.abs(Double.doubleToLongBits(Math.random())));
if (id.length() >= 8)
break;
}
for (VpnProfile p : mVpnProfileList) {
if (p.getId().equals(id)) {
setProfileId(profile);
return;
}
}
profile.setId(id);
}
use of android.net.vpn.VpnProfile in project android_packages_apps_Settings by LineageOS.
the class VpnSettings method deserialize.
private VpnProfile deserialize(File profileObjectFile) throws IOException {
try {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(profileObjectFile));
VpnProfile p = (VpnProfile) ois.readObject();
ois.close();
return p;
} catch (ClassNotFoundException e) {
Log.d(TAG, "deserialize a profile", e);
return null;
}
}
use of android.net.vpn.VpnProfile in project android_packages_apps_Settings by LineageOS.
the class VpnEditor method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
VpnProfile p = (VpnProfile) ((savedInstanceState == null) ? getIntent().getParcelableExtra(VpnSettings.KEY_VPN_PROFILE) : savedInstanceState.getParcelable(KEY_PROFILE));
mProfileEditor = getEditor(p);
mAddingProfile = TextUtils.isEmpty(p.getName());
// Loads the XML preferences file
addPreferencesFromResource(R.xml.vpn_edit);
initViewFor(p);
Parcel parcel = Parcel.obtain();
p.writeToParcel(parcel, 0);
mOriginalProfileData = parcel.marshall();
}
Aggregations