From efeac6d305623e8078184904d66241edd1b2dc86 Mon Sep 17 00:00:00 2001 From: Jonatan Rhodin Date: Fri, 17 Nov 2023 10:54:11 +0100 Subject: [PATCH] Add missing FirewallPolicyError class --- .../notificationbanner/NotificationBanner.kt | 9 ++++++++- .../mullvad/mullvadvpn/model/TunnelState.kt | 16 +++++++++++++-- .../mullvad/talpid/tunnel/ErrorStateCause.kt | 20 +++++++++++-------- .../talpid/tunnel/FirewallPolicyError.kt | 9 +++++++++ mullvad-jni/src/classes.rs | 1 + 5 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 android/lib/talpid/src/main/kotlin/net/mullvad/talpid/tunnel/FirewallPolicyError.kt diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt index 6078e4b39251..2bcda3ea3534 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt @@ -37,6 +37,7 @@ import net.mullvad.mullvadvpn.ui.VersionInfo import net.mullvad.mullvadvpn.ui.notification.StatusLevel import net.mullvad.talpid.tunnel.ErrorState import net.mullvad.talpid.tunnel.ErrorStateCause +import net.mullvad.talpid.tunnel.FirewallPolicyError import org.joda.time.DateTime @Preview @@ -61,7 +62,13 @@ private fun PreviewNotificationBanner() { InAppNotification.TunnelStateBlocked, InAppNotification.NewDevice("Courageous Turtle"), InAppNotification.TunnelStateError( - error = ErrorState(ErrorStateCause.SetFirewallPolicyError, true) + error = + ErrorState( + ErrorStateCause.SetFirewallPolicyError( + FirewallPolicyError.Generic + ), + true + ) ) ) .map { it.toNotificationData({}, {}, {}) } diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt index 364c8861ceda..26f776b2236b 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/TunnelState.kt @@ -6,6 +6,7 @@ import net.mullvad.talpid.net.TunnelEndpoint import net.mullvad.talpid.tunnel.ActionAfterDisconnect import net.mullvad.talpid.tunnel.ErrorState import net.mullvad.talpid.tunnel.ErrorStateCause +import net.mullvad.talpid.tunnel.FirewallPolicyError sealed class TunnelState : Parcelable { @Parcelize object Disconnected : TunnelState(), Parcelable @@ -73,9 +74,20 @@ sealed class TunnelState : Parcelable { DISCONNECTING -> Disconnecting(ActionAfterDisconnect.Nothing) BLOCKING -> Error(ErrorState(ErrorStateCause.StartTunnelError, true)) ERROR -> { - Error(ErrorState(ErrorStateCause.SetFirewallPolicyError, false)) + Error( + ErrorState( + ErrorStateCause.SetFirewallPolicyError(FirewallPolicyError.Generic), + false + ) + ) } - else -> Error(ErrorState(ErrorStateCause.SetFirewallPolicyError, false)) + else -> + Error( + ErrorState( + ErrorStateCause.SetFirewallPolicyError(FirewallPolicyError.Generic), + false + ) + ) } } } diff --git a/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorStateCause.kt b/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorStateCause.kt index 5096e5c69353..fc35e4e23efe 100644 --- a/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorStateCause.kt +++ b/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/tunnel/ErrorStateCause.kt @@ -14,19 +14,23 @@ sealed class ErrorStateCause : Parcelable { } } - @Parcelize object Ipv6Unavailable : ErrorStateCause() + @Parcelize data object Ipv6Unavailable : ErrorStateCause() - @Parcelize object SetFirewallPolicyError : ErrorStateCause() + @Parcelize + data class SetFirewallPolicyError(val firewallPolicyError: FirewallPolicyError) : + ErrorStateCause() - @Parcelize object SetDnsError : ErrorStateCause() + @Parcelize data object SetDnsError : ErrorStateCause() - @Parcelize class InvalidDnsServers(val addresses: ArrayList) : ErrorStateCause() + @Parcelize + data class InvalidDnsServers(val addresses: ArrayList) : ErrorStateCause() - @Parcelize object StartTunnelError : ErrorStateCause() + @Parcelize data object StartTunnelError : ErrorStateCause() - @Parcelize class TunnelParameterError(val error: ParameterGenerationError) : ErrorStateCause() + @Parcelize + data class TunnelParameterError(val error: ParameterGenerationError) : ErrorStateCause() - @Parcelize object IsOffline : ErrorStateCause() + @Parcelize data object IsOffline : ErrorStateCause() - @Parcelize object VpnPermissionDenied : ErrorStateCause() + @Parcelize data object VpnPermissionDenied : ErrorStateCause() } diff --git a/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/tunnel/FirewallPolicyError.kt b/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/tunnel/FirewallPolicyError.kt new file mode 100644 index 000000000000..c6f19e71af4e --- /dev/null +++ b/android/lib/talpid/src/main/kotlin/net/mullvad/talpid/tunnel/FirewallPolicyError.kt @@ -0,0 +1,9 @@ +package net.mullvad.talpid.tunnel + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +enum class FirewallPolicyError : Parcelable { + Generic +} diff --git a/mullvad-jni/src/classes.rs b/mullvad-jni/src/classes.rs index d39cb156d811..454e0e6c6281 100644 --- a/mullvad-jni/src/classes.rs +++ b/mullvad-jni/src/classes.rs @@ -95,5 +95,6 @@ pub const CLASSES: &[&str] = &[ "net/mullvad/talpid/CreateTunResult$InvalidDnsServers", "net/mullvad/talpid/CreateTunResult$PermissionDenied", "net/mullvad/talpid/CreateTunResult$TunnelDeviceError", + "net/mullvad/talpid/tunnel/FirewallPolicyError", "net/mullvad/talpid/TalpidVpnService", ];