mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-13 05:37:47 +02:00
Allow component classname obfuscation
This commit is contained in:
@ -16,8 +16,8 @@
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<application
|
||||
android:name="a.e"
|
||||
android:appComponentFactory="a.a"
|
||||
android:name="a.y"
|
||||
android:appComponentFactory="a.x"
|
||||
android:allowBackup="true"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="UnusedAttribute,GoogleAppIndexingWarning" >
|
||||
@ -25,7 +25,7 @@
|
||||
<!-- Download Activity -->
|
||||
|
||||
<activity
|
||||
android:name="a.c"
|
||||
android:name="a.z"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:theme="@style/SplashTheme">
|
||||
<intent-filter>
|
||||
@ -37,23 +37,23 @@
|
||||
<!-- Magisk Manager Components -->
|
||||
|
||||
<activity
|
||||
android:name="a.b"
|
||||
android:name="a.o"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:exported="true" />
|
||||
|
||||
<activity
|
||||
android:name="a.f"
|
||||
android:name="a.x"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="nosensor" />
|
||||
|
||||
<activity
|
||||
android:name="a.m"
|
||||
android:name="a.g"
|
||||
android:directBootAware="true"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="false" />
|
||||
|
||||
<receiver
|
||||
android:name="a.h"
|
||||
android:name="a.w"
|
||||
android:directBootAware="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
@ -68,7 +68,7 @@
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name="a.j"
|
||||
android:name="a.v"
|
||||
android:exported="false" />
|
||||
|
||||
<meta-data
|
||||
|
6
stub/src/main/java/a/w.java
Normal file
6
stub/src/main/java/a/w.java
Normal file
@ -0,0 +1,6 @@
|
||||
package a;
|
||||
|
||||
import com.topjohnwu.magisk.dummy.DummyReceiver;
|
||||
|
||||
public class w extends DummyReceiver {
|
||||
}
|
@ -2,5 +2,5 @@ package a;
|
||||
|
||||
import com.topjohnwu.magisk.DelegateComponentFactory;
|
||||
|
||||
public class a extends DelegateComponentFactory {
|
||||
public class x extends DelegateComponentFactory {
|
||||
}
|
@ -2,5 +2,5 @@ package a;
|
||||
|
||||
import com.topjohnwu.magisk.DelegateApplication;
|
||||
|
||||
public class e extends DelegateApplication {
|
||||
public class y extends DelegateApplication {
|
||||
}
|
@ -2,5 +2,5 @@ package a;
|
||||
|
||||
import com.topjohnwu.magisk.DownloadActivity;
|
||||
|
||||
public class c extends DownloadActivity {
|
||||
public class z extends DownloadActivity {
|
||||
}
|
32
stub/src/main/java/com/topjohnwu/magisk/ComponentMap.java
Normal file
32
stub/src/main/java/com/topjohnwu/magisk/ComponentMap.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
class ComponentMap {
|
||||
private static Map<String, String> map = new HashMap<>(6);
|
||||
|
||||
// This mapping will be sent into the guest app
|
||||
static Map<String, String> inverseMap;
|
||||
|
||||
static {
|
||||
map.put(a.z.class.getName(), "a.c");
|
||||
map.put("a.x", "a.f");
|
||||
map.put("a.o", "a.b");
|
||||
map.put("a.g", "a.m");
|
||||
map.put(a.w.class.getName(), "a.h");
|
||||
map.put("a.v", "a.j");
|
||||
map.put("a.s", "androidx.work.impl.WorkManagerInitializer");
|
||||
|
||||
inverseMap = new HashMap<>(map.size());
|
||||
for (Map.Entry<String, String> e : map.entrySet()) {
|
||||
inverseMap.put(e.getValue(), e.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
static String get(String name) {
|
||||
String n = map.get(name);
|
||||
return n != null ? n : name;
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ import com.topjohnwu.magisk.utils.DynamicClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.topjohnwu.magisk.DownloadActivity.TAG;
|
||||
|
||||
@ -44,7 +45,8 @@ public class DelegateApplication extends Application {
|
||||
Object df = cl.loadClass("a.a").newInstance();
|
||||
|
||||
// Create the delegate Application
|
||||
delegate = (Application) cl.loadClass("a.e").newInstance();
|
||||
delegate = (Application) cl.loadClass("a.e").getConstructor(Map.class)
|
||||
.newInstance(ComponentMap.inverseMap);
|
||||
|
||||
// Call attachBaseContext without ContextImpl to show it is being wrapped
|
||||
Method m = ContextWrapper.class.getDeclaredMethod("attachBaseContext", Context.class);
|
||||
|
@ -8,12 +8,15 @@ import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.topjohnwu.magisk.dummy.DummyActivity;
|
||||
import com.topjohnwu.magisk.dummy.DummyProvider;
|
||||
import com.topjohnwu.magisk.dummy.DummyReceiver;
|
||||
import com.topjohnwu.magisk.dummy.DummyService;
|
||||
|
||||
import static com.topjohnwu.magisk.DownloadActivity.TAG;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class DelegateComponentFactory extends AppComponentFactory {
|
||||
|
||||
@ -22,39 +25,45 @@ public class DelegateComponentFactory extends AppComponentFactory {
|
||||
|
||||
@Override
|
||||
public Application instantiateApplication(ClassLoader cl, String className) {
|
||||
loader = cl;
|
||||
if (loader == null) loader = cl;
|
||||
Log.d(TAG, className);
|
||||
return new DelegateApplication(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity instantiateActivity(ClassLoader cl, String className, Intent intent)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
Log.d(TAG, className);
|
||||
if (delegate != null)
|
||||
return delegate.instantiateActivity(loader, className, intent);
|
||||
return delegate.instantiateActivity(loader, ComponentMap.get(className), intent);
|
||||
return create(className, DummyActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BroadcastReceiver instantiateReceiver(ClassLoader cl, String className, Intent intent)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
Log.d(TAG, className);
|
||||
if (delegate != null)
|
||||
return delegate.instantiateReceiver(loader, className, intent);
|
||||
return delegate.instantiateReceiver(loader, ComponentMap.get(className), intent);
|
||||
return create(className, DummyReceiver.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Service instantiateService(ClassLoader cl, String className, Intent intent)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
Log.d(TAG, className);
|
||||
if (delegate != null)
|
||||
return delegate.instantiateService(loader, className, intent);
|
||||
return delegate.instantiateService(loader, ComponentMap.get(className), intent);
|
||||
return create(className, DummyService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentProvider instantiateProvider(ClassLoader cl, String className)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
Log.d(TAG, className);
|
||||
if (loader == null) loader = cl;
|
||||
if (delegate != null)
|
||||
return delegate.instantiateProvider(loader, className);
|
||||
return delegate.instantiateProvider(loader, ComponentMap.get(className));
|
||||
return create(className, DummyProvider.class);
|
||||
}
|
||||
|
||||
@ -63,6 +72,7 @@ public class DelegateComponentFactory extends AppComponentFactory {
|
||||
*/
|
||||
private <T> T create(String name, Class<? extends T> dummy)
|
||||
throws InstantiationException, IllegalAccessException {
|
||||
Log.d(TAG, "create " + name);
|
||||
try {
|
||||
return (T) loader.loadClass(name).newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException ignored) {
|
||||
|
Reference in New Issue
Block a user