Repackage Magisk Manager for hiding

This commit is contained in:
topjohnwu 2017-10-21 22:54:47 +08:00
parent 5880d4a6ec
commit f5cc2af5d0
39 changed files with 127 additions and 215 deletions

View File

@ -53,7 +53,6 @@ repositories {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':common')
implementation project(':jarsigner')
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'

View File

@ -9,6 +9,7 @@ import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
@ -44,6 +45,7 @@ public class MagiskManager extends Application {
// Global weak reference to self
private static WeakReference<MagiskManager> weakSelf;
public static final String ORIG_PKG_NAME = "com.topjohnwu.magisk";
public static final String MAGISK_DISABLE_FILE = "/cache/.disable_magisk";
public static final String MAGISK_HOST_FILE = "/magisk/.core/hosts";
public static final String TMP_FOLDER_PATH = "/dev/tmp";
@ -68,6 +70,7 @@ public class MagiskManager extends Application {
public final Topic localeDone = new Topic();
// Info
public int userId;
public String magiskVersionString;
public int magiskVersionCode = -1;
public String remoteMagiskVersionString;
@ -125,6 +128,7 @@ public class MagiskManager extends Application {
public void onCreate() {
super.onCreate();
prefs = PreferenceManager.getDefaultSharedPreferences(this);
userId = getApplicationInfo().uid / 100000;
if (Utils.getDatabasePath(this, SuDatabaseHelper.DB_NAME).exists()) {
// Don't migrate yet, wait and check Magisk version
@ -133,6 +137,15 @@ public class MagiskManager extends Application {
suDB = new SuDatabaseHelper();
}
// If detect original package, self destruct!
if (!getPackageName().equals(ORIG_PKG_NAME)) {
try {
getPackageManager().getApplicationInfo(ORIG_PKG_NAME, 0);
Shell.su(String.format(Locale.US, "pm uninstall --user %d %s", userId, getPackageName()));
return;
} catch (PackageManager.NameNotFoundException ignored) { /* Expected*/ }
}
repoDB = new RepoDatabaseHelper(this);
defaultLocale = Locale.getDefault();
setLocale();
@ -258,6 +271,14 @@ public class MagiskManager extends Application {
// Setup suDB
SuDatabaseHelper.setupSuDB();
// Check alternative Magisk Manager
String pkg;
if (getPackageName().equals(ORIG_PKG_NAME) &&
(pkg = suDB.getStrings(SuDatabaseHelper.REQUESTER, null)) != null) {
Shell.su_raw("pm uninstall " + pkg);
suDB.setStrings(SuDatabaseHelper.REQUESTER, null);
}
// Add update checking service
if (UPDATE_SERVICE_VER > updateServiceVersion) {
ComponentName service = new ComponentName(this, UpdateCheckService.class);

View File

@ -108,7 +108,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
setSummary();
// Disable dangerous settings in user mode if selected owner manage
if (getActivity().getApplicationInfo().uid > 99999) {
if (mm.userId > 0) {
suCategory.removePreference(multiuserMode);
generalCatagory.removePreference(hideManager);
}
@ -125,12 +125,16 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
return true;
});
if (mm.getPackageName().equals(MagiskManager.ORIG_PKG_NAME)) {
hideManager.setOnPreferenceClickListener((pref) -> {
Utils.runWithPermission(getActivity(),
Manifest.permission.WRITE_EXTERNAL_STORAGE,
() -> new HideManager().exec());
return true;
});
} else {
generalCatagory.removePreference(hideManager);
}
if (!Shell.rootAccess()) {
prefScreen.removePreference(magiskCategory);

View File

@ -1,27 +1,26 @@
package com.topjohnwu.magisk.asyncs;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.widget.Toast;
import com.topjohnwu.jarsigner.JarMap;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.container.Policy;
import com.topjohnwu.magisk.database.SuDatabaseHelper;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils;
import com.topjohnwu.magisk.utils.ZipUtils;
import java.io.File;
import java.io.FileInputStream;
import java.security.SecureRandom;
import java.util.List;
import java.util.Locale;
import java.util.jar.JarEntry;
public class HideManager extends ParallelTask<Void, Void, Boolean> {
private static final String UNHIDE_APK = "unhide.apk";
private static final String ANDROID_MANIFEST = "AndroidManifest.xml";
private static final byte[] UNHIDE_PKG_NAME = "com.topjohnwu.unhide\0".getBytes();
private String genPackageName(String prefix, int length) {
StringBuilder builder = new StringBuilder(length);
@ -44,31 +43,13 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
return builder.toString();
}
@Override
protected void onPreExecute() {
MagiskManager.toast(R.string.hide_manager_toast, Toast.LENGTH_SHORT);
}
@Override
protected Boolean doInBackground(Void... voids) {
MagiskManager mm = MagiskManager.get();
// Generate a new unhide app with random package name
File unhideAPK = new File(Environment.getExternalStorageDirectory() + "/MagiskManager", "unhide.apk");
unhideAPK.getParentFile().mkdirs();
String pkg;
try {
JarMap asset = new JarMap(mm.getAssets().open(UNHIDE_APK));
JarEntry je = new JarEntry(ANDROID_MANIFEST);
byte xml[] = asset.getRawData(je);
private boolean findAndPatch(byte xml[], String from, String to) {
int offset = -1;
// Linear search pattern offset
for (int i = 0; i < xml.length - UNHIDE_PKG_NAME.length; ++i) {
byte target[] = (from + '\0').getBytes();
for (int i = 0; i < xml.length - target.length; ++i) {
boolean match = true;
for (int j = 0; j < UNHIDE_PKG_NAME.length; ++j) {
if (xml[i + j] != UNHIDE_PKG_NAME[j]) {
for (int j = 0; j < target.length; ++j) {
if (xml[i + j] != target[j]) {
match = false;
break;
}
@ -81,40 +62,58 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
if (offset < 0)
return false;
// Patch binary XML with new package name
pkg = genPackageName("com.", UNHIDE_PKG_NAME.length - 1);
System.arraycopy(pkg.getBytes(), 0, xml, offset, pkg.length());
asset.getOutputStream(je).write(xml);
System.arraycopy(to.getBytes(), 0, xml, offset, to.length());
return true;
}
@Override
protected void onPreExecute() {
MagiskManager.toast(R.string.hide_manager_toast, Toast.LENGTH_SHORT);
MagiskManager.toast(R.string.hide_manager_toast2, Toast.LENGTH_LONG);
}
@Override
protected Boolean doInBackground(Void... voids) {
MagiskManager mm = MagiskManager.get();
// Generate a new unhide app with random package name
File repack = new File(Environment.getExternalStorageDirectory() + "/MagiskManager", "repack.apk");
repack.getParentFile().mkdirs();
String pkg = genPackageName("com.", MagiskManager.ORIG_PKG_NAME.length());
try {
// Read whole APK into memory
JarMap apk = new JarMap(new FileInputStream(mm.getPackageCodePath()));
JarEntry je = new JarEntry(ANDROID_MANIFEST);
byte xml[] = apk.getRawData(je);
if (!findAndPatch(xml, MagiskManager.ORIG_PKG_NAME, pkg))
return false;
if (!findAndPatch(xml, MagiskManager.ORIG_PKG_NAME + ".provider", pkg + ".provider"))
return false;
// Write in changes
apk.getOutputStream(je).write(xml);
// Sign the APK
ZipUtils.signZip(mm, asset, unhideAPK, false);
ZipUtils.signZip(apk, repack, false);
} catch (Exception e) {
e.printStackTrace();
return false;
}
// Install the application
List<String> ret = Shell.su("pm install " + unhideAPK + ">/dev/null && echo true || echo false");
unhideAPK.delete();
List<String> ret = Shell.su(String.format(Locale.US,
"pm install --user %d %s >/dev/null && echo true || echo false",
mm.userId, repack));
repack.delete();
if (!Utils.isValidShellResponse(ret) || !Boolean.parseBoolean(ret.get(0)))
return false;
try {
// Allow the application to gain root by default
PackageManager pm = mm.getPackageManager();
int uid = pm.getApplicationInfo(pkg, 0).uid;
Policy policy = new Policy(uid, pm);
policy.policy = Policy.ALLOW;
policy.notification = false;
policy.logging = false;
mm.suDB.addPolicy(policy);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return false;
}
mm.suDB.setStrings(SuDatabaseHelper.REQUESTER, pkg);
Shell.su_raw(String.format(Locale.US, "pm uninstall --user %d %s", mm.userId, mm.getPackageName()));
// Hide myself!
Shell.su_raw("pm hide " + mm.getPackageName());
return true;
}

View File

@ -132,13 +132,13 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
publishProgress(SHOW_PROCESSING);
// Then sign the zip for the first time, temp1 -> temp2
ZipUtils.signZip(activity, temp1, temp2, false);
ZipUtils.signZip(temp1, temp2, false);
// Adjust the zip to prevent unzip issues, temp2 -> temp1
ZipUtils.zipAdjust(temp2.getPath(), temp1.getPath());
// Finally, sign the whole zip file again, temp1 -> temp2
ZipUtils.signZip(activity, temp1, temp2, true);
ZipUtils.signZip(temp1, temp2, true);
// Write it to the target zip, temp2 -> file
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(mFile));

View File

@ -41,11 +41,14 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
public static final int NAMESPACE_MODE_REQUESTER = 1;
public static final int NAMESPACE_MODE_ISOLATE = 2;
public static final String REQUESTER = "requester";
public static final String DB_NAME = "su.db";
private static final int DATABASE_VER = 3;
private static final int DATABASE_VER = 4;
private static final String POLICY_TABLE = "policies";
private static final String LOG_TABLE = "logs";
private static final String SETTINGS_TABLE = "settings";
private static final String STRINGS_TABLE = "strings";
private static String GLOBAL_DB;
@ -130,7 +133,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion == 0) {
createTables(db);
oldVersion = 2;
oldVersion = 3;
}
if (oldVersion == 1) {
// We're dropping column app_name, rename and re-construct table
@ -157,6 +160,12 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("UPDATE " + LOG_TABLE + " SET time=time*1000");
++oldVersion;
}
if (oldVersion == 3) {
db.execSQL(
"CREATE TABLE IF NOT EXISTS " + STRINGS_TABLE + " " +
"(key TEXT, value TEXT, PRIMARY KEY(key))");
++oldVersion;
}
if (!Utils.itemExist(GLOBAL_DB)) {
// Hard link our DB globally
@ -335,4 +344,25 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
}
return value;
}
public void setStrings(String key, String value) {
if (value == null) {
mDb.delete(STRINGS_TABLE, "key=?", new String[] { key });
} else {
ContentValues data = new ContentValues();
data.put("key", key);
data.put("value", value);
mDb.replace(STRINGS_TABLE, null, data);
}
}
public String getStrings(String key, String defaultValue) {
String value = defaultValue;
try (Cursor c = mDb.query(STRINGS_TABLE, null, "key=?",new String[] { key }, null, null, null)) {
if (c.moveToNext()) {
value = c.getString(c.getColumnIndex("value"));
}
}
return value;
}
}

View File

@ -24,7 +24,7 @@ public class ManagerUpdate extends BroadcastReceiver {
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri content = FileProvider.getUriForFile(context,
"com.topjohnwu.magisk.provider", new File(uri.getPath()));
context.getPackageName() + ".provider", new File(uri.getPath()));
install.setData(content);
context.startActivity(install);
} else {

View File

@ -1,10 +1,10 @@
package com.topjohnwu.magisk.utils;
import android.content.Context;
import android.content.res.AssetManager;
import com.topjohnwu.jarsigner.JarMap;
import com.topjohnwu.jarsigner.SignAPK;
import com.topjohnwu.magisk.MagiskManager;
import java.io.BufferedInputStream;
import java.io.File;
@ -63,16 +63,16 @@ public class ZipUtils {
}
}
public static void signZip(Context context, InputStream is, File output, boolean minSign) throws Exception {
signZip(context, new JarMap(is, false), output, minSign);
public static void signZip(InputStream is, File output, boolean minSign) throws Exception {
signZip(new JarMap(is, false), output, minSign);
}
public static void signZip(Context context, File input, File output, boolean minSign) throws Exception {
signZip(context, new JarMap(input, false), output, minSign);
public static void signZip(File input, File output, boolean minSign) throws Exception {
signZip(new JarMap(input, false), output, minSign);
}
public static void signZip(Context context, JarMap input, File output, boolean minSign) throws Exception {
AssetManager assets = context.getAssets();
public static void signZip(JarMap input, File output, boolean minSign) throws Exception {
AssetManager assets = MagiskManager.get().getAssets();
SignAPK.signZip(
assets.open(PUBLIC_KEY_NAME), assets.open(PRIVATE_KEY_NAME),
input, output, minSign);

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -122,7 +122,6 @@
<string name="settings_clear_cache_title">Repo-Cache löschen</string>
<string name="settings_clear_cache_summary">Löscht die zwischengespeicherten Informationen der Online-Repos. Erzwingt eine Aktualisierung</string>
<string name="settings_hide_manager_title">Magisk Manager verbergen</string>
<string name="settings_hide_manager_summary">Magisk Manager temporär verbergen.\nDies installiert eine neue App namens \"Unhide Magisk Manager\"</string>
<string name="language">Sprache</string>
<string name="system_default">(Systemstandard)</string>
<string name="settings_update">Update-Einstellungen</string>

View File

@ -115,7 +115,6 @@
<string name="settings_clear_cache_title">Εκκαθάριση προσωρινής μνήμης αποθετηρίων</string>
<string name="settings_clear_cache_summary">Καθαρίζει τις κρυφές πληροφορίες για απευθείας συνδεδεμένα αποθετήρια, αναγκάζει την εφαρμογή να κάνει ανανέωση σε απευθείας σύνδεση</string>
<string name="settings_hide_manager_title">Κρύψιμο Magisk Manager</string>
<string name="settings_hide_manager_summary">Προσωρινό κρύψιμο του Magisk Manager.\nΑυτό θα εγκαταστήσει μια νέα εφαρμογή με το όνομα \"Unhide Magisk Manager\"</string>
<string name="language">Γλώσσα</string>
<string name="system_default">(Προεπιλογή Συστήματος)</string>
<string name="settings_update">Ρυθμίσεις Ενημερώσεων</string>

View File

@ -132,7 +132,6 @@
<string name="settings_clear_cache_title">Limpiar caché del repositorio</string>
<string name="settings_clear_cache_summary">Limpiar la información en caché para los repositorios en línea, fuerza a la aplicación a actualizar en línea</string>
<string name="settings_hide_manager_title">Ocultar Magisk Manager</string>
<string name="settings_hide_manager_summary">Ocultar temporalmente Magisk Manager.\nEsto instalará una nueva aplicación llamada \"Unhide Magisk Manager\"</string>
<string name="language">Idioma</string>
<string name="system_default">(Idioma del sistema)</string>
<string name="settings_update">Ajustes de Actualización</string>

View File

@ -135,8 +135,6 @@
<string name="settings_clear_cache_title">Tühjenda hoidla vahemälu</string>
<string name="settings_clear_cache_summary">Tühjenda võrgus olevate hoidlate vahemälus olev teave, sunnib rakendust võrgust värskendama</string>
<string name="settings_hide_manager_title">Peida Magisk Manager</string>
<string name="settings_hide_manager_summary">Peida ajutiselt Magisk Manager.\n
See installib uue rakenduse nimega \"Unhide Magisk Manager"</string>
<string name="language">Keel</string>
<string name="system_default">(Süsteemi vaikesäte)</string>
<string name="settings_update">Uuenda seadeid</string>

View File

@ -133,7 +133,6 @@
<string name="superuser_notification">Notification Superuser</string>
<string name="request_timeout_summary">%1$s secondes</string>
<string name="settings_hide_manager_title">Masquer Magisk Manager</string>
<string name="settings_hide_manager_summary">Masquer temporairement Magisk Manager.\nCeci installera une nouvelle appli appelée \"Unhide Magisk Manager\"</string>
<string name="language">Langue</string>
<string name="system_default">(Selon système)</string>
<string name="settings_update">Paramètres de mises à jour</string>

View File

@ -128,7 +128,6 @@
<string name="settings_clear_cache_title">Opslagcache wissen</string>
<string name="settings_clear_cache_summary">Wis de gecachte informatie voor online opslagplaatsen. Dit dwingt de app om online te verversen</string>
<string name="settings_hide_manager_title">Magisk Manager verbergen</string>
<string name="settings_hide_manager_summary">Magisk Manager tijdelijk verbergen.\nDit installeert een nieuwe app genaamd \"Unhide Magisk Manager\"</string>
<string name="language">Taal</string>
<string name="system_default">(Systeem standaard)</string>
<string name="settings_update">Instellingen bijwerken</string>

View File

@ -131,7 +131,6 @@
<string name="settings_clear_cache_title">Wyczyść Pamięć Repozytorium</string>
<string name="settings_clear_cache_summary">Wymusza na aplikacji odświeżenie online repozytorium</string>
<string name="settings_hide_manager_title">Ukryj Magisk Manager</string>
<string name="settings_hide_manager_summary">Tymczasowo ukryj Magisk Manager.\nSpowoduje to zainstalowanie nowej aplikacji o nazwie \"Pokaż Magisk Manager\"</string>
<string name="language">Język</string>
<string name="system_default">(Domyślny Systemu)</string>
<string name="settings_update">Aktualizacja Ustawień</string>

View File

@ -134,7 +134,6 @@
<string name="settings_clear_cache_title">Limpar Repo Cache</string>
<string name="settings_clear_cache_summary">Limpe as informações armazenadas em cache para repos. online, forçando o aplicativo a atualizar online</string>
<string name="settings_hide_manager_title">Ocultar Magisk Manager</string>
<string name="settings_hide_manager_summary">Oculta temporariamente o Magisk Manager.\nIsso irá instalar um novo aplicativo chamado \"Unhide Magisk Manager\"</string>
<string name="language">Linguagem</string>
<string name="system_default">(Padrão do Sistema)</string>
<string name="settings_update">Atualizar Configurações</string>

View File

@ -108,7 +108,6 @@
<string name="settings_clear_cache_title">Eliminare cache</string>
<string name="settings_clear_cache_summary">Ștergeți informațiile memorate în cache, forțează actualizarea aplicației online</string>
<string name="settings_hide_manager_title">Ascundeţi Magisk Manager</string>
<string name="settings_hide_manager_summary">Ascundeţi temporar Magisk Manager.\nAceasta va instala o nouă aplicație numită \"Unhide Magisk Manager\"</string>
<string name="language">Limbă</string>
<string name="system_default">(Implicit)</string>

View File

@ -131,7 +131,6 @@
<string name="settings_clear_cache_title">Очистка кеша</string>
<string name="settings_clear_cache_summary">Очистить сохранённую информацию о сетевых репозиториях, заставляя приложение принудительно обновляться через Интернете</string>
<string name="settings_hide_manager_title">Скрыть Менеджер Magisk</string>
<string name="settings_hide_manager_summary">Временно скрывает Менеджер Magisk.\nБудет установлено новое приложение, называется \"Unhide Magisk Manager\"</string>
<string name="language">Язык</string>
<string name="system_default">По умолчанию (системный)</string>
<string name="settings_update">Настройки обновления</string>

View File

@ -125,7 +125,6 @@
<string name="settings_clear_cache_title">Repo Önbelleğini Temizle</string>
<string name="settings_clear_cache_summary">Çevrimiçi repolar için önbellek bilgilerini temizle, uygulamayı çevrimiçi yenilemeye zorla</string>
<string name="settings_hide_manager_title">Magisk Manager\'ı Gizle</string>
<string name="settings_hide_manager_summary">Magisk Manager\'ı geçici olarak gizle.\nBu, \"Unhide Magisk Manager\" adlı yeni bir uygulama yükleyecektir.</string>
<string name="language">Dil</string>
<string name="system_default">(Sistem Varsayılanı)</string>
<string name="settings_update">Güncelleme Ayarları</string>

View File

@ -127,7 +127,6 @@
<string name="settings_clear_cache_title">Очищення кешу</string>
<string name="settings_clear_cache_summary">Очистити збережену інформацію про мережеві репозиторії, змушуючи програму примусово оновлюватися через Інтернет</string>
<string name="settings_hide_manager_title">Приховати Magisk Manager</string>
<string name="settings_hide_manager_summary">Тимчасово приховати Magisk Manager.\nЦя дія встановить новий додаток \"Unhide Magisk Manager\"</string>
<string name="language">Мова</string>
<string name="system_default">Стандартна (системна)</string>
<string name="settings_update">Оновити налаштування</string>

View File

@ -130,7 +130,6 @@
<string name="settings_clear_cache_title">清除仓库缓存</string>
<string name="settings_clear_cache_summary">清除已缓存的在线仓库信息,强制刷新在线数据</string>
<string name="settings_hide_manager_title">隐藏 Magisk Manager</string>
<string name="settings_hide_manager_summary">暂时隐藏 Magisk Manager。\n这将会安装一个应用“Unhide Magisk Manager”用以恢复显示。</string>
<string name="language">语言</string>
<string name="system_default">(系统默认)</string>
<string name="settings_update">更新设定</string>

View File

@ -186,7 +186,6 @@
<string name="hide_manager_toast">正在隱藏 Magisk Manager…</string>
<string name="hide_manager_fail_toast">隱藏 Magisk Manager 失敗</string>
<string name="settings_hide_manager_title">隱藏 Magisk Manager</string>
<string name="settings_hide_manager_summary">暫時隱藏 Magisk Manager。\n這會新增一個新的 app 叫做 Unhide Magisk Manager</string>
<string name="settings_update_channel_title">更新頻道</string>
<string name="settings_update_stable">穩定版</string>
<string name="settings_update_beta">測試版</string>

View File

@ -109,6 +109,7 @@
<string name="magisk_updates">Magisk Updates</string>
<string name="flashing">Flashing</string>
<string name="hide_manager_toast">Hiding Magisk Manager…</string>
<string name="hide_manager_toast2">This might take a while…</string>
<string name="hide_manager_fail_toast">Hide Magisk Manager failed…</string>
<string name="download_zip_only">Download Zip Only</string>
<string name="patch_boot_file">Patch Boot Image File</string>
@ -134,7 +135,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_hide_manager_title">Hide Magisk Manager</string>
<string name="settings_hide_manager_summary">Temporarily hide Magisk Manager.\nThis will install a new app called \"Unhide Magisk Manager\"</string>
<string name="settings_hide_manager_summary">Repackage Magisk Manager with random package name</string>
<string name="language">Language</string>
<string name="system_default">(System Default)</string>
<string name="settings_update">Update Settings</string>
@ -143,7 +144,6 @@
<string name="settings_update_beta">Beta</string>
<string name="settings_boot_format_title">Patched Boot Output Format</string>
<string name="settings_boot_format_summary">Select the format of the output patched boot image.\nChoose .img to flash through fastboot/download mode; choose .img.tar to flash with ODIN.</string>
<string name="settings_core_only_title">Magisk Core Only Mode</string>
<string name="settings_core_only_summary">Enable only core features, all modules will not be loaded. MagiskSU, MagiskHide, and systemless hosts will still be enabled</string>
<string name="settings_magiskhide_summary">Hide Magisk from various detections</string>

1
common/.gitignore vendored
View File

@ -1 +0,0 @@
/build

View File

@ -1,23 +0,0 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@ -1 +0,0 @@
<manifest package="com.topjohnwu.resource" />

View File

@ -3,8 +3,8 @@ apply plugin: 'java-library'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
jar {
manifest {

View File

@ -1 +1 @@
include ':app', ':unhide', ':common', ':snet', ':jarsigner'
include ':app', ':snet', ':jarsigner'

View File

@ -5,7 +5,7 @@ android {
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.topjohnwu.sn"
applicationId "com.topjohnwu.snet"
minSdkVersion 21
targetSdkVersion 26
versionCode 1

1
unhide/.gitignore vendored
View File

@ -1 +0,0 @@
/build

View File

@ -1,25 +0,0 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.topjohnwu.unhide"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':common')
}

View File

@ -1,25 +0,0 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/topjohnwu/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.topjohnwu.unhide">
<application
android:icon="@mipmap/ic_launcher"
android:label="Unhide Magisk Manager"
android:theme="@android:style/Theme.NoDisplay">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -1,33 +0,0 @@
package com.topjohnwu.unhide;
import android.app.Activity;
import android.os.Bundle;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Locale;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String command = String.format(
"pm unhide com.topjohnwu.magisk\n" +
"am start -n com.topjohnwu.magisk/.SplashActivity\n" +
"pm uninstall %s\n" +
"exit\n",
getApplicationInfo().packageName);
Process process;
try {
process = Runtime.getRuntime().exec("su");
OutputStream in = process.getOutputStream();
in.write(command.getBytes("UTF-8"));
in.flush();
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
finish();
}
}