[core] Use array list (#870)
This commit is contained in:
parent
49163768d6
commit
ad5cd87d4a
|
|
@ -24,7 +24,6 @@ import java.nio.file.Paths
|
|||
import java.time.Instant
|
||||
|
||||
plugins {
|
||||
id("org.gradle.idea")
|
||||
id("com.android.application")
|
||||
id("androidx.navigation.safeargs")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.lsposed.lspd.models;
|
||||
|
||||
parcelable ModuleConfig {
|
||||
SharedMemory[] preLoadedDexes;
|
||||
List<SharedMemory> preLoadedDexes;
|
||||
List<String> moduleClassNames;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import org.lsposed.lspd.models.Module;
|
|||
interface ILSPApplicationService {
|
||||
IBinder requestModuleBinder(String name);
|
||||
|
||||
//TODO: after array copy bug fixed, use array instead of list
|
||||
boolean requestManagerBinder(String packageName, String path, out List<IBinder> binder);
|
||||
|
||||
boolean isResourcesHookEnabled();
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ package org.lsposed.lspd.service;
|
|||
import org.lsposed.lspd.service.ILSPApplicationService;
|
||||
|
||||
interface ILSPSystemServerService {
|
||||
ILSPApplicationService requestApplicationService(int uid, int pid, String processName, IBinder heartBeat) = 1;
|
||||
ILSPApplicationService requestApplicationService(int uid, int pid, String processName, IBinder heartBeat);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.lsposed.lspd.service;
|
|||
import org.lsposed.lspd.service.ILSPApplicationService;
|
||||
|
||||
interface ILSPosedService {
|
||||
ILSPApplicationService requestApplicationService(int uid, int pid, String processName, IBinder heartBeat) = 1;
|
||||
ILSPApplicationService requestApplicationService(int uid, int pid, String processName, IBinder heartBeat);
|
||||
|
||||
oneway void dispatchSystemServerContext(in IBinder activityThread, in IBinder activityToken) = 4;
|
||||
oneway void dispatchSystemServerContext(in IBinder activityThread, in IBinder activityToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ 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.atomic.AtomicBoolean;
|
||||
|
||||
|
|
@ -355,7 +356,7 @@ public final class XposedInit {
|
|||
* in <code>assets/xposed_init</code>.
|
||||
*/
|
||||
@SuppressLint("PrivateApi")
|
||||
private static boolean loadModule(String name, String apk, SharedMemory[] dexes) {
|
||||
private static boolean loadModule(String name, String apk, List<SharedMemory> dexes) {
|
||||
Log.i(TAG, "Loading module " + name + " from " + apk);
|
||||
|
||||
if (!new File(apk).exists()) {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class LoadedApkGetCLHooker extends XC_MethodHook {
|
|||
hookNewXSP(lpparam);
|
||||
}
|
||||
|
||||
var binder = new ArrayList<IBinder>();
|
||||
var binder = new ArrayList<IBinder>(1);
|
||||
var blocked = false;
|
||||
var info = loadedApk.getApplicationInfo();
|
||||
if (info != null) {
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ public class ConfigManager {
|
|||
private final Map<ProcessScope, List<Module>> cachedScope = new ConcurrentHashMap<>();
|
||||
|
||||
// apkPath, dexes
|
||||
private final Map<String, SharedMemory[]> cachedDexes = new ConcurrentHashMap<>();
|
||||
private final Map<String, List<SharedMemory>> cachedDexes = new ConcurrentHashMap<>();
|
||||
|
||||
// appId, packageName
|
||||
private final Map<Integer, String> cachedModule = new ConcurrentHashMap<>();
|
||||
|
|
@ -547,7 +547,7 @@ public class ConfigManager {
|
|||
});
|
||||
}
|
||||
|
||||
private SharedMemory[] loadModuleDexes(String path) {
|
||||
private List<SharedMemory> loadModuleDexes(String path) {
|
||||
var sharedMemories = new ArrayList<SharedMemory>();
|
||||
try (var apkFile = new ZipFile(path)) {
|
||||
int secondary = 2;
|
||||
|
|
@ -567,10 +567,10 @@ public class ConfigManager {
|
|||
} catch (IOException e) {
|
||||
Log.e(TAG, "Can not open " + path, e);
|
||||
}
|
||||
return sharedMemories.toArray(new SharedMemory[0]);
|
||||
return sharedMemories;
|
||||
}
|
||||
|
||||
private SharedMemory[] getModuleDexes(String path) {
|
||||
private List<SharedMemory> getModuleDexes(String path) {
|
||||
return cachedDexes.computeIfAbsent(path, this::loadModuleDexes);
|
||||
}
|
||||
|
||||
|
|
@ -579,7 +579,7 @@ public class ConfigManager {
|
|||
var path = entry.getKey();
|
||||
var dexes = entry.getValue();
|
||||
if (!new File(path).exists()) {
|
||||
Arrays.stream(dexes).parallel().forEach(SharedMemory::close);
|
||||
dexes.stream().parallel().forEach(SharedMemory::close);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -856,8 +856,7 @@ public class ConfigManager {
|
|||
}
|
||||
|
||||
public boolean shouldBlock(String packageName) {
|
||||
return packageName.equals("io.github.lsposed.manager") ||
|
||||
packageName.equals(BuildConfig.DEFAULT_MANAGER_PACKAGE_NAME);
|
||||
return packageName.equals("io.github.lsposed.manager") || isManager(packageName);
|
||||
}
|
||||
|
||||
public String getPrefsPath(String fileName, int uid) {
|
||||
|
|
|
|||
|
|
@ -177,10 +177,10 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
|
|||
}
|
||||
|
||||
public static LspModuleClassLoader loadApk(File apk,
|
||||
SharedMemory[] dexes,
|
||||
List<SharedMemory> dexes,
|
||||
String librarySearchPath,
|
||||
ClassLoader parent) {
|
||||
var dexBuffers = Arrays.stream(dexes).parallel().map(dex -> {
|
||||
var dexBuffers = dexes.stream().parallel().map(dex -> {
|
||||
try {
|
||||
return dex.mapReadOnly();
|
||||
} catch (ErrnoException e) {
|
||||
|
|
@ -197,7 +197,7 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
|
|||
cl.initNativeLibraryDirs(librarySearchPath);
|
||||
}
|
||||
Arrays.stream(dexBuffers).parallel().forEach(SharedMemory::unmap);
|
||||
Arrays.stream(dexes).parallel().forEach(SharedMemory::close);
|
||||
dexes.stream().parallel().forEach(SharedMemory::close);
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue