mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 21:45:27 +00:00
Add several options
This commit is contained in:
parent
e76dba0f84
commit
8a8f24f93e
@ -11,9 +11,11 @@ import android.support.v7.app.ActionBar;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -80,18 +82,21 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
themePreference = (ListPreference) findPreference("theme");
|
themePreference = (ListPreference) findPreference("theme");
|
||||||
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
||||||
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
|
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
|
||||||
|
CheckBoxPreference hostsPreference = (CheckBoxPreference) findPreference("hosts");
|
||||||
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
themePreference.setSummary(themePreference.getValue());
|
themePreference.setSummary(themePreference.getValue());
|
||||||
|
|
||||||
if (MagiskFragment.magiskVersion < 8) {
|
if (MagiskFragment.magiskVersion < 9) {
|
||||||
magiskhidePreference.setEnabled(false);
|
hostsPreference.setEnabled(false);
|
||||||
} else if (MagiskFragment.magiskVersion < 7) {
|
|
||||||
busyboxPreference.setEnabled(false);
|
busyboxPreference.setEnabled(false);
|
||||||
|
} else if (MagiskFragment.magiskVersion < 8) {
|
||||||
|
magiskhidePreference.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
busyboxPreference.setEnabled(true);
|
busyboxPreference.setEnabled(true);
|
||||||
magiskhidePreference.setEnabled(true);
|
magiskhidePreference.setEnabled(true);
|
||||||
|
hostsPreference.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +115,7 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
Logger.dev("Settings: Prefs change " + key);
|
Logger.dev("Settings: Prefs change " + key);
|
||||||
|
boolean checked;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "theme":
|
case "theme":
|
||||||
@ -127,7 +133,7 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case "magiskhide":
|
case "magiskhide":
|
||||||
boolean checked = sharedPreferences.getBoolean("magiskhide", false);
|
checked = sharedPreferences.getBoolean("magiskhide", false);
|
||||||
if (checked) {
|
if (checked) {
|
||||||
new Async.RootTask<Void, Void, Void>() {
|
new Async.RootTask<Void, Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
@ -148,7 +154,45 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
case "busybox":
|
case "busybox":
|
||||||
checked = sharedPreferences.getBoolean("busybox", false);
|
checked = sharedPreferences.getBoolean("busybox", false);
|
||||||
new Async.LinkBusyBox(checked).exec();
|
if (checked) {
|
||||||
|
new Async.RootTask<Void, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
Utils.createFile("/magisk/.core/busybox/enable");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.exec();
|
||||||
|
} else {
|
||||||
|
new Async.RootTask<Void, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
Utils.removeItem("/magisk/.core/busybox/enable");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.exec();
|
||||||
|
}
|
||||||
|
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
case "hosts":
|
||||||
|
checked = sharedPreferences.getBoolean("hosts", false);
|
||||||
|
if (checked) {
|
||||||
|
new Async.RootTask<Void, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
Shell.su("cp -af /system/etc/hosts /magisk/.core/hosts");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.exec();
|
||||||
|
} else {
|
||||||
|
new Async.RootTask<Void, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
Shell.su("umount -l /system/etc/hosts", "rm -f /magisk/.core/hosts");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.exec();
|
||||||
|
}
|
||||||
|
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
||||||
break;
|
break;
|
||||||
case "developer_logging":
|
case "developer_logging":
|
||||||
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false);
|
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false);
|
||||||
|
@ -32,7 +32,8 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
.putBoolean("repo_done", false)
|
.putBoolean("repo_done", false)
|
||||||
.putBoolean("update_check_done", false)
|
.putBoolean("update_check_done", false)
|
||||||
.putBoolean("magiskhide", Utils.itemExist(false, "/magisk/.core/magiskhide/enable"))
|
.putBoolean("magiskhide", Utils.itemExist(false, "/magisk/.core/magiskhide/enable"))
|
||||||
.putBoolean("busybox", Utils.commandExists("unzip"))
|
.putBoolean("busybox", Utils.commandExists("busybox"))
|
||||||
|
.putBoolean("hosts", Utils.itemExist(false, "/magisk/.core/hosts"))
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
new Async.CheckUpdates(prefs).exec();
|
new Async.CheckUpdates(prefs).exec();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.topjohnwu.magisk.adapters;
|
package com.topjohnwu.magisk.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
@ -350,28 +350,6 @@ public class Async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LinkBusyBox extends RootTask<Void, Void, Void> {
|
|
||||||
|
|
||||||
private boolean link;
|
|
||||||
|
|
||||||
public LinkBusyBox(boolean b) {
|
|
||||||
link = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Void doInBackground(Void... voids) {
|
|
||||||
if (link) {
|
|
||||||
Shell.su(
|
|
||||||
"rm -rf /magisk/.core/busybox",
|
|
||||||
"ln -s /data/busybox /magisk/.core/busybox"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Shell.su("rm -rf /magisk/.core/busybox");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MagiskHide extends RootTask<Object, Void, Void> {
|
public static class MagiskHide extends RootTask<Object, Void, Void> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Object... params) {
|
protected Void doInBackground(Object... params) {
|
||||||
|
@ -39,6 +39,9 @@ public class Shell {
|
|||||||
rootSTDOUT = new StreamGobbler(rootShell.getInputStream(), rootOutList, true);
|
rootSTDOUT = new StreamGobbler(rootShell.getInputStream(), rootOutList, true);
|
||||||
rootSTDOUT.start();
|
rootSTDOUT.start();
|
||||||
|
|
||||||
|
// Setup umask
|
||||||
|
su("umask 022");
|
||||||
|
|
||||||
List<String> ret = su("echo -BOC-", "id");
|
List<String> ret = su("echo -BOC-", "id");
|
||||||
|
|
||||||
if (ret == null) {
|
if (ret == null) {
|
||||||
|
@ -55,7 +55,8 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean createFile(String path) {
|
public static boolean createFile(String path) {
|
||||||
String command = "touch " + path + " 2>/dev/null; if [ -f " + path + " ]; then echo true; else echo false; fi";
|
String folder = path.substring(0, path.lastIndexOf('/'));
|
||||||
|
String command = "mkdir -p " + folder + " 2>/dev/null; touch " + path + " 2>/dev/null; if [ -f \"" + path + "\" ]; then echo true; else echo false; fi";
|
||||||
return Shell.rootAccess() && Boolean.parseBoolean(Shell.su(command).get(0));
|
return Shell.rootAccess() && Boolean.parseBoolean(Shell.su(command).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
android:scaleType="centerCrop"/>
|
android:scaleType="centerCrop"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/textLayout"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_alignBottom="@+id/app_icon"
|
android:layout_alignBottom="@+id/app_icon"
|
||||||
@ -63,7 +62,6 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/Linear"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
|
@ -19,7 +19,6 @@ android:orientation="vertical">
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:dividerHeight="@dimen/card_divider_space"
|
android:dividerHeight="@dimen/card_divider_space"
|
||||||
android:paddingBottom="60dip"
|
|
||||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
|
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
<android.support.design.widget.CoordinatorLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/llayout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="?attr/actionBarSize"
|
android:layout_marginTop="?attr/actionBarSize"
|
||||||
@ -24,7 +23,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:dividerHeight="@dimen/card_divider_space"
|
android:dividerHeight="@dimen/card_divider_space"
|
||||||
android:paddingBottom="60dip"
|
|
||||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
|
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<group
|
<group android:checkableBehavior="single">
|
||||||
android:id="@+id/main_items"
|
|
||||||
android:checkableBehavior="single">
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/magisk"
|
android:id="@+id/magisk"
|
||||||
@ -32,9 +30,7 @@
|
|||||||
android:title="@string/log"/>
|
android:title="@string/log"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group
|
<group android:checkableBehavior="none">
|
||||||
android:id="@+id/option_items"
|
|
||||||
android:checkableBehavior="none">
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/settings"
|
android:id="@+id/settings"
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
<string name="menuReload">erneut laden</string>
|
<string name="menuReload">erneut laden</string>
|
||||||
<string name="menuClearLog">Log jetzt löschen</string>
|
<string name="menuClearLog">Log jetzt löschen</string>
|
||||||
<string name="logs_cleared">Log erfolgreich gelöscht</string>
|
<string name="logs_cleared">Log erfolgreich gelöscht</string>
|
||||||
<string name="logs_clear_failed">Konnte Log nicht löschen:</string>
|
|
||||||
<string name="log_is_empty">Log ist leer</string>
|
<string name="log_is_empty">Log ist leer</string>
|
||||||
<string name="logs_save_failed">Konnte Log nicht auf SD Karte speichern:</string>
|
<string name="logs_save_failed">Konnte Log nicht auf SD Karte speichern:</string>
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
<string name="menuReload">Ricarica</string>
|
<string name="menuReload">Ricarica</string>
|
||||||
<string name="menuClearLog">Cancella log</string>
|
<string name="menuClearLog">Cancella log</string>
|
||||||
<string name="logs_cleared">Log creato con successo</string>
|
<string name="logs_cleared">Log creato con successo</string>
|
||||||
<string name="logs_clear_failed">Impossibile cancellare il registro:</string>
|
|
||||||
<string name="log_is_empty">Il log è vuoto</string>
|
<string name="log_is_empty">Il log è vuoto</string>
|
||||||
<string name="logs_save_failed">Impossibile scrivere il log sulla SD</string>
|
<string name="logs_save_failed">Impossibile scrivere il log sulla SD</string>
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
<string name="menuReload">Herladen</string>
|
<string name="menuReload">Herladen</string>
|
||||||
<string name="menuClearLog">Maak log leeg</string>
|
<string name="menuClearLog">Maak log leeg</string>
|
||||||
<string name="logs_cleared">Log succesvol geleegd</string>
|
<string name="logs_cleared">Log succesvol geleegd</string>
|
||||||
<string name="logs_clear_failed">Kon de log niet legen.</string>
|
|
||||||
<string name="log_is_empty">Log is leeg</string>
|
<string name="log_is_empty">Log is leeg</string>
|
||||||
<string name="logs_save_failed">Kon niet naar SD-kaart schrijven:</string>
|
<string name="logs_save_failed">Kon niet naar SD-kaart schrijven:</string>
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
<string name="menuReload">Recarregar</string>
|
<string name="menuReload">Recarregar</string>
|
||||||
<string name="menuClearLog">Limpar registro agora</string>
|
<string name="menuClearLog">Limpar registro agora</string>
|
||||||
<string name="logs_cleared">Registro limpado com sucesso</string>
|
<string name="logs_cleared">Registro limpado com sucesso</string>
|
||||||
<string name="logs_clear_failed">Não foi possível limpar o registro:</string>
|
|
||||||
<string name="log_is_empty">Registro está vazio</string>
|
<string name="log_is_empty">Registro está vazio</string>
|
||||||
<string name="logs_save_failed">Não foi possível gravar o registro para o cartão SD:</string>
|
<string name="logs_save_failed">Não foi possível gravar o registro para o cartão SD:</string>
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<!--Welcome Activity-->
|
<!--Welcome Activity-->
|
||||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||||
<string name="magiskhide">MagiskHide</string>
|
<string name="magiskhide">Magisk Hide</string>
|
||||||
<string name="modules">Modules</string>
|
<string name="modules">Modules</string>
|
||||||
<string name="downloads">Downloads</string>
|
<string name="downloads">Downloads</string>
|
||||||
<string name="log">Log</string>
|
<string name="log">Log</string>
|
||||||
@ -45,7 +45,6 @@
|
|||||||
<string name="menuReload">Reload</string>
|
<string name="menuReload">Reload</string>
|
||||||
<string name="menuClearLog">Clear log now</string>
|
<string name="menuClearLog">Clear log now</string>
|
||||||
<string name="logs_cleared">Log successfully cleared</string>
|
<string name="logs_cleared">Log successfully cleared</string>
|
||||||
<string name="logs_clear_failed">Could not clear the log:</string>
|
|
||||||
<string name="log_is_empty">Log is empty</string>
|
<string name="log_is_empty">Log is empty</string>
|
||||||
<string name="logs_save_failed">Could not write log to SD card:</string>
|
<string name="logs_save_failed">Could not write log to SD card:</string>
|
||||||
|
|
||||||
@ -87,27 +86,24 @@
|
|||||||
<string name="file_url">https://raw.githubusercontent.com/Magisk-Modules-Repo/%1$s/master/%2$s</string>
|
<string name="file_url">https://raw.githubusercontent.com/Magisk-Modules-Repo/%1$s/master/%2$s</string>
|
||||||
<string name="zip_url">https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip</string>
|
<string name="zip_url">https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip</string>
|
||||||
|
|
||||||
<!--Settings Fragment -->
|
<!--Settings Activity -->
|
||||||
<string name="settings_general_category">General</string>
|
<string name="settings_general_category">General</string>
|
||||||
<string name="settings_theme_title">Theme</string>
|
<string name="settings_theme_title">Theme</string>
|
||||||
<string name="settings_theme_summary">Select a theme</string>
|
<string name="settings_theme_summary">Select a theme</string>
|
||||||
|
|
||||||
|
<string name="settings_magiskhide_title">Enable Magisk Hide</string>
|
||||||
|
<string name="settings_magiskhide_summary">Hide Magisk from various detections</string>
|
||||||
<string name="settings_busybox_title">Enable BusyBox</string>
|
<string name="settings_busybox_title">Enable BusyBox</string>
|
||||||
<string name="settings_busybox_summary">Make Magisk\'s built-in BusyBox be visible in PATH</string>
|
<string name="settings_busybox_summary">Bind mount Magisk\'s built-in busybox to xbin</string>
|
||||||
|
<string name="settings_hosts_title">Enable systemless hosts</string>
|
||||||
|
<string name="settings_hosts_summary">Systemless support for Adblock apps</string>
|
||||||
|
|
||||||
<string name="settings_development_category">Development</string>
|
<string name="settings_development_category">Development</string>
|
||||||
<string name="settings_developer_logging_title">Enable advanced debug logging</string>
|
<string name="settings_developer_logging_title">Enable advanced debug logging</string>
|
||||||
<string name="settings_developer_logging_summary">Check this to enable more verbose logging.</string>
|
<string name="settings_developer_logging_summary">Check this to enable more verbose logging.</string>
|
||||||
<string name="settings_shell_logging_title">Enable shell command debug logging</string>
|
<string name="settings_shell_logging_title">Enable shell command debug logging</string>
|
||||||
<string name="settings_shell_logging_summary">Check this to enable logging all shell commands and output</string>
|
<string name="settings_shell_logging_summary">Check this to enable logging all shell commands and output</string>
|
||||||
<string name="settings_magiskhide_title">Enable Magisk Hide</string>
|
|
||||||
<string name="settings_magiskhide_summary">Reboot to apply settings</string>
|
|
||||||
|
|
||||||
<!-- Strings related to Settings -->
|
<string name="settings_reboot_toast">Reboot to apply settings</string>
|
||||||
|
|
||||||
<!-- Example General settings -->
|
|
||||||
|
|
||||||
<!-- Example settings for Data & Sync -->
|
|
||||||
|
|
||||||
<!-- Example settings for Notifications -->
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -29,6 +29,12 @@
|
|||||||
android:title="@string/settings_busybox_title"
|
android:title="@string/settings_busybox_title"
|
||||||
android:summary="@string/settings_busybox_summary" />
|
android:summary="@string/settings_busybox_summary" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="hosts"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:title="@string/settings_hosts_title"
|
||||||
|
android:summary="@string/settings_hosts_summary" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
Loading…
Reference in New Issue
Block a user