From 00f701f90b5785a1e3e72c586e7627e8a9159aa5 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Wed, 3 Sep 2025 11:58:09 +0200 Subject: [PATCH] Add LoadedApk callers to deoptimize list 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. The prevailing theory is that the 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 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> --- .../java/org/lsposed/lspd/deopt/InlinedMethodCallers.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/java/org/lsposed/lspd/deopt/InlinedMethodCallers.java b/core/src/main/java/org/lsposed/lspd/deopt/InlinedMethodCallers.java index 9c0425312..4b7f999b7 100644 --- a/core/src/main/java/org/lsposed/lspd/deopt/InlinedMethodCallers.java +++ b/core/src/main/java/org/lsposed/lspd/deopt/InlinedMethodCallers.java @@ -20,6 +20,7 @@ package org.lsposed.lspd.deopt; +import android.app.Instrumentation; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.res.AssetManager; @@ -57,6 +58,12 @@ public class InlinedMethodCallers { // callers of Application#attach(Context) {"android.app.Instrumentation", "newApplication", ClassLoader.class, String.class, Context.class}, {"android.app.Instrumentation", "newApplication", ClassLoader.class, Context.class}, + + // callers of Instrumentation#newApplication(ClassLoader, String, Context) + {"android.app.LoadedApk", "makeApplicationInner", Boolean.TYPE, Instrumentation.class, Boolean.TYPE}, + {"android.app.LoadedApk", "makeApplicationInner", Boolean.TYPE, Instrumentation.class}, + {"android.app.LoadedApk", "makeApplication", Boolean.TYPE, Instrumentation.class}, + {"android.app.ContextImpl", "getSharedPreferencesPath", String.class} };