[core] Fix module load on Android 10 (#811)
This commit is contained in:
parent
d432f3b09b
commit
2c34372803
|
|
@ -2,11 +2,14 @@ package org.lsposed.lspd.util;
|
||||||
|
|
||||||
import static de.robv.android.xposed.XposedBridge.TAG;
|
import static de.robv.android.xposed.XposedBridge.TAG;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.system.OsConstants;
|
import android.system.OsConstants;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
@ -26,7 +29,7 @@ import hidden.ByteBufferDexClassLoader;
|
||||||
public final class InMemoryDelegateLastClassLoader extends ByteBufferDexClassLoader {
|
public final class InMemoryDelegateLastClassLoader extends ByteBufferDexClassLoader {
|
||||||
private static final String zipSeparator = "!/";
|
private static final String zipSeparator = "!/";
|
||||||
private final String apk;
|
private final String apk;
|
||||||
private final List<File> nativeLibraryDirs;
|
private final List<File> nativeLibraryDirs = new ArrayList<>();
|
||||||
|
|
||||||
private static List<File> splitPaths(String searchPath) {
|
private static List<File> splitPaths(String searchPath) {
|
||||||
var result = new ArrayList<File>();
|
var result = new ArrayList<File>();
|
||||||
|
|
@ -38,12 +41,24 @@ public final class InMemoryDelegateLastClassLoader extends ByteBufferDexClassLoa
|
||||||
}
|
}
|
||||||
|
|
||||||
private InMemoryDelegateLastClassLoader(ByteBuffer[] dexBuffers,
|
private InMemoryDelegateLastClassLoader(ByteBuffer[] dexBuffers,
|
||||||
String librarySearchPath,
|
|
||||||
ClassLoader parent,
|
ClassLoader parent,
|
||||||
String apk) {
|
String apk) {
|
||||||
super(dexBuffers, parent);
|
super(dexBuffers, parent);
|
||||||
this.apk = apk;
|
this.apk = apk;
|
||||||
nativeLibraryDirs = new ArrayList<>(splitPaths(librarySearchPath));
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.Q)
|
||||||
|
private InMemoryDelegateLastClassLoader(ByteBuffer[] dexBuffers,
|
||||||
|
String librarySearchPath,
|
||||||
|
ClassLoader parent,
|
||||||
|
String apk) {
|
||||||
|
super(dexBuffers, librarySearchPath, parent);
|
||||||
|
initNativeLibraryDirs(librarySearchPath);
|
||||||
|
this.apk = apk;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initNativeLibraryDirs(String librarySearchPath) {
|
||||||
|
nativeLibraryDirs.addAll(splitPaths(librarySearchPath));
|
||||||
nativeLibraryDirs.addAll(splitPaths(System.getProperty("java.library.path")));
|
nativeLibraryDirs.addAll(splitPaths(System.getProperty("java.library.path")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,7 +172,14 @@ public final class InMemoryDelegateLastClassLoader extends ByteBufferDexClassLoa
|
||||||
Log.e(TAG, "Can not open " + apk, e);
|
Log.e(TAG, "Can not open " + apk, e);
|
||||||
}
|
}
|
||||||
var dexBuffers = new ByteBuffer[byteBuffers.size()];
|
var dexBuffers = new ByteBuffer[byteBuffers.size()];
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
return new InMemoryDelegateLastClassLoader(byteBuffers.toArray(dexBuffers),
|
return new InMemoryDelegateLastClassLoader(byteBuffers.toArray(dexBuffers),
|
||||||
librarySearchPath, parent, apk.getAbsolutePath());
|
librarySearchPath, parent, apk.getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
var cl = new InMemoryDelegateLastClassLoader(byteBuffers.toArray(dexBuffers),
|
||||||
|
parent, apk.getAbsolutePath());
|
||||||
|
cl.initNativeLibraryDirs(librarySearchPath);
|
||||||
|
return cl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,8 @@ public class ByteBufferDexClassLoader extends BaseDexClassLoader {
|
||||||
public ByteBufferDexClassLoader(ByteBuffer[] dexFiles, ClassLoader parent) {
|
public ByteBufferDexClassLoader(ByteBuffer[] dexFiles, ClassLoader parent) {
|
||||||
super(dexFiles, parent);
|
super(dexFiles, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ByteBufferDexClassLoader(ByteBuffer[] dexFiles, String librarySearchPath, ClassLoader parent) {
|
||||||
|
super(dexFiles, librarySearchPath, parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ public class BaseDexClassLoader extends ClassLoader {
|
||||||
throw new RuntimeException("Stub!");
|
throw new RuntimeException("Stub!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseDexClassLoader(ByteBuffer[] dexFiles, String librarySearchPath, ClassLoader parent) {
|
||||||
|
throw new RuntimeException("Stub!");
|
||||||
|
}
|
||||||
|
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||||
throw new RuntimeException("Stub!");
|
throw new RuntimeException("Stub!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue