mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 13:01:50 +01:00
Limit package name overriding to Android 8+ (related to #6846)
This commit is contained in:
parent
554dfb5874
commit
0b2794e843
@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.app.Application
|
||||
import android.app.PendingIntent
|
||||
@ -57,6 +58,7 @@ open class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
||||
|
||||
private val disableIncognitoReceiver = DisableIncognitoReceiver()
|
||||
|
||||
@SuppressLint("LaunchActivityFromNotification")
|
||||
override fun onCreate() {
|
||||
super<Application>.onCreate()
|
||||
|
||||
@ -151,15 +153,21 @@ open class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
||||
}
|
||||
|
||||
override fun getPackageName(): String {
|
||||
// This causes freezes in Android 6/7 for some reason
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
try {
|
||||
// Override the value passed as X-Requested-With in WebView requests
|
||||
val stackTrace = Looper.getMainLooper().thread.stackTrace
|
||||
val chromiumElement = stackTrace.find { it.className.equals("org.chromium.base.BuildInfo", ignoreCase = true) }
|
||||
val chromiumElement = stackTrace.find {
|
||||
it.className.equals("org.chromium.base.BuildInfo",
|
||||
ignoreCase = true)
|
||||
}
|
||||
if (chromiumElement?.methodName.equals("getAll", ignoreCase = true)) {
|
||||
return WebViewUtil.SPOOF_PACKAGE_NAME
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
return super.getPackageName()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user