Skip to content

Commit 153023c

Browse files
committed
Add isAlwaysOn and isLockdownEnabled
1 parent b996989 commit 153023c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tunnel/src/main/java/com/wireguard/android/backend/Backend.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@ public interface Backend {
5252
*/
5353
String getVersion() throws Exception;
5454

55+
/**
56+
* Determines whether the service is running in always-on VPN mode.
57+
* In this mode the system ensures that the service is always running by restarting it when necessary,
58+
* e.g. after reboot.
59+
*
60+
* @returns A boolean indicating whether the service is running in always-on VPN mode.
61+
* @throws Exception Exception raised while retrieving the always-on status.
62+
*/
63+
64+
boolean isAlwaysOn() throws Exception;
65+
66+
/**
67+
* Determines whether the service is running in always-on VPN lockdown mode.
68+
* In this mode the system ensures that the service is always running and that the apps
69+
* aren't allowed to bypass the VPN.
70+
*
71+
* @returns A boolean indicating whether the service is running in always-on VPN lockdown mode.
72+
* @throws Exception Exception raised while retrieving the lockdown status.
73+
*/
74+
75+
boolean isLockdownEnabled() throws Exception;
76+
5577
/**
5678
* Set the state of a tunnel, updating it's configuration. If the tunnel is already up, config
5779
* may update the running configuration; config may be null when setting the tunnel down.

tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ public String getVersion() {
188188
return wgVersion();
189189
}
190190

191+
/**
192+
* Determines if the service is running in always-on VPN mode.
193+
* @return {@link boolean} whether the service is running in always-on VPN mode.
194+
*/
195+
@Override
196+
public boolean isAlwaysOn() {
197+
return vpnService.get(0, TimeUnit.NANOSECONDS).isAlwaysOn();
198+
}
199+
200+
/**
201+
* Determines if the service is running in always-on VPN lockdown mode.
202+
* @return {@link boolean} whether the service is running in always-on VPN lockdown mode.
203+
*/
204+
@Override
205+
public boolean isLockdownEnabled() {
206+
return vpnService.get(0, TimeUnit.NANOSECONDS).isLockdownEnabled();
207+
}
208+
191209
/**
192210
* Change the state of a given {@link Tunnel}, optionally applying a given {@link Config}.
193211
*

0 commit comments

Comments
 (0)