diff options
author | Arne Schwabe <arne@rfc2549.org> | 2013-12-01 14:14:24 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2013-12-01 14:14:24 +0100 |
commit | e827c55cdd14588585b1d12e4f8cba0ffb69381d (patch) | |
tree | 96d044d71ac7fd12a1167314d9385316ea8f3a2f /src/de/blinkt | |
parent | d5e947f2dd9ba93a4bb6a801d0ef8ad21d43d8d2 (diff) |
Implementing user pause/resume from the external API
Diffstat (limited to 'src/de/blinkt')
-rw-r--r-- | src/de/blinkt/openvpn/api/ExternalOpenVPNService.java | 15 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl | 6 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/core/OpenVpnService.java | 6 |
3 files changed, 27 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/src/de/blinkt/openvpn/api/ExternalOpenVPNService.java index 34b61325..765bc23d 100644 --- a/src/de/blinkt/openvpn/api/ExternalOpenVPNService.java +++ b/src/de/blinkt/openvpn/api/ExternalOpenVPNService.java @@ -217,6 +217,21 @@ public class ExternalOpenVPNService extends Service implements StateListener { if (mService != null && mService.getManagement() != null)
mService.getManagement().stopVPN();
}
+
+ @Override
+ public void pause() throws RemoteException {
+ checkOpenVPNPermission();
+ if (mService != null)
+ mService.userPause(true);
+ }
+
+ @Override
+ public void resume() throws RemoteException {
+ checkOpenVPNPermission();
+ if (mService != null)
+ mService.userPause(false);
+
+ }
};
diff --git a/src/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl b/src/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl index 6c1624fa..794e3aad 100644 --- a/src/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl +++ b/src/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl @@ -30,6 +30,12 @@ interface IOpenVPNAPIService { /* Disconnect the VPN */
void disconnect();
+
+ /* Pause the VPN (same as using the pause feature in the notifcation bar) */
+ void pause();
+
+ /* Resume the VPN (same as using the pause feature in the notifcation bar) */
+ void resume();
/**
* Registers to receive OpenVPN Status Updates
diff --git a/src/de/blinkt/openvpn/core/OpenVpnService.java b/src/de/blinkt/openvpn/core/OpenVpnService.java index ab21fc1b..3a6cc802 100644 --- a/src/de/blinkt/openvpn/core/OpenVpnService.java +++ b/src/de/blinkt/openvpn/core/OpenVpnService.java @@ -256,6 +256,12 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac mDeviceStateReceiver = null; } + public void userPause (boolean shouldBePaused) + { + if (mDeviceStateReceiver != null) + mDeviceStateReceiver.userPause(shouldBePaused); + } + @Override public int onStartCommand(Intent intent, int flags, int startId) { |