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

30 lines
888 B
Java
Raw Normal View History

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