From ca1cad6ec5b175a85b361c45e8d2c0cac0b405ec Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 7 Dec 2017 12:49:15 +0100 Subject: #8742 basic always-on implementation with blocking vpn if no profile is configured --- .../de/blinkt/openvpn/core/ConnectionStatus.java | 1 + .../java/de/blinkt/openvpn/core/OpenVPNService.java | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'app/src/main/java/de/blinkt') diff --git a/app/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java b/app/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java index 03d842e3..3e6d23f7 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java +++ b/app/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java @@ -21,6 +21,7 @@ public enum ConnectionStatus implements Parcelable { LEVEL_START, LEVEL_AUTH_FAILED, LEVEL_WAITING_FOR_USER_INPUT, + LEVEL_BLOCKING, // used for Bitmask's VoidVPN UNKNOWN_LEVEL; @Override 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 ded7490a..86e1bb02 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -115,6 +115,11 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac public boolean stopVPN(boolean replaceConnection) throws RemoteException { return OpenVPNService.this.stopVPN(replaceConnection); } + + @Override + public boolean isVpnRunning() throws RemoteException { + return OpenVPNService.this.isVpnRunning(); + } }; // From: http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java @@ -412,6 +417,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac } + @Override public void userPause(boolean shouldBePaused) { if (mDeviceStateReceiver != null) mDeviceStateReceiver.userPause(shouldBePaused); @@ -425,6 +431,20 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac return false; } + /** + * used in Bitmask + */ + @Override + public boolean isVpnRunning() { + boolean hasVPNProcessThread = false; + synchronized (mProcessLock) { + hasVPNProcessThread = mProcessThread != null && mProcessThread.isAlive(); + } + + return hasVPNProcessThread; + + } + @Override public int onStartCommand(Intent intent, int flags, int startId) { -- cgit v1.2.3