Skip to content

Commit

Permalink
Run update check service only in background
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Apr 8, 2019
1 parent fc0df84 commit f187213
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

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;
Expand Down Expand Up @@ -63,6 +64,7 @@ private void initAndStart() {

// Schedule periodic update checks
Utils.scheduleUpdateCheck();
CheckUpdates.check();

// Setup shortcuts
Shortcuts.setup(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand All @@ -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();
}

Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public static void scheduleUpdateCheck() {
ExistingPeriodicWorkPolicy.REPLACE, request);
} else {
WorkManager.getInstance().cancelUniqueWork(Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID);
CheckUpdates.check();
}
}

Expand Down

0 comments on commit f187213

Please sign in to comment.