Change crash log info to just have actual WebView version
This commit is contained in:
parent
e572abb041
commit
22df12a680
3 changed files with 16 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
||||||
package eu.kanade.presentation.more.settings.screen.debug
|
package eu.kanade.presentation.more.settings.screen.debug
|
||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.webkit.WebView
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.ReadOnlyComposable
|
import androidx.compose.runtime.ReadOnlyComposable
|
||||||
import androidx.compose.runtime.getValue
|
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.presentation.util.Screen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||||
|
import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||||
import kotlinx.coroutines.guava.await
|
import kotlinx.coroutines.guava.await
|
||||||
|
|
||||||
class DebugInfoScreen : Screen() {
|
class DebugInfoScreen : Screen() {
|
||||||
|
@ -68,15 +68,7 @@ class DebugInfoScreen : Screen() {
|
||||||
@Composable
|
@Composable
|
||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
private fun getWebViewVersion(): String {
|
private fun getWebViewVersion(): String {
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
return WebViewUtil.getVersion(LocalContext.current)
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
@ -36,7 +36,7 @@ class CrashLogUtil(private val context: Context) {
|
||||||
Device name: ${Build.DEVICE}
|
Device name: ${Build.DEVICE}
|
||||||
Device model: ${Build.MODEL}
|
Device model: ${Build.MODEL}
|
||||||
Device product name: ${Build.PRODUCT}
|
Device product name: ${Build.PRODUCT}
|
||||||
WebView user agent: ${WebViewUtil.getInferredUserAgent(context)}
|
WebView: ${WebViewUtil.getVersion(context)}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.util.system
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.Build
|
||||||
import android.webkit.CookieManager
|
import android.webkit.CookieManager
|
||||||
import android.webkit.WebSettings
|
import android.webkit.WebSettings
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
|
@ -33,6 +34,18 @@ object WebViewUtil {
|
||||||
.replace("Version/.* Chrome/".toRegex(), "Chrome/")
|
.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 {
|
fun supportsWebView(context: Context): Boolean {
|
||||||
try {
|
try {
|
||||||
// May throw android.webkit.WebViewFactory$MissingWebViewPackageException if WebView
|
// May throw android.webkit.WebViewFactory$MissingWebViewPackageException if WebView
|
||||||
|
|
Reference in a new issue