Commit 43b7ef81 authored by topjohnwu's avatar topjohnwu

Add disable, change busybox

parent 99ef0b8c
...@@ -21,6 +21,9 @@ import com.topjohnwu.magisk.utils.Logger; ...@@ -21,6 +21,9 @@ import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.Utils;
import java.io.File;
import java.io.IOException;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
...@@ -137,28 +140,41 @@ public class SettingsActivity extends AppCompatActivity { ...@@ -137,28 +140,41 @@ public class SettingsActivity extends AppCompatActivity {
Global.Events.reloadMainActivity.trigger(); Global.Events.reloadMainActivity.trigger();
} }
break; break;
case "magiskhide": case "disable":
enabled = prefs.getBoolean("magiskhide", false); enabled = prefs.getBoolean("disable", false);
File disable = new File(getActivity().getFilesDir() + "/disable");
if (enabled) if (enabled)
new Async.MagiskHide().enable(); try {
disable.createNewFile();
} catch (IOException e) {
e.printStackTrace();
prefs.edit().putBoolean("disable", false).apply();
}
else else
new Async.MagiskHide().disable(); disable.delete();
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
break; break;
case "busybox": case "busybox":
enabled = prefs.getBoolean("busybox", false); enabled = prefs.getBoolean("busybox", false);
new Async.RootTask<Void, Void, Void>() { File busybox = new File(getActivity().getFilesDir() + "/busybox");
private boolean enable = enabled; if (enabled)
@Override try {
protected Void doInBackground(Void... params) { busybox.createNewFile();
if (enable) } catch (IOException e) {
Utils.createFile("/magisk/.core/busybox/enable"); e.printStackTrace();
else prefs.edit().putBoolean("busybox", false).apply();
Utils.removeItem("/magisk/.core/busybox/enable");
return null;
} }
}.exec(); else
busybox.delete();
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
break; break;
case "magiskhide":
enabled = prefs.getBoolean("magiskhide", false);
if (enabled)
new Async.MagiskHide().enable();
else
new Async.MagiskHide().disable();
break;
case "hosts": case "hosts":
enabled = prefs.getBoolean("hosts", false); enabled = prefs.getBoolean("hosts", false);
new Async.RootTask<Void, Void, Void>() { new Async.RootTask<Void, Void, Void>() {
...@@ -179,8 +195,6 @@ public class SettingsActivity extends AppCompatActivity { ...@@ -179,8 +195,6 @@ public class SettingsActivity extends AppCompatActivity {
case "su_access": case "su_access":
Global.Configs.suAccessState = Utils.getPrefsInt(prefs, "su_access", 0); Global.Configs.suAccessState = Utils.getPrefsInt(prefs, "su_access", 0);
Shell.su("setprop persist.sys.root_access " + Global.Configs.suAccessState); Shell.su("setprop persist.sys.root_access " + Global.Configs.suAccessState);
suAccess.setSummary(getResources()
.getStringArray(R.array.su_access)[Global.Configs.suAccessState]);
break; break;
case "su_request_timeout": case "su_request_timeout":
Global.Configs.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10); Global.Configs.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10);
......
...@@ -185,5 +185,7 @@ ...@@ -185,5 +185,7 @@
<string name="pid">PID:\u0020</string> <string name="pid">PID:\u0020</string>
<string name="target_uid">Target UID:\u0020</string> <string name="target_uid">Target UID:\u0020</string>
<string name="command">Command:\u0020</string> <string name="command">Command:\u0020</string>
<string name="settings_disable_title">Disable Magic Mount</string>
<string name="settings_disable_summary">Disable Magic Mount, which will prevent all modules to work</string>
</resources> </resources>
...@@ -21,6 +21,11 @@ ...@@ -21,6 +21,11 @@
android:key="magisk" android:key="magisk"
android:title="@string/magisk"> android:title="@string/magisk">
<CheckBoxPreference
android:key="disable"
android:title="@string/settings_disable_title"
android:summary="@string/settings_disable_summary" />
<CheckBoxPreference <CheckBoxPreference
android:key="busybox" android:key="busybox"
android:defaultValue="false" android:defaultValue="false"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment