[core] Fix modules may be loaded twice in Android 12 (#1116)
In android 12, loaded apk may be loaded async before handleBindApp Co-authored-by: 残页 <31466456+canyie@users.noreply.github.com>
This commit is contained in:
parent
1a4426d7cb
commit
695fe45c56
|
|
@ -51,8 +51,9 @@ import java.io.File;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
|
||||
|
|
@ -359,5 +360,5 @@ public final class XposedInit {
|
|||
return initModule(mcl, apk, file.moduleClassNames);
|
||||
}
|
||||
|
||||
public final static HashSet<String> loadedPackagesInProcess = new HashSet<>(1);
|
||||
public final static Set<String> loadedPackagesInProcess = ConcurrentHashMap.newKeySet(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,11 @@ public class LoadedApkCstrHooker extends XC_MethodHook {
|
|||
return;
|
||||
}
|
||||
|
||||
if (XposedInit.loadedPackagesInProcess.isEmpty()) {
|
||||
Hookers.logD("First LoadedApk should be called by handleBindApplication, skip: " + mAppDir);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!XposedInit.loadedPackagesInProcess.add(packageName)) {
|
||||
Hookers.logD("LoadedApk#<init> has been loaded before, skip: " + mAppDir);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue