diff options
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt | 55 |
2 files changed, 28 insertions, 29 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 40f7767a4d..c6b11b1526 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,8 @@ Line wrap the file at 100 chars. Th - Fix UI not updating in split screen mode when the window is unfocused. - Fix split tunneling not being correctly configured after restarting the app. - Fix app reopening after pressing the Quit button because app was running multiple tasks. +- Fix inconsistent behavior of the quick-settings tile when logged out. It would sometimes enter the + blocking state and sometimes open the UI for the user to login. Now it always opens the UI. ## [2020.6-beta2] - 2020-08-27 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 9ee87d015e..1bd29ba2fa 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -68,20 +68,14 @@ class MullvadVpnService : TalpidVpnService() { private lateinit var notificationManager: ForegroundNotificationManager private lateinit var tunnelStateUpdater: TunnelStateUpdater - private var pendingAction: PendingAction? = null - set(value) { - field = value - - instance?.connectionProxy?.let { activeConnectionProxy -> - when (value) { - PendingAction.Connect -> activeConnectionProxy.connect() - PendingAction.Disconnect -> activeConnectionProxy.disconnect() - null -> {} - } - - field = null - } + private var pendingAction by observable<PendingAction?>(null) { _, _, action -> + instance?.let { activeInstance -> + handlePendingAction( + activeInstance.connectionProxy, + activeInstance.settingsListener.settings + ) } + } private var isBound by observable(false) { _, _, isBound -> notificationManager.lockedToForeground = isBound @@ -221,22 +215,7 @@ class MullvadVpnService : TalpidVpnService() { private fun setUpInstance(daemon: MullvadDaemon, settings: Settings) { val settingsListener = SettingsListener(daemon, settings) - - val connectionProxy = ConnectionProxy(this, daemon).apply { - when (pendingAction) { - PendingAction.Connect -> { - if (settings.accountToken != null) { - connect() - } else { - openUi() - } - } - PendingAction.Disconnect -> disconnect() - null -> {} - } - - pendingAction = null - } + val connectionProxy = ConnectionProxy(this, daemon) val splitTunneling = SplitTunneling(this).apply { onChange = { excludedApps -> @@ -246,6 +225,8 @@ class MullvadVpnService : TalpidVpnService() { } } + handlePendingAction(connectionProxy, settings) + instance = ServiceInstance( daemon, connectionProxy, @@ -279,6 +260,22 @@ class MullvadVpnService : TalpidVpnService() { setUp() } + private fun handlePendingAction(connectionProxy: ConnectionProxy, settings: Settings) { + when (pendingAction) { + PendingAction.Connect -> { + if (settings.accountToken != null) { + connectionProxy.connect() + } else { + openUi() + } + } + PendingAction.Disconnect -> connectionProxy.disconnect() + null -> return + } + + pendingAction = null + } + private fun openUi() { val intent = Intent(this, MainActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
