summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java13
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java3
3 files changed, 16 insertions, 12 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
index 4e92f67b..bf9b3ac3 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -44,7 +44,6 @@ import de.blinkt.openvpn.core.VpnStatus.ByteCountListener;
import de.blinkt.openvpn.core.VpnStatus.StateListener;
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.VpnNotificationManager;
-import se.leap.bitmaskclient.utils.PreferenceHelper;
import static de.blinkt.openvpn.core.ConnectionStatus.LEVEL_CONNECTED;
import static de.blinkt.openvpn.core.ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT;
@@ -319,14 +318,15 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
updateShortCutUsage(mProfile);
}
- PreferenceHelper.setAlwaysOn(this, false);
+ VpnStatus.setAlwaysOn(false);
+
} else {
/* The intent is null when we are set as always-on or the service has been restarted. */
mProfile = VpnStatus.getLastConnectedVpnProfile(this);
VpnStatus.logInfo(R.string.service_restarted);
if (mProfile != null) {
- PreferenceHelper.setAlwaysOn(this, true);
+ VpnStatus.setAlwaysOn(true);
}
}
@@ -543,13 +543,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
if (mProfile.mAllowLocalLAN) {
allowAllAFFamilies(builder);
}
- if (PreferenceHelper.isAlwaysOn(this)) {
- try {
- builder.addDisallowedApplication(this.getPackageName());
- } catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
- }
- }
}
if (mLocalIP == null && mLocalIPv6 == null) {
diff --git a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
index 33851b8f..c362e299 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java
@@ -17,6 +17,7 @@ import java.util.LinkedList;
import java.util.Locale;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
import de.blinkt.openvpn.VpnProfile;
import se.leap.bitmaskclient.R;
@@ -33,6 +34,8 @@ public class VpnStatus {
private static CopyOnWriteArrayList<StateListener> stateListener;
private static Vector<ByteCountListener> byteCountListener;
+ private static AtomicBoolean isAlwaysOnBooting = new AtomicBoolean(false);
+
private static String mLaststatemsg = "";
private static String mLaststate = "NOPROCESS";
@@ -504,7 +507,6 @@ public class VpnStatus {
}
-
public static synchronized void updateByteCount(long in, long out) {
TrafficHistory.LastDiff diff = trafficHistory.add(in, out);
@@ -512,4 +514,12 @@ public class VpnStatus {
bcl.updateByteCount(in, out, diff.getDiffIn(), diff.getDiffOut());
}
}
+
+ public static void setAlwaysOn(boolean alwaysOn) {
+ isAlwaysOnBooting.set(alwaysOn);
+ }
+
+ public static boolean isAlwaysOn() {
+ return isAlwaysOnBooting.get();
+ }
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
index 8339b033..2efce9e4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
@@ -6,6 +6,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
+import de.blinkt.openvpn.core.VpnStatus;
import se.leap.bitmaskclient.utils.PreferenceHelper;
import static android.content.Intent.ACTION_BOOT_COMPLETED;
@@ -29,7 +30,7 @@ public class OnBootReceiver extends BroadcastReceiver {
preferences = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE);
boolean providerConfigured = !preferences.getString(PROVIDER_VPN_CERTIFICATE, "").isEmpty();
boolean startOnBoot = preferences.getBoolean(EIP_RESTART_ON_BOOT, false);
- boolean isAlwaysOnConfigured = PreferenceHelper.isAlwaysOn(context);
+ boolean isAlwaysOnConfigured = VpnStatus.isAlwaysOn();
Log.d("OpenVPN", "OpenVPN onBoot intent received. Provider configured? " + providerConfigured + " Start on boot? " + startOnBoot + " isAlwaysOn feature configured: " + isAlwaysOnConfigured);
if (providerConfigured) {
if (isAlwaysOnConfigured) {