Browse Source

Change crash log info to just have actual WebView version

arkon 1 year ago
parent
commit
22df12a680

+ 2 - 10
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

+ 1 - 1
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()
     }
 }

+ 13 - 0
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