mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-05-19 05:55:04 -04:00
Use PackageInfoCompat.getLongVersionCode().
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
6b356c8ba2
commit
4ae3da15f0
@@ -4,6 +4,7 @@ import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.core.content.pm.PackageInfoCompat
|
||||
import androidx.core.os.ConfigurationCompat.getLocales
|
||||
import androidx.core.os.LocaleListCompat
|
||||
import androidx.lifecycle.LiveData
|
||||
@@ -396,7 +397,7 @@ internal interface AppDaoInt : AppDao {
|
||||
val packageInfo = installedPackages[item.packageName]
|
||||
if (packageInfo == null) item else item.copy(
|
||||
installedVersionName = packageInfo.versionName,
|
||||
installedVersionCode = packageInfo.getVersionCode(),
|
||||
installedVersionCode = PackageInfoCompat.getLongVersionCode(packageInfo),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.PackageManager.GET_SIGNATURES
|
||||
import android.os.Build
|
||||
import androidx.core.content.pm.PackageInfoCompat
|
||||
import org.fdroid.CompatibilityChecker
|
||||
import org.fdroid.CompatibilityCheckerImpl
|
||||
import org.fdroid.PackagePreference
|
||||
@@ -42,7 +42,7 @@ public class DbUpdateChecker @JvmOverloads constructor(
|
||||
val versions = versionsByPackage[packageName] ?: return@forEach // continue
|
||||
val version = getVersion(versions, packageName, packageInfo, null, releaseChannels)
|
||||
if (version != null) {
|
||||
val versionCode = packageInfo.getVersionCode()
|
||||
val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo)
|
||||
val app = getUpdatableApp(version, versionCode)
|
||||
if (app != null) updatableApps.add(app)
|
||||
}
|
||||
@@ -127,12 +127,3 @@ public class DbUpdateChecker @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun PackageInfo.getVersionCode(): Long {
|
||||
return if (Build.VERSION.SDK_INT >= 28) {
|
||||
longVersionCode
|
||||
} else {
|
||||
@Suppress("DEPRECATION") // we use the new one above, if available
|
||||
versionCode.toLong()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user