summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/de/blinkt/openvpn/OnBootReceiver.java4
-rw-r--r--main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java2
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java1
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java19
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java2
-rwxr-xr-xmain/src/main/res/values/strings.xml4
-rw-r--r--main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt6
-rw-r--r--main/src/ui/java/de/blinkt/openvpn/fragments/SendDumpFragment.java7
-rw-r--r--main/src/ui/res/xml/general_settings.xml4
9 files changed, 36 insertions, 13 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/OnBootReceiver.java b/main/src/main/java/de/blinkt/openvpn/OnBootReceiver.java
index 4827bf10..58c954c9 100644
--- a/main/src/main/java/de/blinkt/openvpn/OnBootReceiver.java
+++ b/main/src/main/java/de/blinkt/openvpn/OnBootReceiver.java
@@ -23,8 +23,8 @@ public class OnBootReceiver extends BroadcastReceiver {
final String action = intent.getAction();
SharedPreferences prefs = Preferences.getDefaultSharedPreferences(context);
- boolean useStartOnBoot = prefs.getBoolean("restartvpnonboot", false);
- if (!useStartOnBoot)
+ boolean alwaysActive = prefs.getBoolean("restartvpnonboot", false);
+ if (!alwaysActive)
return;
if(Intent.ACTION_BOOT_COMPLETED.equals(action) || Intent.ACTION_MY_PACKAGE_REPLACED.equals(action)) {
diff --git a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
index 8573af79..c6a4339a 100644
--- a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
+++ b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
@@ -341,7 +341,7 @@ public class ExternalOpenVPNService extends Service implements StateListener {
- class UpdateMessage {
+ static class UpdateMessage {
public String state;
public String logmessage;
public ConnectionStatus level;
diff --git a/main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java b/main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java
index d102dce2..39151646 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java
@@ -42,7 +42,6 @@ public class ExtAuthHelper {
public static void setExternalAuthProviderSpinnerList(Spinner spinner, String selectedApp) {
Context c = spinner.getContext();
- final PackageManager pm = c.getPackageManager();
ArrayList<ExternalAuthProvider> extProviders = getExternalAuthProviderList(c);
int selectedPos = -1;
diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
index 9e42378b..39aaef57 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -20,6 +20,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutManager;
import android.content.res.Configuration;
@@ -228,8 +229,22 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
endVpnService();
}
+ private boolean isAlwaysActiveEnabled()
+ {
+ SharedPreferences prefs = Preferences.getDefaultSharedPreferences(this);
+ return prefs.getBoolean("restartvpnonboot", false);
+ }
+
+ boolean isVpnAlwaysOnEnabled() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ return isAlwaysOn();
+ }
+ return false;
+ }
+
+
private void endVpnService() {
- if (!isAlwaysOn()) {
+ if (!isVpnAlwaysOnEnabled() && !isAlwaysActiveEnabled()) {
/* if we should be an always on VPN, keep the timer running */
keepVPNAlive.unscheduleKeepVPNAliveJobService(this);
}
@@ -883,6 +898,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
/* On Tiramisu we install the routes exactly like promised */
VpnStatus.logDebug(R.string.routes_debug, TextUtils.join(", ", positiveIPv4Routes), TextUtils.join(", ", positiveIPv6Routes));
}
+ //VpnStatus.logInfo(String.format("Always active %s", isAlwaysOn() ? "on" : "off"));
+
setAllowedVpnPackages(builder);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
// VPN always uses the default network
diff --git a/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java b/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
index 9f5c3ab5..1f12c2fa 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
@@ -51,7 +51,7 @@ public class ProfileManager {
return instance.profiles.get(key);
}
- private static void checkInstance(Context context) {
+ private synchronized static void checkInstance(Context context) {
if (instance == null) {
instance = new ProfileManager();
ProfileEncryption.initMasterCryptAlias();
diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml
index f68d6983..a83d091b 100755
--- a/main/src/main/res/values/strings.xml
+++ b/main/src/main/res/values/strings.xml
@@ -203,8 +203,8 @@
<string name="using_proxy">Using proxy %1$s %2$s</string>
<string name="use_system_proxy">Use system proxy</string>
<string name="use_system_proxy_summary">Use the system wide configuration for HTTP/HTTPS proxies to connect.</string>
- <string name="onbootrestartsummary">OpenVPN will connect the specified VPN if it was active on system boot. Please read the connection warning FAQ before using this option on Android &lt; 5.0.</string>
- <string name="onbootrestart">Connect on boot</string>
+ <string name="keep_vpn_connected_summary">OpenVPN will connect the specified VPN on system boot and will try to keep the VPN connected.</string>
+ <string name="keep_vpn_connected">Keep VPN connected</string>
<string name="ignore">Ignore</string>
<string name="restart">Restart</string>
<string name="restart_vpn_after_change">Configuration changes are applied after restarting the VPN. (Re)start the VPN now?</string>
diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt b/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt
index 3c878d4d..6ba7c6fd 100644
--- a/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt
+++ b/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt
@@ -73,8 +73,10 @@ class GeneralSettings : PreferenceFragmentCompat(), Preference.OnPreferenceClick
findPreference<Preference>("restartvpnonboot") as CheckBoxPreference
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- val vpn:VpnService = VpnService()
- startOnBoot.isChecked = vpn.isAlwaysOn
+ val vpn = VpnService()
+ if (vpn.isAlwaysOn)
+ /* This is not reliable when the VPN is not active */
+ startOnBoot.isChecked
}
startOnBoot.onPreferenceChangeListener =
diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/SendDumpFragment.java b/main/src/ui/java/de/blinkt/openvpn/fragments/SendDumpFragment.java
index 6d4d2968..ae90f3d5 100644
--- a/main/src/ui/java/de/blinkt/openvpn/fragments/SendDumpFragment.java
+++ b/main/src/ui/java/de/blinkt/openvpn/fragments/SendDumpFragment.java
@@ -36,7 +36,12 @@ public class SendDumpFragment extends Fragment {
if (c.getCacheDir() == null)
return null;
- for (File f : c.getCacheDir().listFiles()) {
+ File[] filesList = c.getCacheDir().listFiles();
+
+ if (filesList == null)
+ return null;
+
+ for (File f : filesList) {
if (!f.getName().endsWith(".dmp"))
continue;
diff --git a/main/src/ui/res/xml/general_settings.xml b/main/src/ui/res/xml/general_settings.xml
index 55eedb94..a1920aaf 100644
--- a/main/src/ui/res/xml/general_settings.xml
+++ b/main/src/ui/res/xml/general_settings.xml
@@ -39,8 +39,8 @@
<CheckBoxPreference
android:defaultValue="false"
android:key="restartvpnonboot"
- android:summary="@string/onbootrestartsummary"
- android:title="@string/onbootrestart"/>
+ android:summary="@string/keep_vpn_connected_summary"
+ android:title="@string/keep_vpn_connected"/>
<CheckBoxPreference
android:defaultValue="true"