Improve WebView spoofing (#3678)
- Spoof `Sec-CH-UA` client hints to match the user agent - Fix `X-Requested-With` spoofing leaking to unrelated callers - Update default user agent to Chrome 149
This commit is contained in:
@@ -8,7 +8,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.Build
|
||||
import android.os.Looper
|
||||
import android.webkit.WebView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
@@ -231,7 +230,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
override fun getPackageName(): String {
|
||||
try {
|
||||
// Override the value passed as X-Requested-With in WebView requests
|
||||
val stackTrace = Looper.getMainLooper().thread.stackTrace
|
||||
val stackTrace = Thread.currentThread().stackTrace
|
||||
val isChromiumCall = stackTrace.any { trace ->
|
||||
trace.className.lowercase() in setOf("org.chromium.base.buildinfo", "org.chromium.base.apkinfo") &&
|
||||
trace.methodName.lowercase() in setOf("getall", "getpackagename", "<init>")
|
||||
|
||||
Reference in New Issue
Block a user