From e827c55cdd14588585b1d12e4f8cba0ffb69381d Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sun, 1 Dec 2013 14:14:24 +0100 Subject: Implementing user pause/resume from the external API --- src/de/blinkt/openvpn/api/ExternalOpenVPNService.java | 15 +++++++++++++++ src/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl | 6 ++++++ src/de/blinkt/openvpn/core/OpenVpnService.java | 6 ++++++ 3 files changed, 27 insertions(+) (limited to 'src') 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) { -- cgit v1.2.3