Commit f1872135 authored by topjohnwu's avatar topjohnwu

Run update check service only in background

parent fc0df84e
......@@ -9,6 +9,7 @@ import androidx.appcompat.app.AlertDialog;
import com.topjohnwu.magisk.components.BaseActivity;
import com.topjohnwu.magisk.database.RepoDatabaseHelper;
import com.topjohnwu.magisk.tasks.CheckUpdates;
import com.topjohnwu.magisk.tasks.UpdateRepos;
import com.topjohnwu.magisk.uicomponents.Notifications;
import com.topjohnwu.magisk.uicomponents.Shortcuts;
......@@ -63,6 +64,7 @@ public class SplashActivity extends BaseActivity {
// Schedule periodic update checks
Utils.scheduleUpdateCheck();
CheckUpdates.check();
// Setup shortcuts
Shortcuts.setup(this);
......
......@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.components;
import androidx.annotation.NonNull;
import androidx.work.ListenableWorker;
import com.topjohnwu.magisk.App;
import com.topjohnwu.magisk.BuildConfig;
import com.topjohnwu.magisk.Config;
import com.topjohnwu.magisk.tasks.CheckUpdates;
......@@ -14,8 +15,10 @@ public class UpdateCheckService extends DelegateWorker {
@NonNull
@Override
public ListenableWorker.Result doWork() {
Shell.getShell();
CheckUpdates.check(this::onCheckDone);
if (App.self.foreground == null) {
Shell.getShell();
CheckUpdates.check(this::onCheckDone);
}
return ListenableWorker.Result.success();
}
......
......@@ -158,7 +158,6 @@ public class Utils {
ExistingPeriodicWorkPolicy.REPLACE, request);
} else {
WorkManager.getInstance().cancelUniqueWork(Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID);
CheckUpdates.check();
}
}
......
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