Fallback classloader

This commit is contained in:
LoveSy 2022-02-12 15:55:07 +08:00 committed by LoveSy
parent 8a655cc27e
commit 77b69d52c2
1 changed files with 8 additions and 1 deletions

View File

@ -25,6 +25,9 @@ import java.util.Objects;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import dalvik.system.DelegateLastClassLoader;
import dalvik.system.PathClassLoader;
import de.robv.android.xposed.XposedBridge;
import hidden.ByteBufferDexClassLoader; import hidden.ByteBufferDexClassLoader;
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@ -175,7 +178,7 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
super.toString() + "]"; super.toString() + "]";
} }
public static LspModuleClassLoader loadApk(String apk, public static ClassLoader loadApk(String apk,
List<SharedMemory> dexes, List<SharedMemory> dexes,
String librarySearchPath, String librarySearchPath,
ClassLoader parent) { ClassLoader parent) {
@ -187,6 +190,10 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
return null; return null;
} }
}).filter(Objects::nonNull).toArray(ByteBuffer[]::new); }).filter(Objects::nonNull).toArray(ByteBuffer[]::new);
if (dexBuffers == null) {
XposedBridge.log("Failed to load dex from daemon, falling back to PathDexClassloader");
return new DelegateLastClassLoader(apk, librarySearchPath, parent);
}
LspModuleClassLoader cl; LspModuleClassLoader cl;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
cl = new LspModuleClassLoader(dexBuffers, librarySearchPath, cl = new LspModuleClassLoader(dexBuffers, librarySearchPath,