Commit 1d54c514 authored by topjohnwu's avatar topjohnwu

Fix background update checks

parent e40d4318
...@@ -7,17 +7,20 @@ import com.topjohnwu.magisk.data.repository.MagiskRepository ...@@ -7,17 +7,20 @@ import com.topjohnwu.magisk.data.repository.MagiskRepository
import com.topjohnwu.magisk.model.worker.DelegateWorker import com.topjohnwu.magisk.model.worker.DelegateWorker
import com.topjohnwu.magisk.utils.inject import com.topjohnwu.magisk.utils.inject
import com.topjohnwu.magisk.view.Notifications import com.topjohnwu.magisk.view.Notifications
import com.topjohnwu.superuser.Shell
class UpdateCheckService : DelegateWorker() { class UpdateCheckService : DelegateWorker() {
private val magiskRepo: MagiskRepository by inject() private val magiskRepo: MagiskRepository by inject()
override fun doWork(): ListenableWorker.Result { override fun doWork(): ListenableWorker.Result {
// Make sure shell initializer was ran
Shell.getShell()
return runCatching { return runCatching {
magiskRepo.fetchUpdate().blockingGet() magiskRepo.fetchUpdate().blockingGet()
if (BuildConfig.VERSION_CODE < Info.remoteManagerVersionCode) if (BuildConfig.VERSION_CODE < Info.remoteManagerVersionCode)
Notifications.managerUpdate() Notifications.managerUpdate()
else if (Info.magiskVersionCode < Info.remoteManagerVersionCode) else if (Info.magiskVersionCode < Info.remoteMagiskVersionCode)
Notifications.magiskUpdate() Notifications.magiskUpdate()
ListenableWorker.Result.success() ListenableWorker.Result.success()
}.getOrElse { }.getOrElse {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment