diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-03-26 14:58:36 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-03-29 14:22:55 +0000 |
| commit | d9c7a3bedf094835473898c4b3ac92701a661049 (patch) | |
| tree | 7eaa17a2a781bc896d82bd4f2644dda7205bf84d /android/src | |
| parent | f62238c646cb27299863ec7fb3c0ad06e1f59fe6 (diff) | |
| download | mullvadvpn-d9c7a3bedf094835473898c4b3ac92701a661049.tar.xz mullvadvpn-d9c7a3bedf094835473898c4b3ac92701a661049.zip | |
Remove synchronization blocks
This is safe because all the code is running in the UI thread. There was
one coroutine to reset the reconnection expected flag that wasn't
running in the UI thread, but since it's a really simple task it was
moved to the UI thread as well.
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt index 973d57a298..ddb75f85b0 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WireguardKeyFragment.kt @@ -145,18 +145,16 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre override fun onSafelyStart() { connectionProxy.onUiStateChange.subscribe(this) { uiState -> jobTracker.newUiJob("tunnelStateUpdate") { - synchronized(this@WireguardKeyFragment) { - tunnelState = uiState + tunnelState = uiState - if (actionState is ActionState.Generating) { - reconnectionExpected = !(tunnelState is TunnelState.Disconnected) - } else if (tunnelState is TunnelState.Connected) { - reconnectionExpected = false - } - - isOffline = uiState is TunnelState.Error && - uiState.errorState.cause is ErrorStateCause.IsOffline + if (actionState is ActionState.Generating) { + reconnectionExpected = !(tunnelState is TunnelState.Disconnected) + } else if (tunnelState is TunnelState.Connected) { + reconnectionExpected = false } + + isOffline = uiState is TunnelState.Error && + uiState.errorState.cause is ErrorStateCause.IsOffline } } @@ -312,10 +310,8 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre } private suspend fun onGenerateKeyPress() { - synchronized(this) { - actionState = ActionState.Generating(keyStatus is KeygenEvent.NewKey) - reconnectionExpected = !(tunnelState is TunnelState.Disconnected) - } + actionState = ActionState.Generating(keyStatus is KeygenEvent.NewKey) + reconnectionExpected = !(tunnelState is TunnelState.Disconnected) keyStatus = null keyStatusListener.generateKey().join() @@ -330,7 +326,7 @@ class WireguardKeyFragment : ServiceDependentFragment(OnNoService.GoToLaunchScre } private fun resetReconnectionExpected() { - jobTracker.newBackgroundJob("resetReconnectionExpected") { + jobTracker.newUiJob("resetReconnectionExpected") { delay(20_000) if (reconnectionExpected) { |
