Add disable, change busybox

This commit is contained in:
topjohnwu 2017-02-02 19:19:22 +08:00
parent 99ef0b8cb4
commit 43b7ef8110
3 changed files with 38 additions and 17 deletions

View File

@ -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,6 +140,34 @@ public class SettingsActivity extends AppCompatActivity {
Global.Events.reloadMainActivity.trigger(); Global.Events.reloadMainActivity.trigger();
} }
break; 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": case "magiskhide":
enabled = prefs.getBoolean("magiskhide", false); enabled = prefs.getBoolean("magiskhide", false);
if (enabled) if (enabled)
@ -144,21 +175,6 @@ public class SettingsActivity extends AppCompatActivity {
else else
new Async.MagiskHide().disable(); new Async.MagiskHide().disable();
break; break;
case "busybox":
enabled = prefs.getBoolean("busybox", false);
new Async.RootTask<Void, Void, Void>() {
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": 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 {
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);

View File

@ -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>

View File

@ -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"