mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 23:35:04 +01:00
Add WebView-based user agent string to debug info
Could probably use this when choosing a user agent later on.
This commit is contained in:
parent
77a8a4229c
commit
de92b1351f
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.os.Build
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
||||
import eu.kanade.tachiyomi.util.system.toShareIntent
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
@ -35,6 +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)}
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,24 @@ import kotlin.coroutines.resume
|
||||
object WebViewUtil {
|
||||
const val SPOOF_PACKAGE_NAME = "org.chromium.chrome"
|
||||
|
||||
const val MINIMUM_WEBVIEW_VERSION = 111
|
||||
const val MINIMUM_WEBVIEW_VERSION = 114
|
||||
|
||||
/**
|
||||
* Uses the WebView's user agent string to create something similar to what Chrome on Android
|
||||
* would return.
|
||||
*
|
||||
* Example of WebView user agent string:
|
||||
* Mozilla/5.0 (Linux; Android 13; Pixel 7 Build/TQ3A.230901.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36
|
||||
*
|
||||
* Example of Chrome on Android:
|
||||
* Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.3
|
||||
*/
|
||||
fun getInferredUserAgent(context: Context): String {
|
||||
return WebView(context)
|
||||
.getDefaultUserAgentString()
|
||||
.replace("; Android .*?\\)".toRegex(), "; Android 10; K)")
|
||||
.replace("Version/.* Chrome/".toRegex(), "Chrome/")
|
||||
}
|
||||
|
||||
fun supportsWebView(context: Context): Boolean {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user