Change crash log info to just have actual WebView version

This commit is contained in:
arkon
2023-10-17 22:30:55 -04:00
parent e572abb041
commit 22df12a680
3 changed files with 16 additions and 11 deletions

View File

@ -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