Update core

This commit is contained in:
Nullptr 2022-02-11 00:45:21 +08:00
parent 074dce99a8
commit 9129b42226
9 changed files with 86 additions and 14 deletions

View File

@ -57,7 +57,7 @@ android {
}
lint {
isAbortOnError = false
abortOnError = false
}
}
@ -89,6 +89,7 @@ androidComponents.onVariants { variant ->
}
dependencies {
implementation(project(":daemon-service"))
implementation(project(":lspcore"))
implementation(project(":hiddenapi-bridge"))
compileOnly(project(":hiddenapi-stubs"))

View File

@ -3,7 +3,6 @@ package org.lsposed.lspatch.loader;
import static android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE;
import static org.lsposed.lspatch.share.Constants.CONFIG_ASSET_PATH;
import static org.lsposed.lspatch.share.Constants.ORIGINAL_APK_ASSET_PATH;
import static org.lsposed.lspd.service.ConfigFileManager.loadModule;
import android.app.ActivityThread;
import android.app.LoadedApk;
@ -25,6 +24,7 @@ import android.util.Log;
import com.google.gson.Gson;
import org.lsposed.lspatch.loader.util.FileUtils;
import org.lsposed.lspatch.loader.util.ModuleLoader;
import org.lsposed.lspatch.loader.util.XLog;
import org.lsposed.lspatch.share.Constants;
import org.lsposed.lspatch.share.PatchConfig;
@ -267,7 +267,7 @@ public class LSPApplication extends ApplicationServiceClient {
var module = new Module();
module.apkPath = cacheApkPath;
module.packageName = packageName;
module.file = loadModule(cacheApkPath);
module.file = ModuleLoader.loadModule(cacheApkPath);
modules.add(module);
}
} catch (Throwable ignored) {

View File

@ -0,0 +1,75 @@
package org.lsposed.lspatch.loader.util;
import android.os.SharedMemory;
import android.system.ErrnoException;
import android.system.OsConstants;
import android.util.Log;
import org.lsposed.lspd.models.PreLoadedApk;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.channels.Channels;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipFile;
public class ModuleLoader {
private static final String TAG = "LSPatch";
private static void readDexes(ZipFile apkFile, List<SharedMemory> preLoadedDexes) {
int secondary = 2;
for (var dexFile = apkFile.getEntry("classes.dex"); dexFile != null;
dexFile = apkFile.getEntry("classes" + secondary + ".dex"), secondary++) {
try (var in = apkFile.getInputStream(dexFile)) {
var memory = SharedMemory.create(null, in.available());
var byteBuffer = memory.mapReadWrite();
Channels.newChannel(in).read(byteBuffer);
SharedMemory.unmap(byteBuffer);
memory.setProtect(OsConstants.PROT_READ);
preLoadedDexes.add(memory);
} catch (IOException | ErrnoException e) {
Log.w(TAG, "Can not load " + dexFile + " in " + apkFile, e);
}
}
}
private static void readName(ZipFile apkFile, String initName, List<String> names) {
var initEntry = apkFile.getEntry(initName);
if (initEntry == null) return;
try (var in = apkFile.getInputStream(initEntry)) {
var reader = new BufferedReader(new InputStreamReader(in));
String name;
while ((name = reader.readLine()) != null) {
name = name.trim();
if (name.isEmpty() || name.startsWith("#")) continue;
names.add(name);
}
} catch (IOException e) {
Log.e(TAG, "Can not open " + initEntry, e);
}
}
public static PreLoadedApk loadModule(String path) {
if (path == null) return null;
var file = new PreLoadedApk();
var preLoadedDexes = new ArrayList<SharedMemory>();
var moduleClassNames = new ArrayList<String>(1);
var moduleLibraryNames = new ArrayList<String>(1);
try (var apkFile = new ZipFile(path)) {
readDexes(apkFile, preLoadedDexes);
readName(apkFile, "assets/xposed_init", moduleClassNames);
readName(apkFile, "assets/native_init", moduleLibraryNames);
} catch (IOException e) {
Log.e(TAG, "Can not open " + path, e);
return null;
}
if (preLoadedDexes.isEmpty()) return null;
if (moduleClassNames.isEmpty()) return null;
file.preLoadedDexes = preLoadedDexes;
file.moduleClassNames = moduleClassNames;
file.moduleLibraryNames = moduleLibraryNames;
return file;
}
}

View File

@ -5,12 +5,10 @@ buildscript {
google()
mavenCentral()
}
val agpVersion by extra("7.0.3")
val navVersion by extra("2.5.0-alpha01")
val agpVersion by extra("7.1.1")
dependencies {
classpath("com.android.tools.build:gradle:$agpVersion")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$navVersion")
}
}

2
core

@ -1 +1 @@
Subproject commit a06ba931a533198cd906825d436280db8247c869
Subproject commit 216a6f00435b4ab00f5fadc80c1c3b1e7ac9b20c

View File

@ -1,6 +1,5 @@
#Tue Aug 24 21:50:17 CST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

View File

@ -36,5 +36,5 @@ android {
}
dependencies {
implementation(project(":lspcore"))
api(project(":daemon-service"))
}

View File

@ -47,8 +47,7 @@ android {
}
dependencies {
compileOnly(project(":patch"))
compileOnly(project(":lspcore"))
implementation(project(":patch"))
implementation(project(":imanager"))
implementation("androidx.core:core-ktx:1.7.0")

View File

@ -1,16 +1,16 @@
rootProject.name = "LSPatch"
include(":daemon-service")
include(":hiddenapi-bridge")
include(":hiddenapi-stubs")
include(":interface")
include(":lspapp")
include(":lspcore")
include(":manager-service")
project(":daemon-service").projectDir = file("core/daemon-service")
project(":hiddenapi-bridge").projectDir = file("core/hiddenapi-bridge")
project(":hiddenapi-stubs").projectDir = file("core/hiddenapi-stubs")
project(":interface").projectDir = file("core/service/interface")
project(":lspapp").projectDir = file("core/app")
project(":lspcore").projectDir = file("core/core")
project(":manager-service").projectDir = file("core/manager-service")