2017-02-17 01:51:51 +01:00
|
|
|
package com.topjohnwu.magisk.services;
|
|
|
|
|
2018-12-13 10:35:50 +01:00
|
|
|
import com.topjohnwu.magisk.BuildConfig;
|
2019-01-30 09:10:12 +01:00
|
|
|
import com.topjohnwu.magisk.Config;
|
2018-12-13 10:35:50 +01:00
|
|
|
import com.topjohnwu.magisk.components.Notifications;
|
2019-01-30 09:10:12 +01:00
|
|
|
import com.topjohnwu.magisk.tasks.CheckUpdates;
|
2018-07-30 21:51:11 +02:00
|
|
|
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() {
|
2018-07-30 21:51:11 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|