From e1b1f4f3fc48f0c928fba34c67bf0d76c3dd1064 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 1 Feb 2022 09:48:37 -0500 Subject: [PATCH] Avoid trying to open links in invalid Huawei app --- .../java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt | 2 +- app/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index 4ab874c09..531f06c46 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -304,7 +304,7 @@ fun Context.defaultBrowserPackageName(): String? { val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://")) return packageManager.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY) ?.activityInfo?.packageName - ?.takeIf { it != "android" } + ?.takeUnless { it in DeviceUtil.invalidDefaultBrowsers } } fun Context.createFileInCacheDir(name: String): File { diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt index c2b62d8fd..3da54c1eb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/DeviceUtil.kt @@ -35,6 +35,8 @@ object DeviceUtil { DynamicColors.isDynamicColorAvailable() || (isSamsung && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) } + val invalidDefaultBrowsers = listOf("android", "com.huawei.android.internal.app") + @SuppressLint("PrivateApi") private fun getSystemProperty(key: String?): String? { return try {