From c3cb26ce35209552c199e54566fc1fcbb5294152 Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 14 Dec 2018 00:46:46 +0800 Subject: [PATCH] Fix inconsistent behavior in onLost --- .../main/java/be/mygod/vpnhotspot/net/monitor/VpnMonitor.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/VpnMonitor.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/VpnMonitor.kt index 8dad7450..3357fab7 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/VpnMonitor.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/VpnMonitor.kt @@ -71,15 +71,13 @@ object VpnMonitor : UpstreamMonitor() { override fun onLost(network: Network) = synchronized(this@VpnMonitor) { if (available.remove(network) == null || currentNetwork != network) return + callbacks.forEach { it.onLost() } if (available.isNotEmpty()) { val next = available.entries.first() currentNetwork = next.key debugLog(TAG, "Switching to ${next.value.interfaceName} as VPN interface") callbacks.forEach { it.onAvailable(next.value.interfaceName!!, next.value.dnsServers) } - } else { - callbacks.forEach { it.onLost() } - currentNetwork = null - } + } else currentNetwork = null } }