summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2017-12-07 12:54:36 +0100
committercyBerta <cyberta@riseup.net>2017-12-07 12:54:36 +0100
commit33d7a788cb72d189df137fe282ee90340bb2a130 (patch)
tree03ac549a8040a44af673df21bda534838ce160cf
parent95403c6cb19b2f08df187eeb5bf67030d58bb87f (diff)
#8742 add method to check if openvpn process is running
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java24
1 files changed, 22 insertions, 2 deletions
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 40d412da..3287eebc 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
+++ b/main/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
@@ -238,8 +243,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
//noinspection NewApi
nbuilder.setChannelId(channel);
if (mProfile != null)
- //noinspection NewApi
- nbuilder.setShortcutId(mProfile.getUUIDString());
+ //noinspection NewApi
+ nbuilder.setShortcutId(mProfile.getUUIDString());
}
@@ -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) {