UpdateWorker: Respect incompatible updates setting

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-10-24 18:56:13 +05:30
parent 3395751974
commit 1943d672ae

View File

@@ -74,6 +74,9 @@ class UpdateWorker @AssistedInject constructor(
!CertUtil.isAppGalleryApp(appContext, BuildConfig.APPLICATION_ID) &&
buildType != BuildType.DEBUG
private val isExtendedUpdateEnabled: Boolean
get() = Preferences.getBoolean(appContext, Preferences.PREFERENCE_UPDATES_EXTENDED)
override suspend fun doWork(): Result {
super.doWork()
@@ -94,10 +97,9 @@ class UpdateWorker @AssistedInject constructor(
}
try {
val updates = checkUpdates().also {
// Cache the updates into the database
updateDao.insertUpdates(it)
}
val updates = checkUpdates()
.also { updateDao.insertUpdates(it) }
.filter { if (!isExtendedUpdateEnabled) it.hasValidCert else true }
if (updates.isEmpty()) {
Log.i(TAG, "No updates found!")