Hi all, Has there been any discussion on forcing the Quick Settings tile for Android to check if the device is unlocked prior to allowing interaction with tunnels?
According to https://developer.android.com/reference/android/service/quicksettings/TileService -- isLocked() can be used to ensure the device is unlocked by an authenticated user before initiating or terminating existing tunnels. Attached is a crude patch which adds this functionality. - Simon
From ff0f8ceb83dbdbbf9c218033b061f8c5713dde6c Mon Sep 17 00:00:00 2001 From: Simon <[email protected]> Subject: [PATCH] Force QuickSettings toggle to be 'secure' --- .../wireguard/android/QuickTileService.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/wireguard/android/QuickTileService.java b/app/src/main/java/com/wireguard/android/QuickTileService.java index 425738e..5ac7765 100644 --- a/app/src/main/java/com/wireguard/android/QuickTileService.java +++ b/app/src/main/java/com/wireguard/android/QuickTileService.java @@ -59,18 +59,24 @@ public class QuickTileService extends TileService { @Override public void onClick() { - if (tunnel != null) { - final Tile tile = getQsTile(); - if (tile != null) { - tile.setIcon(tile.getIcon() == iconOn ? iconOff : iconOn); - tile.updateTile(); - } - tunnel.setState(State.TOGGLE).whenComplete(this::onToggleFinished); - } else { + if (!isLocked()) { + if (tunnel != null) { + final Tile tile = getQsTile(); + if (tile != null) { + tile.setIcon(tile.getIcon() == iconOn ? iconOff : iconOn); + tile.updateTile(); + } + tunnel.setState(State.TOGGLE).whenComplete(this::onToggleFinished); + } else { + final Intent intent = new Intent(this, MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivityAndCollapse(intent); + } + } else { /* This is already a 'secure' call for unlockAndRun */ final Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivityAndCollapse(intent); - } + } } @Override -- 2.21.0
_______________________________________________ WireGuard mailing list [email protected] https://lists.zx2c4.com/mailman/listinfo/wireguard
