diff options
3 files changed, 8 insertions, 2 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt index 59814d0923..5563c2f10f 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt @@ -21,6 +21,7 @@ const val MAX_RETRIES: Int = 17 // ceil(log2(MAX_DELAY / DELAY_SCALE) + 1) class LocationInfoCache( val daemon: MullvadDaemon, + val connectionProxy: ConnectionProxy, val connectivityListener: ConnectivityListener ) { private var activeFetch: Job? = null @@ -34,6 +35,10 @@ class LocationInfoCache( } } + private val realStateListenerId = connectionProxy.onStateChange.subscribe { realState -> + state = realState + } + var onNewLocation: ((GeoIpLocation?) -> Unit)? = null set(value) { field = value @@ -81,6 +86,7 @@ class LocationInfoCache( fun onDestroy() { connectivityListener.connectivityNotifier.unsubscribe(connectivityListenerId) + connectionProxy.onStateChange.unsubscribe(realStateListenerId) activeFetch?.cancel() } diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt index 5d1b92a1fc..4df3ff6791 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -176,7 +176,8 @@ class MullvadVpnService : TalpidVpnService() { pendingAction = null } - val newLocationInfoCache = LocationInfoCache(newDaemon, connectivityListener) + val newLocationInfoCache = + LocationInfoCache(newDaemon, newConnectionProxy, connectivityListener) daemon = newDaemon connectionProxy = newConnectionProxy diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt index 7f296657a6..2d8645b6be 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt @@ -123,7 +123,6 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) { private fun updateTunnelState(uiState: TunnelState, realState: TunnelState) = GlobalScope.launch(Dispatchers.Main) { notificationBanner.tunnelState = realState - locationInfoCache.state = realState locationInfo.state = realState headerBar.setState(realState) status.setState(realState) |
