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