summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorEmīls <emils@mullvad.net>2019-12-09 11:24:37 +0000
committerEmīls <emils@mullvad.net>2019-12-09 11:24:37 +0000
commitbe89341733b58f2e992141fe99713e4d6e4ba7fd (patch)
tree5c5c7413fab96d3c874cc882b7f80e253892cef0 /android
parent345bebcf9cd75dc29328b1355c2feacbf7b65aad (diff)
parent3a041298b1433ec8b81656d77bc2379978af2691 (diff)
downloadmullvadvpn-be89341733b58f2e992141fe99713e4d6e4ba7fd.tar.xz
mullvadvpn-be89341733b58f2e992141fe99713e4d6e4ba7fd.zip
Merge branch 'add-error-state'
Diffstat (limited to 'android')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt4
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectionStatus.kt12
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ForegroundNotificationManager.kt13
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/HeaderBar.kt8
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt39
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt2
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt4
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt2
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt4
-rw-r--r--android/src/main/kotlin/net/mullvad/talpid/tunnel/BlockReason.kt12
-rw-r--r--android/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorState.kt3
-rw-r--r--android/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorStateCause.kt12
-rw-r--r--android/src/main/res/values/strings.xml2
13 files changed, 76 insertions, 41 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt
index 4789d27a2c..cdaa302a71 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectActionButton.kt
@@ -26,7 +26,7 @@ class ConnectActionButton(val parentView: View) {
}
is TunnelState.Connecting -> connecting()
is TunnelState.Connected -> connected()
- is TunnelState.Blocked -> connected()
+ is TunnelState.Error -> connected()
}
field = value
@@ -46,7 +46,7 @@ class ConnectActionButton(val parentView: View) {
is TunnelState.Disconnecting -> onConnect?.invoke()
is TunnelState.Connecting -> onCancel?.invoke()
is TunnelState.Connected -> onDisconnect?.invoke()
- is TunnelState.Blocked -> onDisconnect?.invoke()
+ is TunnelState.Error -> onDisconnect?.invoke()
}
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectionStatus.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectionStatus.kt
index 664156dd04..8fd95fab1f 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectionStatus.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectionStatus.kt
@@ -26,7 +26,7 @@ class ConnectionStatus(val parentView: View, val resources: Resources) {
is TunnelState.Disconnected -> disconnected()
is TunnelState.Connecting -> connecting()
is TunnelState.Connected -> connected()
- is TunnelState.Blocked -> blocked()
+ is TunnelState.Error -> errorState(state.errorState.isBlocking)
}
}
@@ -51,10 +51,16 @@ class ConnectionStatus(val parentView: View, val resources: Resources) {
text.setText(R.string.secure_connection)
}
- private fun blocked() {
+ private fun errorState(isBlocking: Boolean) {
spinner.visibility = View.GONE
+ // TODO: revise how to best inform the user about us not blocking
+ // traffic
text.setTextColor(securedTextColor)
- text.setText(R.string.blocked_connection)
+ if (isBlocking) {
+ text.setText(R.string.blocked_connection)
+ } else {
+ text.setText(R.string.blocked_connection)
+ }
}
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ForegroundNotificationManager.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ForegroundNotificationManager.kt
index 80890e56ca..e7c3886873 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ForegroundNotificationManager.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ForegroundNotificationManager.kt
@@ -66,7 +66,14 @@ class ForegroundNotificationManager(val service: Service, val connectionProxy: C
else -> R.string.disconnecting
}
}
- is TunnelState.Blocked -> R.string.blocking_all_connections
+ is TunnelState.Error -> {
+ if (state.errorState.isBlocking) {
+ R.string.blocking_all_connections
+ } else {
+ // TODO Revise use of message when the app fails to block traffic
+ R.string.unsecured
+ }
+ }
}
}
@@ -84,7 +91,7 @@ class ForegroundNotificationManager(val service: Service, val connectionProxy: C
else -> R.string.connect
}
}
- is TunnelState.Blocked -> R.string.disconnect
+ is TunnelState.Error -> R.string.disconnect
}
}
@@ -102,7 +109,7 @@ class ForegroundNotificationManager(val service: Service, val connectionProxy: C
else -> KEY_CONNECT_ACTION
}
}
- is TunnelState.Blocked -> KEY_DISCONNECT_ACTION
+ is TunnelState.Error -> KEY_DISCONNECT_ACTION
}
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/HeaderBar.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/HeaderBar.kt
index b89b13e08a..38022e1ef2 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/HeaderBar.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/HeaderBar.kt
@@ -16,7 +16,13 @@ class HeaderBar(val parentView: View, val resources: Resources) {
is TunnelState.Connecting -> secured()
is TunnelState.Connected -> secured()
is TunnelState.Disconnecting -> secured()
- is TunnelState.Blocked -> secured()
+ is TunnelState.Error -> {
+ if (state.errorState.isBlocking) {
+ secured()
+ } else {
+ unsecured()
+ }
+ }
}
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt
index c5cd816ce2..77133f929d 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt
@@ -16,7 +16,8 @@ import net.mullvad.mullvadvpn.dataproxy.WwwAuthTokenRetriever
import net.mullvad.mullvadvpn.model.KeygenEvent
import net.mullvad.mullvadvpn.model.TunnelState
import net.mullvad.talpid.tunnel.ActionAfterDisconnect
-import net.mullvad.talpid.tunnel.BlockReason
+import net.mullvad.talpid.tunnel.ErrorState
+import net.mullvad.talpid.tunnel.ErrorStateCause
import net.mullvad.talpid.tunnel.ParameterGenerationError
class NotificationBanner(
@@ -132,7 +133,7 @@ class NotificationBanner(
is TunnelState.Disconnected -> return false
is TunnelState.Connecting -> showBlocking(null)
is TunnelState.Connected -> return false
- is TunnelState.Blocked -> showBlocking(state.reason)
+ is TunnelState.Error -> showBlocking(state.errorState)
}
return true
@@ -167,18 +168,20 @@ class NotificationBanner(
return true
}
- private fun showBlocking(reason: BlockReason?) {
- val messageText = when (reason) {
+ private fun showBlocking(errorState: ErrorState?) {
+ val cause = errorState?.cause
+
+ val messageText = when (cause) {
null -> null
- is BlockReason.AuthFailed -> R.string.auth_failed
- is BlockReason.Ipv6Unavailable -> R.string.ipv6_unavailable
- is BlockReason.SetFirewallPolicyError -> R.string.set_firewall_policy_error
- is BlockReason.SetDnsError -> R.string.set_dns_error
- is BlockReason.StartTunnelError -> R.string.start_tunnel_error
- is BlockReason.IsOffline -> R.string.is_offline
- is BlockReason.TapAdapterProblem -> R.string.tap_adapter_problem
- is BlockReason.TunnelParameterError -> {
- when (reason.error) {
+ is ErrorStateCause.AuthFailed -> R.string.auth_failed
+ is ErrorStateCause.Ipv6Unavailable -> R.string.ipv6_unavailable
+ is ErrorStateCause.SetFirewallPolicyError -> R.string.set_firewall_policy_error
+ is ErrorStateCause.SetDnsError -> R.string.set_dns_error
+ is ErrorStateCause.StartTunnelError -> R.string.start_tunnel_error
+ is ErrorStateCause.IsOffline -> R.string.is_offline
+ is ErrorStateCause.TapAdapterProblem -> R.string.tap_adapter_problem
+ is ErrorStateCause.TunnelParameterError -> {
+ when (cause.error) {
ParameterGenerationError.NoMatchingRelay -> R.string.no_matching_relay
ParameterGenerationError.NoMatchingBridgeRelay -> {
R.string.no_matching_bridge_relay
@@ -190,7 +193,15 @@ class NotificationBanner(
}
}
}
- showError(R.string.blocking_internet, messageText)
+
+ // if the error state is null, we can assume that we are secure
+ val blockMessage = if (errorState?.isBlocking ?: true) {
+ R.string.blocking_internet
+ } else {
+ R.string.not_blocking_internet
+ }
+
+ showError(blockMessage, messageText)
}
private fun showError(titleText: Int, messageText: Int?) {
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt
index 930c1ff626..581fae4772 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt
@@ -64,7 +64,7 @@ class SwitchLocationButton(val parentView: View, val resources: Resources) {
}
is TunnelState.Connecting -> showLabel()
is TunnelState.Connected -> showLabel()
- is TunnelState.Blocked -> showLocation()
+ is TunnelState.Error -> showLocation()
}
}
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt
index 11f27d2b53..c0237fa7d6 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/WireguardKeyFragment.kt
@@ -91,7 +91,7 @@ class WireguardKeyFragment : Fragment() {
urlController = BlockingController(
object : BlockableView {
override fun setEnabled(enabled: Boolean) {
- if (!enabled || tunnelState is TunnelState.Blocked) {
+ if (!enabled || tunnelState is TunnelState.Error) {
visitWebsiteView.setClickable(false)
visitWebsiteView.setAlpha(0.5f)
} else {
@@ -251,7 +251,7 @@ class WireguardKeyFragment : Fragment() {
verifyButton.visibility = View.GONE
verifySpinner.visibility = View.VISIBLE
}
- is TunnelState.Blocked -> {
+ is TunnelState.Error -> {
statusMessage.setText(R.string.wireguard_key_blocked_state_message)
statusMessage.visibility = View.VISIBLE
generateButton.setClickable(false)
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt
index 9c9e339541..41fb1ccbf3 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt
@@ -64,7 +64,7 @@ class LocationInfoCache(
ActionAfterDisconnect.Reconnect -> location = locationFromSelectedRelay()
}
}
- is TunnelState.Blocked -> location = null
+ is TunnelState.Error -> location = null
}
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt
index 040c4997c9..556517720d 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt
@@ -2,12 +2,12 @@ package net.mullvad.mullvadvpn.model
import net.mullvad.talpid.net.TunnelEndpoint
import net.mullvad.talpid.tunnel.ActionAfterDisconnect
-import net.mullvad.talpid.tunnel.BlockReason
+import net.mullvad.talpid.tunnel.ErrorState
sealed class TunnelState() {
class Disconnected() : TunnelState()
class Connecting(val endpoint: TunnelEndpoint?, val location: GeoIpLocation?) : TunnelState()
class Connected(val endpoint: TunnelEndpoint, val location: GeoIpLocation?) : TunnelState()
class Disconnecting(val actionAfterDisconnect: ActionAfterDisconnect) : TunnelState()
- class Blocked(val reason: BlockReason) : TunnelState()
+ class Error(val errorState: ErrorState) : TunnelState()
}
diff --git a/android/src/main/kotlin/net/mullvad/talpid/tunnel/BlockReason.kt b/android/src/main/kotlin/net/mullvad/talpid/tunnel/BlockReason.kt
deleted file mode 100644
index bed6177fb0..0000000000
--- a/android/src/main/kotlin/net/mullvad/talpid/tunnel/BlockReason.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package net.mullvad.talpid.tunnel
-
-sealed class BlockReason {
- class AuthFailed(val reason: String?) : BlockReason()
- class Ipv6Unavailable : BlockReason()
- class SetFirewallPolicyError : BlockReason()
- class SetDnsError : BlockReason()
- class StartTunnelError : BlockReason()
- class TunnelParameterError(val error: ParameterGenerationError) : BlockReason()
- class IsOffline : BlockReason()
- class TapAdapterProblem : BlockReason()
-}
diff --git a/android/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorState.kt b/android/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorState.kt
new file mode 100644
index 0000000000..c88a932887
--- /dev/null
+++ b/android/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorState.kt
@@ -0,0 +1,3 @@
+package net.mullvad.talpid.tunnel
+
+data class ErrorState(val cause: ErrorStateCause, val isBlocking: Boolean)
diff --git a/android/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorStateCause.kt b/android/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorStateCause.kt
new file mode 100644
index 0000000000..e289b59551
--- /dev/null
+++ b/android/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorStateCause.kt
@@ -0,0 +1,12 @@
+package net.mullvad.talpid.tunnel
+
+sealed class ErrorStateCause {
+ class AuthFailed(val reason: String?) : ErrorStateCause()
+ class Ipv6Unavailable : ErrorStateCause()
+ class SetFirewallPolicyError : ErrorStateCause()
+ class SetDnsError : ErrorStateCause()
+ class StartTunnelError : ErrorStateCause()
+ class TunnelParameterError(val error: ParameterGenerationError) : ErrorStateCause()
+ class IsOffline : ErrorStateCause()
+ class TapAdapterProblem : ErrorStateCause()
+}
diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml
index 02064541a1..d019f68b17 100644
--- a/android/src/main/res/values/strings.xml
+++ b/android/src/main/res/values/strings.xml
@@ -70,6 +70,7 @@
<string name="creating_secure_connection">Creating secure connection</string>
<string name="secure_connection">Secure connection</string>
<string name="blocked_connection">Blocked connection</string>
+ <string name="error_state">Failed to secure connection</string>
<string name="connect">Secure my connection</string>
<string name="cancel">Cancel</string>
<string name="disconnect">Disconnect</string>
@@ -81,6 +82,7 @@
<string name="out_address">Out %1$s</string>
<string name="blocking_internet">Blocking internet</string>
+ <string name="not_blocking_internet">Failed to block internet</string>
<string name="auth_failed">Account authentication failed.</string>
<string name="ipv6_unavailable">Could not configure IPv6</string>
<string name="set_firewall_policy_error">