Fix webview crash caused by 6bfb80fe (mihonapp/mihon#1819)

(cherry picked from commit 9957fff2fbb6dad6f9df89bb2c16db34d9e4da96)
This commit is contained in:
AwkwardPeak7 2025-03-04 12:06:21 +05:00 committed by Cuong-Tran
parent f0fcdbe816
commit 4892e858f9
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -286,9 +286,9 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
try {
// Override the value passed as X-Requested-With in WebView requests
val stackTrace = Looper.getMainLooper().thread.stackTrace
val isChromiumCall = stackTrace.any {
it.className.startsWith("org.chromium.") &&
it.methodName in setOf("getAll", "getPackageName", "<init>")
val isChromiumCall = stackTrace.any { trace ->
trace.className.equals("org.chromium.base.BuildInfo", ignoreCase = true) &&
setOf("getAll", "getPackageName", "<init>").any { trace.methodName.equals(it, ignoreCase = true) }
}
if (isChromiumCall) return WebViewUtil.spoofedPackageName(applicationContext)