summaryrefslogtreecommitdiff
path: root/app/src/main/java/de
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2019-07-12 18:02:49 +0200
committercyBerta <cyberta@riseup.net>2019-07-12 18:02:54 +0200
commit045675a8cf2b7bf377ab86fa3196949e1684cc44 (patch)
tree310f86ac51a66d44d4a62a7363b2ad2dcbb5918e /app/src/main/java/de
parent2979517d1401a42eedcadfbe33af4af02ef0afac (diff)
* use static atomicBoolean to save alwaysOn settings instead of sharedPrefs
>> avoid race conditions between sharedPreference writing and onBoot receiver reading * don't explicitly exclude Bitmask from routes
Diffstat (limited to 'app/src/main/java/de')
-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
2 files changed, 14 insertions, 11 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();
+ }
}