From 43b7ef81109427026eb25b98a1fe8d61ea590358 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 2 Feb 2017 19:19:22 +0800 Subject: [PATCH] Add disable, change busybox --- .../topjohnwu/magisk/SettingsActivity.java | 48 ++++++++++++------- app/src/main/res/values/strings.xml | 2 + app/src/main/res/xml/app_settings.xml | 5 ++ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java index 993fd685f..839e5c923 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java @@ -21,6 +21,9 @@ import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Utils; +import java.io.File; +import java.io.IOException; + import butterknife.BindView; import butterknife.ButterKnife; @@ -137,6 +140,34 @@ public class SettingsActivity extends AppCompatActivity { Global.Events.reloadMainActivity.trigger(); } break; + case "disable": + enabled = prefs.getBoolean("disable", false); + File disable = new File(getActivity().getFilesDir() + "/disable"); + if (enabled) + try { + disable.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + prefs.edit().putBoolean("disable", false).apply(); + } + else + disable.delete(); + Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show(); + break; + case "busybox": + enabled = prefs.getBoolean("busybox", false); + File busybox = new File(getActivity().getFilesDir() + "/busybox"); + if (enabled) + try { + busybox.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + prefs.edit().putBoolean("busybox", false).apply(); + } + else + busybox.delete(); + Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show(); + break; case "magiskhide": enabled = prefs.getBoolean("magiskhide", false); if (enabled) @@ -144,21 +175,6 @@ public class SettingsActivity extends AppCompatActivity { else new Async.MagiskHide().disable(); break; - case "busybox": - enabled = prefs.getBoolean("busybox", false); - new Async.RootTask() { - private boolean enable = enabled; - @Override - protected Void doInBackground(Void... params) { - if (enable) - Utils.createFile("/magisk/.core/busybox/enable"); - else - Utils.removeItem("/magisk/.core/busybox/enable"); - return null; - } - }.exec(); - Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show(); - break; case "hosts": enabled = prefs.getBoolean("hosts", false); new Async.RootTask() { @@ -179,8 +195,6 @@ public class SettingsActivity extends AppCompatActivity { case "su_access": Global.Configs.suAccessState = Utils.getPrefsInt(prefs, "su_access", 0); Shell.su("setprop persist.sys.root_access " + Global.Configs.suAccessState); - suAccess.setSummary(getResources() - .getStringArray(R.array.su_access)[Global.Configs.suAccessState]); break; case "su_request_timeout": Global.Configs.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index aedbef4f6..9c9c74d2a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -185,5 +185,7 @@ PID:\u0020 Target UID:\u0020 Command:\u0020 + Disable Magic Mount + Disable Magic Mount, which will prevent all modules to work diff --git a/app/src/main/res/xml/app_settings.xml b/app/src/main/res/xml/app_settings.xml index 0cb9c9a60..e4f73372d 100644 --- a/app/src/main/res/xml/app_settings.xml +++ b/app/src/main/res/xml/app_settings.xml @@ -21,6 +21,11 @@ android:key="magisk" android:title="@string/magisk"> + +