mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-11 22:43:36 +00:00
42 lines
1.2 KiB
Java
42 lines
1.2 KiB
Java
package com.topjohnwu.magisk;
|
|
|
|
import android.app.Application;
|
|
import android.content.Context;
|
|
import android.content.ContextWrapper;
|
|
import android.content.res.Configuration;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import io.michaelrocks.paranoid.Obfuscate;
|
|
|
|
@Obfuscate
|
|
public class DelegateApplication extends Application {
|
|
|
|
static boolean dynLoad = false;
|
|
|
|
private Application receiver;
|
|
|
|
@Override
|
|
protected void attachBaseContext(Context base) {
|
|
super.attachBaseContext(base);
|
|
|
|
// Only dynamic load full APK if hidden
|
|
dynLoad = !base.getPackageName().equals(BuildConfig.APPLICATION_ID);
|
|
|
|
receiver = InjectAPK.setup(this);
|
|
if (receiver != null) try {
|
|
// Call attachBaseContext without ContextImpl to show it is being wrapped
|
|
Method m = ContextWrapper.class.getDeclaredMethod("attachBaseContext", Context.class);
|
|
m.setAccessible(true);
|
|
m.invoke(receiver, this);
|
|
} catch (Exception ignored) { /* Impossible */ }
|
|
}
|
|
|
|
@Override
|
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
super.onConfigurationChanged(newConfig);
|
|
if (receiver != null)
|
|
receiver.onConfigurationChanged(newConfig);
|
|
}
|
|
}
|