Skip to content

Commit f5af569

Browse files
Add LoadedApk callers to deoptimize list (#414)
This commit attempts to resolve an issue reported by users on recent OnePlus software updates where LSPosed modules are no longer able to hook the `Application#attach` method. Android Runtime (ART) on these devices has become more aggressive with method inlining. This optimization can cause the relatively small `Application#attach` method to be directly embedded into its (indirect) calling methods, which makes it invisible to the hooking framework. This approach is adapted from a reportedly successful commit in a community fork (LSPosed-Irena). It identifies `makeApplication` and `makeApplicationInner` within the `android.app.LoadedApk` class as the key callers to deoptimize. By adding these methods to the `BOOT_IMAGE` list, the goal is to prevent ART from inlining them, thus preserving `Application#attach` as a distinct and hookable method. Co-authored-by: Irena <140869597+re-zero001@users.noreply.github.com>
1 parent 487e835 commit f5af569

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/src/main/java/org/lsposed/lspd/deopt/InlinedMethodCallers.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package org.lsposed.lspd.deopt;
2222

23+
import android.app.Instrumentation;
2324
import android.content.Context;
2425
import android.content.pm.ApplicationInfo;
2526
import android.content.res.AssetManager;
@@ -57,6 +58,12 @@ public class InlinedMethodCallers {
5758
// callers of Application#attach(Context)
5859
{"android.app.Instrumentation", "newApplication", ClassLoader.class, String.class, Context.class},
5960
{"android.app.Instrumentation", "newApplication", ClassLoader.class, Context.class},
61+
62+
// callers of Instrumentation#newApplication(ClassLoader, String, Context)
63+
{"android.app.LoadedApk", "makeApplicationInner", Boolean.TYPE, Instrumentation.class, Boolean.TYPE},
64+
{"android.app.LoadedApk", "makeApplicationInner", Boolean.TYPE, Instrumentation.class},
65+
{"android.app.LoadedApk", "makeApplication", Boolean.TYPE, Instrumentation.class},
66+
6067
{"android.app.ContextImpl", "getSharedPreferencesPath", String.class}
6168
};
6269

0 commit comments

Comments
 (0)