From 86280176ed580ae1b8db58d8d47ac0053bdbb5f4 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 1 Jan 2018 02:15:34 -0600 Subject: TunnelManager: Clear primary tunnel when it's removed Signed-off-by: Samuel Holland --- app/src/main/java/com/wireguard/android/model/TunnelManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/com') diff --git a/app/src/main/java/com/wireguard/android/model/TunnelManager.java b/app/src/main/java/com/wireguard/android/model/TunnelManager.java index 5122f9bf..b6f6819d 100644 --- a/app/src/main/java/com/wireguard/android/model/TunnelManager.java +++ b/app/src/main/java/com/wireguard/android/model/TunnelManager.java @@ -70,7 +70,11 @@ public final class TunnelManager { Log.v(TAG, "Requested delete tunnel " + tunnel.getName() + " state=" + tunnel.getState()); return backend.setState(tunnel, State.DOWN) .thenCompose(x -> configStore.delete(tunnel.getName())) - .thenAccept(x -> tunnels.remove(tunnel.getName())); + .thenAccept(x -> { + tunnels.remove(tunnel.getName()); + if (tunnel.getName().equals(preferences.getString(KEY_PRIMARY_TUNNEL, null))) + preferences.edit().remove(KEY_PRIMARY_TUNNEL).apply(); + }); } public TunnelCollection getTunnels() { -- cgit v1.2.3