From 22df12a680174890fe8f3559218b1819e37bf2f6 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 17 Oct 2023 22:30:55 -0400 Subject: [PATCH] Change crash log info to just have actual WebView version --- .../more/settings/screen/debug/DebugInfoScreen.kt | 12 ++---------- .../java/eu/kanade/tachiyomi/util/CrashLogUtil.kt | 2 +- .../eu/kanade/tachiyomi/util/system/WebViewUtil.kt | 13 +++++++++++++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/DebugInfoScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/DebugInfoScreen.kt index 37fa0189d..0e3bcde93 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/DebugInfoScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/DebugInfoScreen.kt @@ -1,7 +1,6 @@ package eu.kanade.presentation.more.settings.screen.debug import android.os.Build -import android.webkit.WebView import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.getValue @@ -16,6 +15,7 @@ import eu.kanade.presentation.more.settings.screen.about.AboutScreen import eu.kanade.presentation.util.Screen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.DeviceUtil +import eu.kanade.tachiyomi.util.system.WebViewUtil import kotlinx.coroutines.guava.await class DebugInfoScreen : Screen() { @@ -68,15 +68,7 @@ class DebugInfoScreen : Screen() { @Composable @ReadOnlyComposable private fun getWebViewVersion(): String { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val webView = WebView.getCurrentWebViewPackage() ?: return "how did you get here?" - val pm = LocalContext.current.packageManager - val label = webView.applicationInfo.loadLabel(pm) - val version = webView.versionName - return "$label $version" - } else { - return "Unknown" - } + return WebViewUtil.getVersion(LocalContext.current) } @Composable diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt index c495c7008..505ec3cf9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt @@ -36,7 +36,7 @@ class CrashLogUtil(private val context: Context) { Device name: ${Build.DEVICE} Device model: ${Build.MODEL} Device product name: ${Build.PRODUCT} - WebView user agent: ${WebViewUtil.getInferredUserAgent(context)} + WebView: ${WebViewUtil.getVersion(context)} """.trimIndent() } } diff --git a/core/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt b/core/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt index eb1ad9617..b3329e9b7 100644 --- a/core/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt +++ b/core/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.util.system import android.annotation.SuppressLint import android.content.Context import android.content.pm.PackageManager +import android.os.Build import android.webkit.CookieManager import android.webkit.WebSettings import android.webkit.WebView @@ -33,6 +34,18 @@ object WebViewUtil { .replace("Version/.* Chrome/".toRegex(), "Chrome/") } + fun getVersion(context: Context): String { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val webView = WebView.getCurrentWebViewPackage() ?: return "how did you get here?" + val pm = context.packageManager + val label = webView.applicationInfo.loadLabel(pm) + val version = webView.versionName + "$label $version" + } else { + "Unknown" + } + } + fun supportsWebView(context: Context): Boolean { try { // May throw android.webkit.WebViewFactory$MissingWebViewPackageException if WebView