mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 23:07:38 +00:00
Make Magisk version more clear
This commit is contained in:
parent
2ca528f93f
commit
fd7b5f393a
@ -22,6 +22,7 @@ import com.topjohnwu.magisk.asyncs.CheckUpdates;
|
|||||||
import com.topjohnwu.magisk.components.AlertDialogBuilder;
|
import com.topjohnwu.magisk.components.AlertDialogBuilder;
|
||||||
import com.topjohnwu.magisk.components.ExpandableView;
|
import com.topjohnwu.magisk.components.ExpandableView;
|
||||||
import com.topjohnwu.magisk.components.Fragment;
|
import com.topjohnwu.magisk.components.Fragment;
|
||||||
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
import com.topjohnwu.magisk.utils.ShowUI;
|
import com.topjohnwu.magisk.utils.ShowUI;
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
@ -205,7 +206,7 @@ public class MagiskFragment extends Fragment
|
|||||||
|
|
||||||
boolean hasNetwork = Utils.checkNetworkStatus();
|
boolean hasNetwork = Utils.checkNetworkStatus();
|
||||||
boolean hasRoot = Shell.rootAccess();
|
boolean hasRoot = Shell.rootAccess();
|
||||||
boolean isUpToDate = mm.magiskVersionCode > 1300;
|
boolean isUpToDate = mm.magiskVersionCode > Const.MAGISK_VER.UNIFIED;
|
||||||
|
|
||||||
magiskUpdate.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
magiskUpdate.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||||
safetyNetCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
safetyNetCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||||
|
@ -210,7 +210,7 @@ public class MagiskManager extends Shell.ContainerApp {
|
|||||||
try {
|
try {
|
||||||
magiskVersionString = Utils.cmd("magisk -v").split(":")[0];
|
magiskVersionString = Utils.cmd("magisk -v").split(":")[0];
|
||||||
magiskVersionCode = Integer.parseInt(Utils.cmd("magisk -V"));
|
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);
|
+ Const.MAGISKHIDE_PROP);
|
||||||
magiskHide = s == null || Integer.parseInt(s) != 0;
|
magiskHide = s == null || Integer.parseInt(s) != 0;
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
@ -138,7 +138,7 @@ public class MainActivity extends Activity
|
|||||||
MagiskManager mm = getMagiskManager();
|
MagiskManager mm = getMagiskManager();
|
||||||
Menu menu = navigationView.getMenu();
|
Menu menu = navigationView.getMenu();
|
||||||
menu.findItem(R.id.magiskhide).setVisible(
|
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));
|
&& mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false));
|
||||||
menu.findItem(R.id.modules).setVisible(!mm.prefs.getBoolean(Const.Key.COREONLY, false) &&
|
menu.findItem(R.id.modules).setVisible(!mm.prefs.getBoolean(Const.Key.COREONLY, false) &&
|
||||||
Shell.rootAccess() && mm.magiskVersionCode >= 0);
|
Shell.rootAccess() && mm.magiskVersionCode >= 0);
|
||||||
|
@ -156,7 +156,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
fingerprint.setSummary(R.string.disable_fingerprint);
|
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)) {
|
if (mm.getPackageName().equals(Const.ORIG_PKG_NAME)) {
|
||||||
hideManager.setOnPreferenceClickListener((pref) -> {
|
hideManager.setOnPreferenceClickListener((pref) -> {
|
||||||
new HideManager(getActivity()).exec();
|
new HideManager(getActivity()).exec();
|
||||||
@ -194,7 +194,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
if (!Shell.rootAccess()) {
|
if (!Shell.rootAccess()) {
|
||||||
prefScreen.removePreference(magiskCategory);
|
prefScreen.removePreference(magiskCategory);
|
||||||
generalCatagory.removePreference(hideManager);
|
generalCatagory.removePreference(hideManager);
|
||||||
} else if (mm.magiskVersionCode < 1300) {
|
} else if (mm.magiskVersionCode < Const.MAGISK_VER.UNIFIED) {
|
||||||
prefScreen.removePreference(magiskCategory);
|
prefScreen.removePreference(magiskCategory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,10 +75,10 @@ public class MagiskDatabaseHelper {
|
|||||||
mm.loadMagiskInfo();
|
mm.loadMagiskInfo();
|
||||||
// Cleanup
|
// Cleanup
|
||||||
Shell.Sync.su("db_clean " + Const.USER_ID);
|
Shell.Sync.su("db_clean " + Const.USER_ID);
|
||||||
if (mm.magiskVersionCode < 1410) {
|
if (mm.magiskVersionCode < Const.MAGISK_VER.FBE_AWARE) {
|
||||||
// Super old legacy mode
|
// Super old legacy mode
|
||||||
return mm.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
|
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
|
// Legacy mode with FBE aware
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
de.moveDatabaseFrom(mm, "su.db");
|
de.moveDatabaseFrom(mm, "su.db");
|
||||||
@ -89,7 +89,7 @@ public class MagiskDatabaseHelper {
|
|||||||
final SuFile GLOBAL_DB = new SuFile("/data/adb/magisk.db", true);
|
final SuFile GLOBAL_DB = new SuFile("/data/adb/magisk.db", true);
|
||||||
mm.deleteDatabase("su.db");
|
mm.deleteDatabase("su.db");
|
||||||
de.deleteDatabase("su.db");
|
de.deleteDatabase("su.db");
|
||||||
if (mm.magiskVersionCode < 1460) {
|
if (mm.magiskVersionCode < Const.MAGISK_VER.HIDDEN_PATH) {
|
||||||
// Link to new path
|
// Link to new path
|
||||||
File oldDB = new File(de.getFilesDir().getParentFile().getParentFile(),
|
File oldDB = new File(de.getFilesDir().getParentFile().getParentFile(),
|
||||||
"magisk.db");
|
"magisk.db");
|
||||||
|
@ -48,7 +48,7 @@ public class ShortcutReceiver extends BroadcastReceiver {
|
|||||||
.setIcon(Icon.createWithResource(mm, R.drawable.sc_superuser))
|
.setIcon(Icon.createWithResource(mm, R.drawable.sc_superuser))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
if (Shell.rootAccess() && mm.magiskVersionCode >= 1300
|
if (Shell.rootAccess() && mm.magiskVersionCode >= Const.MAGISK_VER.UNIFIED
|
||||||
&& mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false)) {
|
&& mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false)) {
|
||||||
shortCuts.add(new ShortcutInfo.Builder(mm, "magiskhide")
|
shortCuts.add(new ShortcutInfo.Builder(mm, "magiskhide")
|
||||||
.setShortLabel(mm.getString(R.string.magiskhide))
|
.setShortLabel(mm.getString(R.string.magiskhide))
|
||||||
|
@ -69,6 +69,16 @@ public class Const {
|
|||||||
|
|
||||||
public static final int USER_ID = Process.myUid() / 100000;
|
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 class ID {
|
||||||
public static final int UPDATE_SERVICE_ID = 1;
|
public static final int UPDATE_SERVICE_ID = 1;
|
||||||
public static final int FETCH_ZIP = 2;
|
public static final int FETCH_ZIP = 2;
|
||||||
|
@ -268,7 +268,7 @@ public class ShowUI {
|
|||||||
Shell.Sync.su(
|
Shell.Sync.su(
|
||||||
Utils.fmt("echo '%s' > /cache/%s", uninstaller.toString().replace("'", "'\\''"), Const.UNINSTALLER),
|
Utils.fmt("echo '%s' > /cache/%s", uninstaller.toString().replace("'", "'\\''"), Const.UNINSTALLER),
|
||||||
Utils.fmt("echo '%s' > %s/%s", utils.toString().replace("'", "'\\''"),
|
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 {
|
try {
|
||||||
uninstaller.close();
|
uninstaller.close();
|
||||||
|
@ -202,7 +202,7 @@ public class Utils {
|
|||||||
|
|
||||||
public static void patchDTBO() {
|
public static void patchDTBO() {
|
||||||
MagiskManager mm = MagiskManager.get();
|
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")) {
|
if (ShellUtils.fastCmdResult(Shell.getShell(), "patch_dtbo_image")) {
|
||||||
ShowUI.dtboPatchedNotification();
|
ShowUI.dtboPatchedNotification();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user