From 6be9cccc7a14c2ef9b69493493809de0c1841241 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 1 Oct 2022 13:21:12 -0400 Subject: [PATCH] Revert min extension-lib change Some extensions haven't been bumped yet. We should probably try to bump everything at some point. Also includes some minor cleanup. --- .../extension/util/ExtensionLoader.kt | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt index e54fe7635..14cc0762a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.content.Context import android.content.pm.PackageInfo import android.content.pm.PackageManager +import android.os.Build import androidx.core.content.pm.PackageInfoCompat import dalvik.system.PathClassLoader import eu.kanade.domain.source.service.SourcePreferences @@ -37,7 +38,7 @@ internal object ExtensionLoader { private const val METADATA_NSFW = "tachiyomi.extension.nsfw" private const val METADATA_HAS_README = "tachiyomi.extension.hasReadme" private const val METADATA_HAS_CHANGELOG = "tachiyomi.extension.hasChangelog" - const val LIB_VERSION_MIN = 1.3 + const val LIB_VERSION_MIN = 1.2 const val LIB_VERSION_MAX = 1.4 private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES @@ -57,7 +58,14 @@ internal object ExtensionLoader { */ fun loadExtensions(context: Context): List { val pkgManager = context.packageManager - val installedPkgs = pkgManager.getInstalledPackages(PACKAGE_FLAGS) + + @Suppress("DEPRECATION") + val installedPkgs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + pkgManager.getInstalledPackages(PackageManager.PackageInfoFlags.of(PACKAGE_FLAGS.toLong())) + } else { + pkgManager.getInstalledPackages(PACKAGE_FLAGS) + } + val extPkgs = installedPkgs.filter { isPackageAnExtension(it) } if (extPkgs.isEmpty()) return emptyList() @@ -113,19 +121,17 @@ internal object ExtensionLoader { val versionCode = PackageInfoCompat.getLongVersionCode(pkgInfo) if (versionName.isNullOrEmpty()) { - val exception = Exception("Missing versionName for extension $extName") - logcat(LogPriority.WARN, exception) + logcat(LogPriority.WARN) { "Missing versionName for extension $extName" } return LoadResult.Error } // Validate lib version val libVersion = versionName.substringBeforeLast('.').toDouble() if (libVersion < LIB_VERSION_MIN || libVersion > LIB_VERSION_MAX) { - val exception = Exception( + logcat(LogPriority.WARN) { "Lib version is $libVersion, while only versions " + - "$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed", - ) - logcat(LogPriority.WARN, exception) + "$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed" + } return LoadResult.Error }