Skip to content

Commit

Permalink
Allow setting restart VPN on Boot setting via App restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
schwabe committed Nov 11, 2023
1 parent 5efca0f commit 823cb52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ private static void setMiscSettings(Context c, Bundle restrictions) {
editor.putBoolean("screenoff", pauseVPN);
editor.apply();
}
if (restrictions.containsKey("restartvpnonboot"))
{
boolean restartVPNonBoot = restrictions.getBoolean("restartvpnonboot");
SharedPreferences.Editor editor = defaultPrefs.edit();
editor.putBoolean("restartvpnonboot", restartVPNonBoot);
editor.apply();
}
}

private void importVPNProfiles(Context c, Bundle restrictions, Parcelable[] profileList) {
Expand All @@ -155,6 +162,7 @@ private void importVPNProfiles(Context c, Bundle restrictions, Parcelable[] prof
String defaultprofile = restrictions.getString("defaultprofile", null);
boolean defaultprofileProvisioned = false;


ProfileManager pm = ProfileManager.getInstance(c);
for (Parcelable profile : profileList) {
if (!(profile instanceof Bundle)) {
Expand Down
1 change: 1 addition & 0 deletions main/src/main/res/values/untranslatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<string name="faq_title_ncp">Failed to negotiate cipher with server</string>
<string name="import_from_URL">URL</string>
<string name="restriction_pausevpn">Pause VPN when screen is off and less than 64 kB transferred data in 60s</string>
<string name="restriction_restartvpnonboot">Enable the workaround to use an on boot receiver to start the VPN if the Always On VPN functionality is not available</string>
<string name="apprest_aidl_list">List of apps that are allowed to use the remote AIDL. If this list is in the restrictions, the app will not allowed any changes to the list by the user. Package names of allowed apps separated by comma, space or newlines</string>
<string name="apprest_remoteaidl">Remote API access</string>

Expand Down
5 changes: 5 additions & 0 deletions main/src/main/res/xml/app_restrictions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
android:key="screenoffpausevpn"
android:restrictionType="bool"
android:title="@string/restriction_pausevpn" />
<restriction
android:key="restartvpnonboot"
android:restrictionType="bool"
android:title="@string/restriction_restartvpnonboot" />

<restriction
android:description="@string/apprest_aidl_list"
android:key="allowed_remote_access"
Expand Down

0 comments on commit 823cb52

Please sign in to comment.