mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 08:29:20 +01:00
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.
This commit is contained in:
parent
a5a70defc8
commit
6be9cccc7a
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.Build
|
||||||
import androidx.core.content.pm.PackageInfoCompat
|
import androidx.core.content.pm.PackageInfoCompat
|
||||||
import dalvik.system.PathClassLoader
|
import dalvik.system.PathClassLoader
|
||||||
import eu.kanade.domain.source.service.SourcePreferences
|
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_NSFW = "tachiyomi.extension.nsfw"
|
||||||
private const val METADATA_HAS_README = "tachiyomi.extension.hasReadme"
|
private const val METADATA_HAS_README = "tachiyomi.extension.hasReadme"
|
||||||
private const val METADATA_HAS_CHANGELOG = "tachiyomi.extension.hasChangelog"
|
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
|
const val LIB_VERSION_MAX = 1.4
|
||||||
|
|
||||||
private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES
|
private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES
|
||||||
@ -57,7 +58,14 @@ internal object ExtensionLoader {
|
|||||||
*/
|
*/
|
||||||
fun loadExtensions(context: Context): List<LoadResult> {
|
fun loadExtensions(context: Context): List<LoadResult> {
|
||||||
val pkgManager = context.packageManager
|
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) }
|
val extPkgs = installedPkgs.filter { isPackageAnExtension(it) }
|
||||||
|
|
||||||
if (extPkgs.isEmpty()) return emptyList()
|
if (extPkgs.isEmpty()) return emptyList()
|
||||||
@ -113,19 +121,17 @@ internal object ExtensionLoader {
|
|||||||
val versionCode = PackageInfoCompat.getLongVersionCode(pkgInfo)
|
val versionCode = PackageInfoCompat.getLongVersionCode(pkgInfo)
|
||||||
|
|
||||||
if (versionName.isNullOrEmpty()) {
|
if (versionName.isNullOrEmpty()) {
|
||||||
val exception = Exception("Missing versionName for extension $extName")
|
logcat(LogPriority.WARN) { "Missing versionName for extension $extName" }
|
||||||
logcat(LogPriority.WARN, exception)
|
|
||||||
return LoadResult.Error
|
return LoadResult.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate lib version
|
// Validate lib version
|
||||||
val libVersion = versionName.substringBeforeLast('.').toDouble()
|
val libVersion = versionName.substringBeforeLast('.').toDouble()
|
||||||
if (libVersion < LIB_VERSION_MIN || libVersion > LIB_VERSION_MAX) {
|
if (libVersion < LIB_VERSION_MIN || libVersion > LIB_VERSION_MAX) {
|
||||||
val exception = Exception(
|
logcat(LogPriority.WARN) {
|
||||||
"Lib version is $libVersion, while only versions " +
|
"Lib version is $libVersion, while only versions " +
|
||||||
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed",
|
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed"
|
||||||
)
|
}
|
||||||
logcat(LogPriority.WARN, exception)
|
|
||||||
return LoadResult.Error
|
return LoadResult.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user