mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 21:45:27 +00:00
Handle MagiskHide at boot
This commit is contained in:
parent
0efb4da0ee
commit
99ef0b8cb4
@ -56,6 +56,7 @@ public class Global {
|
||||
public static boolean isDarkTheme;
|
||||
public static boolean shellLogging;
|
||||
public static boolean devLogging;
|
||||
public static boolean magiskHide;
|
||||
public static int suRequestTimeout;
|
||||
public static int suLogTimeout = 14;
|
||||
public static int suAccessState;
|
||||
@ -68,13 +69,14 @@ public class Global {
|
||||
Configs.isDarkTheme = prefs.getBoolean("dark_theme", false);
|
||||
Configs.devLogging = prefs.getBoolean("developer_logging", false);
|
||||
Configs.shellLogging = prefs.getBoolean("shell_logging", false);
|
||||
Configs.magiskHide = prefs.getBoolean("magiskhide", false);
|
||||
updateMagiskInfo();
|
||||
initSuAccess();
|
||||
initSuConfigs(context);
|
||||
// Initialize prefs
|
||||
prefs.edit()
|
||||
.putBoolean("dark_theme", Configs.isDarkTheme)
|
||||
.putBoolean("magiskhide", Utils.itemExist(false, "/magisk/.core/magiskhide/enable"))
|
||||
.putBoolean("magiskhide", Configs.magiskHide)
|
||||
.putBoolean("busybox", Utils.commandExists("busybox"))
|
||||
.putBoolean("hosts", Utils.itemExist(false, "/magisk/.core/hosts"))
|
||||
.putString("su_request_timeout", String.valueOf(Configs.suRequestTimeout))
|
||||
|
@ -95,10 +95,6 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
setSummary();
|
||||
|
||||
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
||||
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
|
||||
SwitchPreference hostsPreference = (SwitchPreference) findPreference("hosts");
|
||||
|
||||
findPreference("clear").setOnPreferenceClickListener((pref) -> {
|
||||
ModuleHelper.clearRepoCache(getActivity());
|
||||
return true;
|
||||
@ -108,16 +104,10 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
prefScreen.removePreference(magiskCategory);
|
||||
prefScreen.removePreference(suCategory);
|
||||
} else {
|
||||
if (!Global.Info.isSuClient) {
|
||||
if (!Global.Info.isSuClient)
|
||||
prefScreen.removePreference(suCategory);
|
||||
}
|
||||
if (Global.Info.magiskVersion < 9) {
|
||||
hostsPreference.setEnabled(false);
|
||||
busyboxPreference.setEnabled(false);
|
||||
}
|
||||
if (Global.Info.magiskVersion < 8) {
|
||||
magiskhidePreference.setEnabled(false);
|
||||
}
|
||||
if (Global.Info.magiskVersion < 11)
|
||||
prefScreen.removePreference(magiskCategory);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,20 +139,10 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
break;
|
||||
case "magiskhide":
|
||||
enabled = prefs.getBoolean("magiskhide", false);
|
||||
new Async.RootTask<Void, Void, Void>() {
|
||||
private boolean enable = enabled;
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if (enable) {
|
||||
Utils.createFile("/magisk/.core/magiskhide/enable");
|
||||
} else {
|
||||
Utils.removeItem("/magisk/.core/magiskhide/enable");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}.exec();
|
||||
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
|
||||
if (enabled)
|
||||
new Async.MagiskHide().enable();
|
||||
else
|
||||
new Async.MagiskHide().disable();
|
||||
break;
|
||||
case "busybox":
|
||||
enabled = prefs.getBoolean("busybox", false);
|
||||
@ -170,11 +150,10 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
private boolean enable = enabled;
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if (enable) {
|
||||
if (enable)
|
||||
Utils.createFile("/magisk/.core/busybox/enable");
|
||||
} else {
|
||||
else
|
||||
Utils.removeItem("/magisk/.core/busybox/enable");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}.exec();
|
||||
|
@ -76,8 +76,11 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
||||
if (SNLIST.contains(info.packageName)) {
|
||||
holder.checkBox.setChecked(true);
|
||||
holder.checkBox.setEnabled(false);
|
||||
holder.itemView.setOnClickListener(v ->
|
||||
Snackbar.make(holder.itemView, R.string.safetyNet_hide_notice, Snackbar.LENGTH_LONG).show());
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
Snackbar snackbar = Snackbar.make(holder.itemView, R.string.safetyNet_hide_notice, Snackbar.LENGTH_LONG);
|
||||
((TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_text)).setMaxLines(2);
|
||||
snackbar.show();
|
||||
});
|
||||
} else {
|
||||
holder.checkBox.setEnabled(true);
|
||||
holder.checkBox.setChecked(mHideList.contains(info.packageName));
|
||||
|
@ -3,12 +3,22 @@ package com.topjohnwu.magisk.receivers;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
Global.initSuAccess();
|
||||
if (prefs.getBoolean("magiskhide", false)) {
|
||||
Toast.makeText(context, R.string.start_magiskhide, Toast.LENGTH_SHORT).show();
|
||||
new Async.MagiskHide().enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,13 @@ public class RequestActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Global.initSuConfigs(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
Global.initSuConfigs(this);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setClass(this, SuRequestActivity.class);
|
||||
startActivity(intent);
|
||||
|
@ -293,18 +293,25 @@ public class Async {
|
||||
public static class MagiskHide extends RootTask<Object, Void, Void> {
|
||||
@Override
|
||||
protected Void doInBackground(Object... params) {
|
||||
boolean add = (boolean) params[0];
|
||||
String packageName = (String) params[1];
|
||||
Shell.su(MAGISK_HIDE_PATH + (add ? "add " : "rm ") + packageName);
|
||||
String command = (String) params[0];
|
||||
Shell.su(MAGISK_HIDE_PATH + command);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void add(CharSequence packageName) {
|
||||
exec(true, packageName);
|
||||
exec("add " + packageName);
|
||||
}
|
||||
|
||||
public void rm(CharSequence packageName) {
|
||||
exec(false, packageName);
|
||||
exec("rm " + packageName);
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
exec("enable");
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
exec("disable");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
|
||||
</vector>
|
@ -39,7 +39,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">حفظ إلى بطاقة ذاكرة SD</string>
|
||||
<string name="menuSend">إرسال</string>
|
||||
<string name="menuReload">إعادة تحميل</string>
|
||||
<string name="menuClearLog">حذف السجل الآن</string>
|
||||
<string name="logs_cleared">تم حذف السجل بنجاح</string>
|
||||
@ -86,7 +85,6 @@
|
||||
<string name="settings_dark_theme_title">السمة</string>
|
||||
<string name="settings_dark_theme_summary">أختر سمة</string>
|
||||
|
||||
<string name="settings_magiskhide_title">تمكين إخفاء Magisk</string>
|
||||
<string name="settings_magiskhide_summary">إخفاء Magisk من مختلف حالات الإكتشاف</string>
|
||||
<string name="settings_busybox_title">تمكين BusyBox</string>
|
||||
<string name="settings_busybox_summary">ربط تحميل Magisk\'s المدمج في busybox إلى xbin</string>
|
||||
|
@ -65,7 +65,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">Auf SD-Karte speichern</string>
|
||||
<string name="menuSend">Senden</string>
|
||||
<string name="menuReload">Erneut laden</string>
|
||||
<string name="menuClearLog">Log löschen</string>
|
||||
<string name="logs_cleared">Log erfolgreich gelöscht</string>
|
||||
@ -126,7 +125,6 @@
|
||||
<string name="settings_clear_cache_title">Repo-Cache löschen</string>
|
||||
<string name="settings_clear_cache_summary">Löscht die zwischengespeicherten Informtionen der Online-Repos. Erzwingt eine Aktualisierung</string>
|
||||
|
||||
<string name="settings_magiskhide_title">Magisk Hide aktivieren</string>
|
||||
<string name="settings_magiskhide_summary">Versteckt Magisk vor diversen Entdeckungsmethoden\nErfordert einen Neustart</string>
|
||||
<string name="settings_busybox_title">BusyBox aktivieren</string>
|
||||
<string name="settings_busybox_summary">Magisk\'s integriertes BusyBox nach xbin mounten\nErfordert einen Neustart</string>
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">Salvar a SD</string>
|
||||
<string name="menuSend">Enviar</string>
|
||||
<string name="menuReload">Recargar</string>
|
||||
<string name="menuClearLog">Vaciar Log ahora</string>
|
||||
<string name="logs_cleared">Log vaciado correctamente</string>
|
||||
@ -83,7 +82,6 @@
|
||||
<string name="settings_dark_theme_title">Tema</string>
|
||||
<string name="settings_dark_theme_summary">Selecciona un tema</string>
|
||||
|
||||
<string name="settings_magiskhide_title">Habilitar Magisk Hide</string>
|
||||
<string name="settings_magiskhide_summary">Ocultar Magisk de varias detecciones</string>
|
||||
<string name="settings_busybox_title">Habilitar BusyBox</string>
|
||||
<string name="settings_busybox_summary">Montar el busybox interno de Magisk en xbin</string>
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">Salva nella SD</string>
|
||||
<string name="menuSend">Invia</string>
|
||||
<string name="menuReload">Ricarica</string>
|
||||
<string name="menuClearLog">Cancella log</string>
|
||||
<string name="logs_cleared">Log creato con successo</string>
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">Opslaan op SD-kaart</string>
|
||||
<string name="menuSend">Verzenden</string>
|
||||
<string name="menuReload">Herladen</string>
|
||||
<string name="menuClearLog">Maak log leeg</string>
|
||||
<string name="logs_cleared">Log succesvol geleegd</string>
|
||||
@ -89,7 +88,6 @@
|
||||
<string name="settings_developer_logging_summary">Schakel dit in voor uitgebreidere logging.</string>
|
||||
<string name="settings_shell_logging_title">Shell command debug loggin</string>
|
||||
<string name="settings_shell_logging_summary">Schakel dit in om alle shell commands en output te loggen</string>
|
||||
<string name="settings_magiskhide_title">Magisk verbergen</string>
|
||||
<string name="settings_magiskhide_summary">Reboot om de instellingen toe te passen</string>
|
||||
|
||||
<!-- Strings related to Settings -->
|
||||
|
@ -65,7 +65,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">Zapisz na SD</string>
|
||||
<string name="menuSend">Wyślij</string>
|
||||
<string name="menuReload">Załaduj ponownie</string>
|
||||
<string name="menuClearLog">Wyczyść Log</string>
|
||||
<string name="logs_cleared">Log wyczyszczony</string>
|
||||
@ -126,7 +125,6 @@
|
||||
<string name="settings_clear_cache_title">Wyczyść Cache Repozytorium</string>
|
||||
<string name="settings_clear_cache_summary">Wyczyść cache dla repozytorium, wymusza odświeżenie online przez aplikację</string>
|
||||
|
||||
<string name="settings_magiskhide_title">Włącz Magisk Hide</string>
|
||||
<string name="settings_magiskhide_summary">Włącz Hide Magisk dla wykrytych aplikacji</string>
|
||||
<string name="settings_busybox_title">Włącz BusyBox</string>
|
||||
<string name="settings_busybox_summary">Bind mount Magisk\'s built-in busybox to xbin</string>
|
||||
|
@ -59,7 +59,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">Salvar no SD</string>
|
||||
<string name="menuSend">Enviar</string>
|
||||
<string name="menuReload">Recarregar</string>
|
||||
<string name="menuClearLog">Limpar registro agora</string>
|
||||
<string name="logs_cleared">Registro limpado com sucesso</string>
|
||||
@ -110,7 +109,6 @@
|
||||
<string name="settings_dark_theme_title">Tema</string>
|
||||
<string name="settings_dark_theme_summary">Escolha um tema</string>
|
||||
|
||||
<string name="settings_magiskhide_title">Ativar Magisk Hide</string>
|
||||
<string name="settings_magiskhide_summary">Ocultar Magisk de várias detecções</string>
|
||||
<string name="settings_busybox_title">Ativar BusyBox</string>
|
||||
<string name="settings_busybox_summary">Monta a busybox interna do Magisk\'s para xbin</string>
|
||||
|
@ -57,7 +57,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">保存到 SD 卡</string>
|
||||
<string name="menuSend">发送</string>
|
||||
<string name="menuReload">重载</string>
|
||||
<string name="menuClearLog">清除日志</string>
|
||||
<string name="logs_cleared">日志已成功清除</string>
|
||||
@ -107,7 +106,6 @@
|
||||
<string name="settings_dark_theme_title">主题</string>
|
||||
<string name="settings_dark_theme_summary">选择一个主题</string>
|
||||
|
||||
<string name="settings_magiskhide_title">启用 Magisk 隐藏</string>
|
||||
<string name="settings_magiskhide_summary">隐藏 Magisk 使其不被多种方法检测到</string>
|
||||
<string name="settings_busybox_title">启用 BusyBox</string>
|
||||
<string name="settings_busybox_summary">将 Magisk 内置的 Busybox 挂载到 xbin</string>
|
||||
|
@ -65,7 +65,6 @@
|
||||
|
||||
<!--Log Fragment-->
|
||||
<string name="menuSaveToSd">Save to SD</string>
|
||||
<string name="menuSend">Send</string>
|
||||
<string name="menuReload">Reload</string>
|
||||
<string name="menuClearLog">Clear log now</string>
|
||||
<string name="logs_cleared">Log successfully cleared</string>
|
||||
@ -114,6 +113,7 @@
|
||||
<string name="check_release_notes">Check release notes</string>
|
||||
<string name="repo_cache_cleared">Repo cache cleared</string>
|
||||
<string name="safetyNet_hide_notice">This app uses SafetyNet\nAlready handled by MagiskHide by default</string>
|
||||
<string name="start_magiskhide">Starting MagiskHide …</string>
|
||||
|
||||
<!--URL Templates-->
|
||||
<string name="url_main" translatable="false">https://api.github.com/orgs/Magisk-Modules-Repo/repos</string>
|
||||
@ -127,8 +127,7 @@
|
||||
<string name="settings_clear_cache_title">Clear Repo Cache</string>
|
||||
<string name="settings_clear_cache_summary">Clear the cached information for online repos, forces the app to refresh online</string>
|
||||
|
||||
<string name="settings_magiskhide_title">Enable Magisk Hide</string>
|
||||
<string name="settings_magiskhide_summary">Hide Magisk from various detections\nRequires reboot</string>
|
||||
<string name="settings_magiskhide_summary">Hide Magisk from various detections</string>
|
||||
<string name="settings_busybox_title">Enable BusyBox</string>
|
||||
<string name="settings_busybox_summary">Bind mount Magisk\'s built-in busybox to xbin\nRequires reboot</string>
|
||||
<string name="settings_hosts_title">Systemless hosts</string>
|
||||
|
@ -21,18 +21,18 @@
|
||||
android:key="magisk"
|
||||
android:title="@string/magisk">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="magiskhide"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/settings_magiskhide_title"
|
||||
android:summary="@string/settings_magiskhide_summary" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="busybox"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/settings_busybox_title"
|
||||
android:summary="@string/settings_busybox_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="magiskhide"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/magiskhide"
|
||||
android:summary="@string/settings_magiskhide_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="hosts"
|
||||
android:defaultValue="false"
|
||||
|
Loading…
Reference in New Issue
Block a user