From 70eba568afff40399b5a3985b5ccc66922673235 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 2 Feb 2019 02:27:15 -0500 Subject: [PATCH] Do not check update twice --- app/src/full/java/com/topjohnwu/magisk/SplashActivity.java | 4 +--- app/src/full/java/com/topjohnwu/magisk/utils/AppUtils.java | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java index 7369b404b..e04a88680 100644 --- a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java @@ -28,7 +28,7 @@ public class SplashActivity extends BaseActivity { String pkg = Config.get(Config.Key.SU_MANAGER); if (pkg != null && getPackageName().equals(BuildConfig.APPLICATION_ID)) { Config.remove(Config.Key.SU_MANAGER); - Shell.su("pm uninstall " + pkg).exec(); + Shell.su("pm uninstall " + pkg).submit(); } if (TextUtils.equals(pkg, getPackageName())) { try { @@ -57,8 +57,6 @@ public class SplashActivity extends BaseActivity { Shortcuts.setup(this); if (Networking.checkNetworkStatus(this)) { - // Fire update check - CheckUpdates.check(); // Repo update check new UpdateRepos().exec(); } diff --git a/app/src/full/java/com/topjohnwu/magisk/utils/AppUtils.java b/app/src/full/java/com/topjohnwu/magisk/utils/AppUtils.java index b8232e15e..1f3dda5ee 100644 --- a/app/src/full/java/com/topjohnwu/magisk/utils/AppUtils.java +++ b/app/src/full/java/com/topjohnwu/magisk/utils/AppUtils.java @@ -10,6 +10,7 @@ import com.topjohnwu.magisk.Config; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.components.UpdateCheckService; +import com.topjohnwu.magisk.tasks.CheckUpdates; import java.util.concurrent.TimeUnit; @@ -30,10 +31,12 @@ public class AppUtils { .Builder(ClassMap.get(UpdateCheckService.class), 12, TimeUnit.HOURS) .setConstraints(constraints) .build(); - WorkManager.getInstance().enqueueUniquePeriodicWork(Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID, + WorkManager.getInstance().enqueueUniquePeriodicWork( + Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID, ExistingPeriodicWorkPolicy.REPLACE, request); } else { WorkManager.getInstance().cancelUniqueWork(Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID); + CheckUpdates.check(); } }