cancel app update job if updater is not included in build
This commit is contained in:
parent
b831349b37
commit
181dc1d56e
1 changed files with 7 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ import androidx.work.NetworkType
|
|||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkerParameters
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
import exh.log.xLogE
|
||||
|
|
@ -20,6 +21,10 @@ class AppUpdateJob(private val context: Context, workerParams: WorkerParameters)
|
|||
|
||||
override suspend fun doWork(): Result = coroutineScope {
|
||||
try {
|
||||
if (!BuildConfig.INCLUDE_UPDATER) {
|
||||
cancelTask(context)
|
||||
return@coroutineScope Result.success()
|
||||
}
|
||||
AppUpdateChecker().checkForUpdate(context)
|
||||
Result.success()
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -55,7 +60,9 @@ class AppUpdateJob(private val context: Context, workerParams: WorkerParameters)
|
|||
}
|
||||
|
||||
fun cancelTask(context: Context) {
|
||||
// cancel and remove job
|
||||
WorkManager.getInstance(context).cancelAllWorkByTag(TAG)
|
||||
WorkManager.getInstance(context).pruneWork()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue