mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 10:35:26 +00:00
Properly detect hosts file
This commit is contained in:
parent
a3abb86daa
commit
5762ded601
@ -44,6 +44,7 @@ import java.util.concurrent.ExecutionException;
|
||||
public class MagiskManager extends Application {
|
||||
|
||||
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 INTENT_SECTION = "section";
|
||||
@ -264,7 +265,7 @@ public class MagiskManager extends Application {
|
||||
.putBoolean("dark_theme", isDarkTheme)
|
||||
.putBoolean("magiskhide", magiskHide)
|
||||
.putBoolean("notification", updateNotification)
|
||||
.putBoolean("hosts", new File("/magisk/.core/hosts").exists())
|
||||
.putBoolean("hosts", Utils.itemExist(shell, MAGISK_HOST_FILE))
|
||||
.putBoolean("disable", Utils.itemExist(shell, MAGISK_DISABLE_FILE))
|
||||
.putBoolean("su_reauth", suReauth)
|
||||
.putString("su_request_timeout", String.valueOf(suRequestTimeout))
|
||||
|
@ -221,12 +221,12 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
||||
enabled = prefs.getBoolean("hosts", false);
|
||||
if (enabled) {
|
||||
getShell().su_raw(
|
||||
"cp -af /system/etc/hosts /magisk/.core/hosts",
|
||||
"mount -o bind /magisk/.core/hosts /system/etc/hosts");
|
||||
"cp -af /system/etc/hosts " + MagiskManager.MAGISK_HOST_FILE,
|
||||
"mount -o bind " + MagiskManager.MAGISK_HOST_FILE + " /system/etc/hosts");
|
||||
} else {
|
||||
getShell().su_raw(
|
||||
"umount -l /system/etc/hosts",
|
||||
"rm -f /magisk/.core/hosts");
|
||||
"rm -f " + MagiskManager.MAGISK_HOST_FILE);
|
||||
}
|
||||
break;
|
||||
case "su_access":
|
||||
|
Loading…
Reference in New Issue
Block a user