Avoid crash on Samsung devices on Android 12
Co-authored-by: Jays2Kings <Jays2Kings@users.noreply.github.com>
This commit is contained in:
parent
b701821550
commit
7edf7a434f
5 changed files with 21 additions and 11 deletions
|
@ -18,7 +18,7 @@ import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting
|
|||
import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||
import eu.kanade.tachiyomi.util.system.MiuiUtil
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
@ -326,7 +326,7 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun extensionInstaller() = flowPrefs.getEnum(
|
||||
Keys.extensionInstaller,
|
||||
if (MiuiUtil.isMiui()) Values.ExtensionInstaller.LEGACY else Values.ExtensionInstaller.PACKAGEINSTALLER
|
||||
if (DeviceUtil.isMiui()) Values.ExtensionInstaller.LEGACY else Values.ExtensionInstaller.PACKAGEINSTALLER
|
||||
)
|
||||
|
||||
fun verboseLogging() = prefs.getBoolean(Keys.verboseLogging, false)
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.network.interceptor
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.webkit.WebSettings
|
||||
import android.webkit.WebView
|
||||
import android.widget.Toast
|
||||
|
@ -10,6 +11,7 @@ import eu.kanade.tachiyomi.R
|
|||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.util.system.WebViewClientCompat
|
||||
import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||
import eu.kanade.tachiyomi.util.system.isOutdated
|
||||
|
@ -37,6 +39,12 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||
* Application class.
|
||||
*/
|
||||
private val initWebView by lazy {
|
||||
// Avoid crashes on Samsung devices on Android 12
|
||||
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.S && DeviceUtil.isSamsung()) {
|
||||
return@lazy
|
||||
}
|
||||
|
||||
WebSettings.getDefaultUserAgent(context)
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
|||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
import eu.kanade.tachiyomi.util.system.MiuiUtil
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.util.system.isPackageInstalled
|
||||
import eu.kanade.tachiyomi.util.system.powerManager
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
|
@ -215,7 +215,7 @@ class SettingsAdvancedController : SettingsController() {
|
|||
R.string.ext_installer_shizuku,
|
||||
)
|
||||
entryValues = PreferenceValues.ExtensionInstaller.values().map { it.name }.toTypedArray()
|
||||
defaultValue = if (MiuiUtil.isMiui()) {
|
||||
defaultValue = if (DeviceUtil.isMiui()) {
|
||||
PreferenceValues.ExtensionInstaller.LEGACY
|
||||
} else {
|
||||
PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER
|
||||
|
|
|
@ -35,7 +35,7 @@ import eu.kanade.tachiyomi.util.preference.preference
|
|||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
import eu.kanade.tachiyomi.util.system.MiuiUtil
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
@ -62,7 +62,7 @@ class SettingsBackupController : SettingsController() {
|
|||
summaryRes = R.string.pref_create_backup_summ
|
||||
|
||||
onClick {
|
||||
if (MiuiUtil.isMiui() && MiuiUtil.isMiuiOptimizationDisabled()) {
|
||||
if (DeviceUtil.isMiui() && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
context.toast(R.string.restore_miui_warning, Toast.LENGTH_LONG)
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class SettingsBackupController : SettingsController() {
|
|||
summaryRes = R.string.pref_restore_backup_summ
|
||||
|
||||
onClick {
|
||||
if (MiuiUtil.isMiui() && MiuiUtil.isMiuiOptimizationDisabled()) {
|
||||
if (DeviceUtil.isMiui() && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
context.toast(R.string.restore_miui_warning, Toast.LENGTH_LONG)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
import logcat.LogPriority
|
||||
import java.util.Locale
|
||||
|
||||
object MiuiUtil {
|
||||
object DeviceUtil {
|
||||
|
||||
fun isMiui(): Boolean {
|
||||
return getSystemProperty("ro.miui.ui.version.name")?.isNotEmpty() ?: false
|
||||
}
|
||||
fun isMiui() = getSystemProperty("ro.miui.ui.version.name")?.isNotEmpty() ?: false
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
fun isMiuiOptimizationDisabled(): Boolean {
|
||||
|
@ -25,6 +25,8 @@ object MiuiUtil {
|
|||
}
|
||||
}
|
||||
|
||||
fun isSamsung() = Build.MANUFACTURER.lowercase(Locale.ENGLISH) == "samsung"
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
private fun getSystemProperty(key: String?): String? {
|
||||
return try {
|
Reference in a new issue