summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt26
1 files changed, 10 insertions, 16 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt
index 3f1efab066..be0458e66a 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ConnectionProxy.kt
@@ -22,31 +22,25 @@ class ConnectionProxy(val context: Context, val daemon: MullvadDaemon) {
private var activeAction: Job? = null
private var resetAnticipatedStateJob: Job? = null
- private val fetchInitialStateJob = fetchInitialState()
private val initialState: TunnelState = TunnelState.Disconnected()
- var state = initialState
- private set(value) {
- field = value
- resetAnticipatedStateJob?.cancel()
- onStateChange.notify(value)
- uiState = value
- }
+ var onStateChange = EventNotifier(initialState)
+ var onUiStateChange = EventNotifier(initialState)
+ var vpnPermission = CompletableDeferred<Boolean>()
- var uiState = initialState
- private set(value) {
- field = value
- onUiStateChange.notify(value)
- }
+ var state by onStateChange.notifiable()
+ private set
+ var uiState by onUiStateChange.notifiable()
+ private set
- var onUiStateChange = EventNotifier(uiState)
- var onStateChange = EventNotifier(state)
- var vpnPermission = CompletableDeferred<Boolean>()
+ private val fetchInitialStateJob = fetchInitialState()
init {
daemon.onTunnelStateChange = { newState ->
synchronized(this) {
+ resetAnticipatedStateJob?.cancel()
state = newState
+ uiState = newState
}
}
}