diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-12-02 18:16:59 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-03-25 18:19:58 +0000 |
| commit | e5653d5b6a59945b9cbbb928752310c75c118a75 (patch) | |
| tree | 41bb0924314295b0f8d5c5109834ddf75311ee6e /android/src | |
| parent | 17bf2c043459daa2ec5350e542d0b122a6a099f9 (diff) | |
| download | mullvadvpn-e5653d5b6a59945b9cbbb928752310c75c118a75.tar.xz mullvadvpn-e5653d5b6a59945b9cbbb928752310c75c118a75.zip | |
Use intermittent daemon in `LocationInfoCache`
Diffstat (limited to 'android/src')
4 files changed, 12 insertions, 6 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt index 47b613816b..388f60b07e 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt @@ -11,7 +11,7 @@ sealed class Request : Message(), Parcelable { protected override val messageKey = MESSAGE_KEY @Parcelize - class RegisterListener(val listener: Messenger) : Request(), Parcelable + data class RegisterListener(val listener: Messenger) : Request(), Parcelable companion object { private const val MESSAGE_KEY = "request" 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 bd45e78ce5..ad14c45c8e 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/LocationInfoCache.kt @@ -17,13 +17,14 @@ import net.mullvad.mullvadvpn.relaylist.RelayCity import net.mullvad.mullvadvpn.relaylist.RelayCountry import net.mullvad.mullvadvpn.relaylist.RelayItem import net.mullvad.mullvadvpn.util.ExponentialBackoff +import net.mullvad.mullvadvpn.util.Intermittent import net.mullvad.talpid.ConnectivityListener import net.mullvad.talpid.tunnel.ActionAfterDisconnect class LocationInfoCache( - val daemon: MullvadDaemon, val connectionProxy: ConnectionProxy, - val connectivityListener: ConnectivityListener + val connectivityListener: ConnectivityListener, + val daemon: Intermittent<MullvadDaemon> ) { companion object { private enum class RequestFetch { @@ -131,11 +132,11 @@ class LocationInfoCache( while (true) { var fetchType = channel.receive() - var newLocation = daemon.getCurrentLocation() + var newLocation = daemon.await().getCurrentLocation() while (newLocation == null || !channel.isEmpty) { fetchType = delayOrReceive(delays, channel, fetchType) - newLocation = daemon.getCurrentLocation() + newLocation = daemon.await().getCurrentLocation() } handleNewLocation(newLocation, fetchType) 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 46719f9806..3e3b81bad2 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -247,6 +247,7 @@ class MullvadVpnService : TalpidVpnService() { instance = ServiceInstance( endpoint.messenger, daemon, + daemonInstance.intermittentDaemon, connectionProxy, connectivityListener, customDns, diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ServiceInstance.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ServiceInstance.kt index a124acfa64..f65cc3ecb2 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ServiceInstance.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ServiceInstance.kt @@ -2,11 +2,13 @@ package net.mullvad.mullvadvpn.service import android.os.Messenger import net.mullvad.mullvadvpn.service.endpoint.SettingsListener +import net.mullvad.mullvadvpn.util.Intermittent import net.mullvad.talpid.ConnectivityListener class ServiceInstance( val messenger: Messenger, val daemon: MullvadDaemon, + val intermittentDaemon: Intermittent<MullvadDaemon>, val connectionProxy: ConnectionProxy, val connectivityListener: ConnectivityListener, val customDns: CustomDns, @@ -15,7 +17,9 @@ class ServiceInstance( ) { val accountCache = AccountCache(daemon, settingsListener) val keyStatusListener = KeyStatusListener(daemon) - val locationInfoCache = LocationInfoCache(daemon, connectionProxy, connectivityListener) + + val locationInfoCache = + LocationInfoCache(connectionProxy, connectivityListener, intermittentDaemon) fun onDestroy() { accountCache.onDestroy() |
