Make Magisk version more clear

This commit is contained in:
topjohnwu 2018-04-14 15:32:37 +08:00
parent 2ca528f93f
commit fd7b5f393a
9 changed files with 22 additions and 11 deletions

View File

@ -22,6 +22,7 @@ import com.topjohnwu.magisk.asyncs.CheckUpdates;
import com.topjohnwu.magisk.components.AlertDialogBuilder;
import com.topjohnwu.magisk.components.ExpandableView;
import com.topjohnwu.magisk.components.Fragment;
import com.topjohnwu.magisk.utils.Const;
import com.topjohnwu.magisk.utils.ShowUI;
import com.topjohnwu.magisk.utils.Topic;
import com.topjohnwu.magisk.utils.Utils;
@ -205,7 +206,7 @@ public class MagiskFragment extends Fragment
boolean hasNetwork = Utils.checkNetworkStatus();
boolean hasRoot = Shell.rootAccess();
boolean isUpToDate = mm.magiskVersionCode > 1300;
boolean isUpToDate = mm.magiskVersionCode > Const.MAGISK_VER.UNIFIED;
magiskUpdate.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
safetyNetCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);

View File

@ -210,7 +210,7 @@ public class MagiskManager extends Shell.ContainerApp {
try {
magiskVersionString = Utils.cmd("magisk -v").split(":")[0];
magiskVersionCode = Integer.parseInt(Utils.cmd("magisk -V"));
String s = Utils.cmd((magiskVersionCode > 1435 ? "resetprop -p " : "getprop ")
String s = Utils.cmd((magiskVersionCode >= Const.MAGISK_VER.RESETPROP_PERSIST ? "resetprop -p " : "getprop ")
+ Const.MAGISKHIDE_PROP);
magiskHide = s == null || Integer.parseInt(s) != 0;
} catch (Exception ignored) {}

View File

@ -138,7 +138,7 @@ public class MainActivity extends Activity
MagiskManager mm = getMagiskManager();
Menu menu = navigationView.getMenu();
menu.findItem(R.id.magiskhide).setVisible(
Shell.rootAccess() && mm.magiskVersionCode >= 1300
Shell.rootAccess() && mm.magiskVersionCode >= Const.MAGISK_VER.UNIFIED
&& mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false));
menu.findItem(R.id.modules).setVisible(!mm.prefs.getBoolean(Const.Key.COREONLY, false) &&
Shell.rootAccess() && mm.magiskVersionCode >= 0);

View File

@ -156,7 +156,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
fingerprint.setSummary(R.string.disable_fingerprint);
}
if (mm.magiskVersionCode >= 1440) {
if (mm.magiskVersionCode >= Const.MAGISK_VER.MANAGER_HIDE) {
if (mm.getPackageName().equals(Const.ORIG_PKG_NAME)) {
hideManager.setOnPreferenceClickListener((pref) -> {
new HideManager(getActivity()).exec();
@ -194,7 +194,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
if (!Shell.rootAccess()) {
prefScreen.removePreference(magiskCategory);
generalCatagory.removePreference(hideManager);
} else if (mm.magiskVersionCode < 1300) {
} else if (mm.magiskVersionCode < Const.MAGISK_VER.UNIFIED) {
prefScreen.removePreference(magiskCategory);
}
}

View File

@ -75,10 +75,10 @@ public class MagiskDatabaseHelper {
mm.loadMagiskInfo();
// Cleanup
Shell.Sync.su("db_clean " + Const.USER_ID);
if (mm.magiskVersionCode < 1410) {
if (mm.magiskVersionCode < Const.MAGISK_VER.FBE_AWARE) {
// Super old legacy mode
return mm.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
} else if (mm.magiskVersionCode < 1450) {
} else if (mm.magiskVersionCode < Const.MAGISK_VER.LEGACY_GLOBAL_DB) {
// Legacy mode with FBE aware
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
de.moveDatabaseFrom(mm, "su.db");
@ -89,7 +89,7 @@ public class MagiskDatabaseHelper {
final SuFile GLOBAL_DB = new SuFile("/data/adb/magisk.db", true);
mm.deleteDatabase("su.db");
de.deleteDatabase("su.db");
if (mm.magiskVersionCode < 1460) {
if (mm.magiskVersionCode < Const.MAGISK_VER.HIDDEN_PATH) {
// Link to new path
File oldDB = new File(de.getFilesDir().getParentFile().getParentFile(),
"magisk.db");

View File

@ -48,7 +48,7 @@ public class ShortcutReceiver extends BroadcastReceiver {
.setIcon(Icon.createWithResource(mm, R.drawable.sc_superuser))
.build());
}
if (Shell.rootAccess() && mm.magiskVersionCode >= 1300
if (Shell.rootAccess() && mm.magiskVersionCode >= Const.MAGISK_VER.UNIFIED
&& mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false)) {
shortCuts.add(new ShortcutInfo.Builder(mm, "magiskhide")
.setShortLabel(mm.getString(R.string.magiskhide))

View File

@ -69,6 +69,16 @@ public class Const {
public static final int USER_ID = Process.myUid() / 100000;
public static final class MAGISK_VER {
public static final int UNIFIED = 1300;
public static final int FBE_AWARE = 1410;
public static final int RESETPROP_PERSIST = 1436;
public static final int MANAGER_HIDE = 1440;
public static final int DTBO_SUPPORT = 1446;
public static final int LEGACY_GLOBAL_DB = 1450;
public static final int HIDDEN_PATH = 1460;
}
public static class ID {
public static final int UPDATE_SERVICE_ID = 1;
public static final int FETCH_ZIP = 2;

View File

@ -268,7 +268,7 @@ public class ShowUI {
Shell.Sync.su(
Utils.fmt("echo '%s' > /cache/%s", uninstaller.toString().replace("'", "'\\''"), Const.UNINSTALLER),
Utils.fmt("echo '%s' > %s/%s", utils.toString().replace("'", "'\\''"),
mm.magiskVersionCode >= 1464 ? "/data/adb/magisk" : "/data/magisk", Const.UTIL_FUNCTIONS)
mm.magiskVersionCode >= Const.MAGISK_VER.HIDDEN_PATH ? "/data/adb/magisk" : "/data/magisk", Const.UTIL_FUNCTIONS)
);
try {
uninstaller.close();

View File

@ -202,7 +202,7 @@ public class Utils {
public static void patchDTBO() {
MagiskManager mm = MagiskManager.get();
if (mm.magiskVersionCode >= 1446 && !mm.keepVerity) {
if (mm.magiskVersionCode >= Const.MAGISK_VER.DTBO_SUPPORT && !mm.keepVerity) {
if (ShellUtils.fastCmdResult(Shell.getShell(), "patch_dtbo_image")) {
ShowUI.dtboPatchedNotification();
}