diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java index 1df97b9ba..ffe23a714 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java @@ -218,12 +218,12 @@ public class SettingsActivity extends Activity implements Topic.Subscriber { enabled = prefs.getBoolean(Const.Key.HOSTS, false); if (enabled) { Shell.su_raw( - "cp -af /system/etc/hosts " + Const.MAGISK_HOST_FILE, - "mount -o bind " + Const.MAGISK_HOST_FILE + " /system/etc/hosts"); + "cp -af /system/etc/hosts " + Const.MAGISK_HOST_FILE(), + "mount -o bind " + Const.MAGISK_HOST_FILE() + " /system/etc/hosts"); } else { Shell.su_raw( "umount -l /system/etc/hosts", - "rm -f " + Const.MAGISK_HOST_FILE); + "rm -f " + Const.MAGISK_HOST_FILE()); } break; case Const.Key.ROOT_ACCESS: diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index 4cba4fb39..6ffdacbd8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -112,7 +112,7 @@ public class SplashActivity extends Activity { .putBoolean(Const.Key.DARK_THEME, mm.isDarkTheme) .putBoolean(Const.Key.MAGISKHIDE, mm.magiskHide) .putBoolean(Const.Key.UPDATE_NOTIFICATION, mm.updateNotification) - .putBoolean(Const.Key.HOSTS, Utils.itemExist(Const.MAGISK_HOST_FILE)) + .putBoolean(Const.Key.HOSTS, Utils.itemExist(Const.MAGISK_HOST_FILE())) .putBoolean(Const.Key.DISABLE, Utils.itemExist(Const.MAGISK_DISABLE_FILE)) .putBoolean(Const.Key.SU_REAUTH, mm.suReauth) .putString(Const.Key.SU_REQUEST_TIMEOUT, String.valueOf(mm.suRequestTimeout)) diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/LoadModules.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/LoadModules.java index b17a16104..4efeef542 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/LoadModules.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/LoadModules.java @@ -11,7 +11,7 @@ import java.util.List; public class LoadModules extends ParallelTask { private List getModList() { - String command = "ls -d " + Const.MAGISK_PATH + "/* | grep -v lost+found"; + String command = "ls -d " + Const.MAGISK_PATH() + "/* | grep -v lost+found"; return Shell.su(command); } diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Const.java b/app/src/main/java/com/topjohnwu/magisk/utils/Const.java index bfc991d93..df4c11481 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Const.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Const.java @@ -20,12 +20,22 @@ public class Const { // Paths public static final String MAGISK_DISABLE_FILE = "/cache/.disable_magisk"; - public static final String MAGISK_HOST_FILE = "/magisk/.core/hosts"; public static final String TMP_FOLDER_PATH = "/dev/tmp"; - public static final String MAGISK_PATH = "/magisk"; public static final String MAGISK_LOG = "/cache/magisk.log"; public static final String BUSYBOXPATH = "/dev/magisk/bin"; + public static String MAGISK_PATH() { + if (Utils.itemExist("/dev/magisk/img")) { + return "/dev/magisk/img"; + } else { + return "/magisk"; + } + } + + public static String MAGISK_HOST_FILE() { + return MAGISK_PATH() + "/.core/hosts"; + } + /* A list of apps that should not be shown as hide-able */ public static final List SN_BLACKLIST = Arrays.asList( "android",