From 56d2fb9a3b06d136d1586556b676a26c7d27eedc Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 2 Feb 2019 05:30:16 -0500 Subject: [PATCH] Prevent Magisk Manager to run on pre-v18.0 --- .../main/java/com/topjohnwu/magisk/Const.java | 2 +- .../com/topjohnwu/magisk/SplashActivity.java | 21 ++++++++++++++++--- app/src/full/res/values/strings.xml | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app-core/src/main/java/com/topjohnwu/magisk/Const.java b/app-core/src/main/java/com/topjohnwu/magisk/Const.java index dd0be4ddb..ea646b51d 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/Const.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/Const.java @@ -46,7 +46,7 @@ public class Const { public static final int USER_ID = Process.myUid() / 100000; public static final class MAGISK_VER { - /* Currently no backwards compatibility needed */ + public static final int MIN_SUPPORT = 18000; } public static class ID { diff --git a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java index 0710e4bec..bbb4d5e66 100644 --- a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java @@ -15,15 +15,14 @@ import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.net.Networking; import com.topjohnwu.superuser.Shell; +import androidx.appcompat.app.AlertDialog; + public class SplashActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Dynamic detect all locales - LocaleManager.loadAvailableLocales(R.string.app_changelog); - String pkg = Config.get(Config.Key.SU_MANAGER); if (pkg != null && getPackageName().equals(BuildConfig.APPLICATION_ID)) { Config.remove(Config.Key.SU_MANAGER); @@ -37,6 +36,22 @@ public class SplashActivity extends BaseActivity { } catch (PackageManager.NameNotFoundException ignored) {} } + if (Config.magiskVersionCode > 0 && Config.magiskVersionCode < Const.MAGISK_VER.MIN_SUPPORT) { + new AlertDialog.Builder(this) + .setTitle(R.string.unsupport_magisk_title) + .setMessage(R.string.unsupport_magisk_message) + .setNegativeButton(R.string.ok, null) + .setOnDismissListener(dialog -> finish()) + .show(); + } else { + initAndStart(); + } + } + + private void initAndStart() { + // Dynamic detect all locales + LocaleManager.loadAvailableLocales(R.string.app_changelog); + // Set default configs Config.initialize(); diff --git a/app/src/full/res/values/strings.xml b/app/src/full/res/values/strings.xml index 4a7cb0bc8..57f9b71cf 100644 --- a/app/src/full/res/values/strings.xml +++ b/app/src/full/res/values/strings.xml @@ -7,6 +7,8 @@ Log Settings Install + Unsupported Magisk Version + This version of Magisk Manager does not support Magisk version lower than v18.0.\n\nYou can either manually upgrade Magisk, or downgrade the app to an older version. Magisk is not installed.