summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2022-06-09 11:00:12 +0200
committerAlbin <albin@mullvad.net>2022-06-15 10:25:32 +0200
commitd4bc0265f16b15af130c393b5da523097fcc6efe (patch)
treecc7ad9d5eca16b000be05ac6f2944df054e06d85 /android
parentd05e8a02403d32203412d1b7c16a5267d9b43055 (diff)
downloadmullvadvpn-d4bc0265f16b15af130c393b5da523097fcc6efe.tar.xz
mullvadvpn-d4bc0265f16b15af130c393b5da523097fcc6efe.zip
Ensure all device events are propagated
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt8
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt3
2 files changed, 6 insertions, 5 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
index 551e61961f..380ae0dedf 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadDaemon.kt
@@ -1,7 +1,7 @@
package net.mullvad.mullvadvpn.service
-import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.asSharedFlow
import net.mullvad.mullvadvpn.model.AppVersionInfo
import net.mullvad.mullvadvpn.model.Device
import net.mullvad.mullvadvpn.model.DeviceEvent
@@ -30,8 +30,8 @@ class MullvadDaemon(vpnService: MullvadVpnService) {
var onRelayListChange: ((RelayList) -> Unit)? = null
var onDaemonStopped: (() -> Unit)? = null
- private val _deviceStateUpdates = MutableStateFlow<DeviceState>(DeviceState.InitialState)
- val deviceStateUpdates = _deviceStateUpdates.asStateFlow()
+ private val _deviceStateUpdates = MutableSharedFlow<DeviceState>(extraBufferCapacity = 1)
+ val deviceStateUpdates = _deviceStateUpdates.asSharedFlow()
init {
System.loadLibrary("mullvad_jni")
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
index c1b5b47ded..c79ade7891 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt
@@ -7,6 +7,7 @@ import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.flow.lastOrNull
import net.mullvad.mullvadvpn.ipc.Event
import net.mullvad.mullvadvpn.ipc.Request
import net.mullvad.mullvadvpn.model.AccountCreationResult
@@ -107,7 +108,7 @@ class AccountCache(private val endpoint: ServiceEndpoint) {
}
private suspend fun accountToken(): String? {
- return daemon.await().deviceStateUpdates.value.token()
+ return daemon.await().deviceStateUpdates.lastOrNull()?.token()
}
private fun spawnActor() = GlobalScope.actor<Command>(Dispatchers.Default, Channel.UNLIMITED) {