From 3907f6a4c1af2ef5925cc589eb72bc16c09ecaca Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 11 Apr 2023 19:17:55 +0200 Subject: tunnel: do not keep service running when bringing tunnel down Doing so causes the process to restart when the activity is cleared, even when no tunnel is running. I fear this might also lead to the current flurry of DeadSystemExceptions. Signed-off-by: Jason A. Donenfeld --- tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tunnel') diff --git a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java index ef06ebe7..670f04a1 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -324,6 +324,9 @@ public final class GoBackend implements Backend { currentTunnelHandle = -1; currentConfig = null; wgTurnOff(handleToClose); + try { + vpnService.get(0, TimeUnit.NANOSECONDS).stopSelf(); + } catch (final TimeoutException ignored) { } } tunnel.onStateChange(state); -- cgit v1.2.3