|
1 | 1 | package me.weishu.exposed; |
2 | 2 |
|
3 | 3 | import android.annotation.SuppressLint; |
| 4 | +import android.app.Application; |
4 | 5 | import android.content.ComponentName; |
5 | 6 | import android.content.Context; |
| 7 | +import android.content.ContextWrapper; |
6 | 8 | import android.content.Intent; |
7 | 9 | import android.content.ServiceConnection; |
8 | 10 | import android.content.SharedPreferences; |
|
33 | 35 | import java.lang.reflect.Constructor; |
34 | 36 | import java.lang.reflect.Field; |
35 | 37 | import java.lang.reflect.Member; |
| 38 | +import java.lang.reflect.Method; |
36 | 39 | import java.util.Arrays; |
37 | 40 | import java.util.HashMap; |
38 | 41 | import java.util.HashSet; |
@@ -268,10 +271,24 @@ public static XC_MethodHook.Unhook hookMethod(Member method, XC_MethodHook callb |
268 | 271 | if (ignoreHooks(method)) { |
269 | 272 | return null; |
270 | 273 | } |
| 274 | + |
| 275 | + method = replaceForCHA(method); |
| 276 | + |
271 | 277 | final XC_MethodHook.Unhook unhook = DexposedBridge.hookMethod(method, callback); |
272 | 278 | return ExposedHelper.newUnHook(callback, unhook.getHookedMethod()); |
273 | 279 | } |
274 | 280 |
|
| 281 | + private static Member replaceForCHA(Member member) { |
| 282 | + |
| 283 | + if (member.getDeclaringClass() == Application.class && member.getName().equals("attach")) { |
| 284 | + |
| 285 | + Method m = XposedHelpers.findMethodExact(ContextWrapper.class, "attachBaseContext", Context.class); |
| 286 | + XposedBridge.log("replace ContextWrapper.attachBaseContext with Application.attach for CHA"); |
| 287 | + return m; |
| 288 | + } |
| 289 | + return member; |
| 290 | + } |
| 291 | + |
275 | 292 | private static void initForXposedModule(Context context, ApplicationInfo applicationInfo, ClassLoader appClassLoader) { |
276 | 293 | InputStream inputStream = null; |
277 | 294 |
|
|
0 commit comments