aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-26 13:34:20 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-26 13:49:14 +0200
commit938399d881aa6b365be131ffb3a517d64be427bb (patch)
tree818d6d25c5394d0f7af15cf7ed130b48992d0154 /ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt
parentui: print proper exception trace from log viewer (diff)
downloadwireguard-android-938399d881aa6b365be131ffb3a517d64be427bb.tar.xz
wireguard-android-938399d881aa6b365be131ffb3a517d64be427bb.zip
ui: queue up tunnel mutating on activity scope instead of fragment scope
Fragment scopes get cancelled when the fragment goes away, but we don't actually want to cancel an in-flight transition in that case. Also, before when the fragment would cancel, there'd be an exception, and the exception handler would call Fragment::getString, which in turn called requireContext, which caused an exception. Work around this by using the `activity ?: Application.get()` idiom to always have a context for strings and toasts. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt')
-rw-r--r--ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt4
1 files changed, 2 insertions, 2 deletions
diff --git a/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt b/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt
index d8ac94d9..1ee0dafc 100644
--- a/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt
+++ b/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt
@@ -6,7 +6,7 @@ package com.wireguard.android.util
import android.content.res.Resources
import android.os.RemoteException
-import com.wireguard.android.Application.Companion.get
+import com.wireguard.android.Application
import com.wireguard.android.R
import com.wireguard.android.backend.BackendException
import com.wireguard.android.util.RootShell.RootShellException
@@ -63,7 +63,7 @@ object ErrorMessages {
)
operator fun get(throwable: Throwable?): String {
- val resources = get().resources
+ val resources = Application.get().resources
if (throwable == null) return resources.getString(R.string.unknown_error)
val rootCause = rootCause(throwable)
return when {