Magisk/app/src/full/java/com/topjohnwu/magisk/services/UpdateCheckService.java

30 lines
884 B
Java
Raw Normal View History

2017-02-17 08:51:51 +08:00
package com.topjohnwu.magisk.services;
2019-01-21 15:49:03 -05:00
import com.topjohnwu.core.Config;
import com.topjohnwu.core.tasks.CheckUpdates;
import com.topjohnwu.magisk.BuildConfig;
import com.topjohnwu.magisk.components.Notifications;
import com.topjohnwu.superuser.Shell;
2017-02-17 08:51:51 +08:00
2018-12-27 22:07:47 +08:00
import androidx.annotation.NonNull;
import androidx.work.ListenableWorker;
public class UpdateCheckService extends DelegateWorker {
2017-07-19 16:10:17 +08:00
2018-12-27 22:07:47 +08:00
@NonNull
2017-02-17 08:51:51 +08:00
@Override
2018-12-27 22:07:47 +08:00
public ListenableWorker.Result doWork() {
Shell.getShell();
2018-12-27 22:07:47 +08:00
CheckUpdates.checkNow(this::onCheckDone);
return ListenableWorker.Result.success();
2017-02-17 08:51:51 +08:00
}
2018-12-27 22:07:47 +08:00
private void onCheckDone() {
2019-01-21 15:49:03 -05:00
if (BuildConfig.VERSION_CODE < Config.remoteManagerVersionCode) {
2018-12-27 22:07:47 +08:00
Notifications.managerUpdate();
2019-01-21 15:49:03 -05:00
} else if (Config.magiskVersionCode < Config.remoteMagiskVersionCode) {
2018-12-27 22:07:47 +08:00
Notifications.magiskUpdate();
}
2017-02-17 08:51:51 +08:00
}
}