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;
|
2018-12-13 04:35:50 -05:00
|
|
|
import com.topjohnwu.core.tasks.CheckUpdates;
|
|
|
|
import com.topjohnwu.magisk.BuildConfig;
|
|
|
|
import com.topjohnwu.magisk.components.Notifications;
|
2018-07-31 03:51:11 +08:00
|
|
|
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() {
|
2018-07-31 03:51:11 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|