summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-09-09 09:59:31 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-09-09 09:59:31 -0300
commitc840a15588db413c6cc4d39cce70fe6962f89a56 (patch)
tree35f6d118bc0d7a316a616c601c94f65be28fdcc4
parent2650248f19ff4822d057408a0c1f20ac3c307c16 (diff)
parentcbde7fd311f95b58451bd0d0fb6a96937a33a2c9 (diff)
downloadmullvadvpn-c840a15588db413c6cc4d39cce70fe6962f89a56.tar.xz
mullvadvpn-c840a15588db413c6cc4d39cce70fe6962f89a56.zip
Merge branch 'fix-inconsistent-quick-settings-tile-behavior'
-rw-r--r--CHANGELOG.md2
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt55
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)