Add CLI to detect MagiskHide status

This commit is contained in:
topjohnwu
2018-11-16 00:37:41 -05:00
parent 572e078d87
commit 3aad9d8166
5 changed files with 58 additions and 44 deletions

View File

@@ -44,11 +44,11 @@ public class Const {
public static final int USER_ID = Process.myUid() / 100000;
public static final class MAGISK_VER {
public static final int REMOVE_LEGACY_LINK = 1630;
public static final int SEPOL_REFACTOR = 1640;
public static final int FIX_ENV = 1650;
public static final int DBVER_SIX = 17000;
public static final int CMDLINE_DB = 17305;
public static final int HIDE_STATUS = 17315;
}
public static class ID {

View File

@@ -91,8 +91,12 @@ public class Data {
try {
magiskVersionString = ShellUtils.fastCmd("magisk -v").split(":")[0];
magiskVersionCode = Integer.parseInt(ShellUtils.fastCmd("magisk -V"));
String s = ShellUtils.fastCmd(("resetprop -p ") + Const.MAGISKHIDE_PROP);
magiskHide = s.isEmpty() || Integer.parseInt(s) != 0;
if (magiskVersionCode >= Const.MAGISK_VER.HIDE_STATUS) {
magiskHide = Shell.su("magiskhide --status").exec().isSuccess();
} else {
String s = ShellUtils.fastCmd(("resetprop -p ") + Const.MAGISKHIDE_PROP);
magiskHide = s.isEmpty() || Integer.parseInt(s) != 0;
}
} catch (NumberFormatException ignored) {}
}