summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2021-01-05 00:14:09 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2021-04-12 13:19:37 +0000
commit8304178db9bddea937dd73c944d3f70ea11a10b9 (patch)
tree8b5f37a5f50176587922da7494c6d3157f5d417f /android/src
parent5cb56b98fcb259a00f7c212ece231ea468e0a169 (diff)
downloadmullvadvpn-8304178db9bddea937dd73c944d3f70ea11a10b9.tar.xz
mullvadvpn-8304178db9bddea937dd73c944d3f70ea11a10b9.zip
Use `ConnectionProxy` in `LocationInfoCache`
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt2
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt11
2 files changed, 5 insertions, 8 deletions
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 a12b7c5f94..83c62cd5f3 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
@@ -243,8 +243,6 @@ class MullvadVpnService : TalpidVpnService() {
handlePendingAction(settings)
- endpoint.locationInfoCache.stateEvents = connectionProxy.onStateChange
-
if (state == State.Running) {
instance = ServiceInstance(
endpoint.messenger,
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt
index 2f118ede6d..df769abad9 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/LocationInfoCache.kt
@@ -20,7 +20,6 @@ import net.mullvad.mullvadvpn.model.RelaySettings
import net.mullvad.mullvadvpn.model.TunnelState
import net.mullvad.mullvadvpn.util.ExponentialBackoff
import net.mullvad.talpid.tunnel.ActionAfterDisconnect
-import net.mullvad.talpid.util.autoSubscribable
class LocationInfoCache(private val endpoint: ServiceEndpoint) {
companion object {
@@ -70,11 +69,11 @@ class LocationInfoCache(private val endpoint: ServiceEndpoint) {
}
}
- var stateEvents by autoSubscribable<TunnelState>(this, TunnelState.Disconnected) { newState ->
- state = newState
- }
-
init {
+ endpoint.connectionProxy.onStateChange.subscribe(this) { newState ->
+ state = newState
+ }
+
endpoint.connectivityListener.connectivityNotifier.subscribe(this) { isConnected ->
if (isConnected && state is TunnelState.Disconnected) {
fetchRequestChannel.sendBlocking(RequestFetch.ForRealLocation)
@@ -85,9 +84,9 @@ class LocationInfoCache(private val endpoint: ServiceEndpoint) {
}
fun onDestroy() {
+ endpoint.connectionProxy.onStateChange.unsubscribe(this)
endpoint.connectivityListener.connectivityNotifier.unsubscribe(this)
endpoint.settingsListener.relaySettingsNotifier.unsubscribe(this)
- stateEvents = null
fetchRequestChannel.close()
}