No compress for so
This commit is contained in:
parent
19089a3097
commit
0f8dd05233
|
|
@ -52,7 +52,6 @@ public class LSPatch {
|
||||||
@Parameter(names = {"-f", "--force"}, description = "Force overwrite exists output file")
|
@Parameter(names = {"-f", "--force"}, description = "Force overwrite exists output file")
|
||||||
private boolean forceOverwrite = false;
|
private boolean forceOverwrite = false;
|
||||||
|
|
||||||
@Parameter(names = {"-p", "--proxyname"}, description = "Special proxy app name with full dot path")
|
|
||||||
private String proxyName = "org.lsposed.lspatch.appstub.LSPApplicationStub";
|
private String proxyName = "org.lsposed.lspatch.appstub.LSPApplicationStub";
|
||||||
|
|
||||||
@Parameter(names = {"-d", "--debuggable"}, description = "Set app to be debuggable")
|
@Parameter(names = {"-d", "--debuggable"}, description = "Set app to be debuggable")
|
||||||
|
|
@ -206,7 +205,7 @@ public class LSPatch {
|
||||||
System.out.println("Search target apk library arch..");
|
System.out.println("Search target apk library arch..");
|
||||||
for (StoredEntry storedEntry : zFile.entries()) {
|
for (StoredEntry storedEntry : zFile.entries()) {
|
||||||
var name = storedEntry.getCentralDirectoryHeader().getName();
|
var name = storedEntry.getCentralDirectoryHeader().getName();
|
||||||
if (name.startsWith("lib/")) {
|
if (name.startsWith("lib/") && name.length() >= 5) {
|
||||||
var arch = name.substring(4, name.indexOf('/', 5));
|
var arch = name.substring(4, name.indexOf('/', 5));
|
||||||
apkArchs.add(arch);
|
apkArchs.add(arch);
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +216,7 @@ public class LSPatch {
|
||||||
}
|
}
|
||||||
|
|
||||||
apkArchs.removeIf((arch) -> {
|
apkArchs.removeIf((arch) -> {
|
||||||
if (!APK_LIB_PATH_ARRAY.contains(arch)) {
|
if (!APK_LIB_PATH_ARRAY.contains(arch) && !arch.equals("armeabi")) {
|
||||||
System.err.println("Warning: unsupported arch " + arch + ". Skipping...");
|
System.err.println("Warning: unsupported arch " + arch + ". Skipping...");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -229,8 +228,8 @@ public class LSPatch {
|
||||||
for (String arch : apkArchs) {
|
for (String arch : apkArchs) {
|
||||||
// lib/armeabi-v7a -> armeabi-v7a
|
// lib/armeabi-v7a -> armeabi-v7a
|
||||||
String entryName = "lib/" + arch + "/liblspd.so";
|
String entryName = "lib/" + arch + "/liblspd.so";
|
||||||
try (var is = getClass().getClassLoader().getResourceAsStream("assets/so/" + arch + "/liblspd.so")) {
|
try (var is = getClass().getClassLoader().getResourceAsStream("assets/so/" + (arch.equals("armeabi") ? "armeabi-v7a" : arch) + "/liblspd.so")) {
|
||||||
zFile.add(entryName, is);
|
zFile.add(entryName, is, false); // no compress for so
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw new PatchError("Error when adding native lib: " + e);
|
throw new PatchError("Error when adding native lib: " + e);
|
||||||
}
|
}
|
||||||
|
|
@ -268,10 +267,14 @@ public class LSPatch {
|
||||||
throw new PatchError("Error when saving signature: " + e);
|
throw new PatchError("Error when saving signature: " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Signing apk...");
|
||||||
|
var sign = zFile.get("META-INF/MANIFEST.MF");
|
||||||
|
if (sign != null)
|
||||||
|
sign.delete();
|
||||||
|
|
||||||
zFile.update();
|
zFile.update();
|
||||||
zFile.close();
|
zFile.close();
|
||||||
|
|
||||||
System.out.println("Signing apk...");
|
|
||||||
signApkUsingAndroidApksigner(workingDir, tmpApk, outputFile);
|
signApkUsingAndroidApksigner(workingDir, tmpApk, outputFile);
|
||||||
|
|
||||||
System.out.println("Done. Output APK: " + outputFile.getAbsolutePath());
|
System.out.println("Done. Output APK: " + outputFile.getAbsolutePath());
|
||||||
|
|
@ -283,15 +286,17 @@ public class LSPatch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] modifyManifestFile(InputStream is) {
|
private byte[] modifyManifestFile(InputStream is) throws IOException {
|
||||||
ModificationProperty property = new ModificationProperty();
|
ModificationProperty property = new ModificationProperty();
|
||||||
|
|
||||||
property.addApplicationAttribute(new AttributeItem(NodeValue.Application.DEBUGGABLE, debuggableFlag));
|
property.addApplicationAttribute(new AttributeItem(NodeValue.Application.DEBUGGABLE, debuggableFlag));
|
||||||
property.addApplicationAttribute(new AttributeItem("extractNativeLibs", true));
|
|
||||||
property.addApplicationAttribute(new AttributeItem(NodeValue.Application.NAME, proxyName));
|
property.addApplicationAttribute(new AttributeItem(NodeValue.Application.NAME, proxyName));
|
||||||
|
|
||||||
var os = new ByteArrayOutputStream();
|
var os = new ByteArrayOutputStream();
|
||||||
(new ManifestEditor(is, os, property)).processManifest();
|
(new ManifestEditor(is, os, property)).processManifest();
|
||||||
|
is.close();
|
||||||
|
os.flush();
|
||||||
|
os.close();
|
||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -323,14 +328,16 @@ public class LSPatch {
|
||||||
commandList.add("pass:" + 123456);
|
commandList.add("pass:" + 123456);
|
||||||
commandList.add("--key-pass");
|
commandList.add("--key-pass");
|
||||||
commandList.add("pass:" + 123456);
|
commandList.add("pass:" + 123456);
|
||||||
commandList.add("--out");
|
commandList.add("--min-sdk-version");
|
||||||
commandList.add(outputPath.getAbsolutePath());
|
commandList.add("27");
|
||||||
commandList.add("--v1-signing-enabled");
|
commandList.add("--v1-signing-enabled");
|
||||||
commandList.add(Boolean.toString(v1));
|
commandList.add(Boolean.toString(v1));
|
||||||
commandList.add("--v2-signing-enabled"); // v2签名不兼容android 6
|
commandList.add("--v2-signing-enabled"); // v2签名不兼容android 6
|
||||||
commandList.add(Boolean.toString(v2));
|
commandList.add(Boolean.toString(v2));
|
||||||
commandList.add("--v3-signing-enabled"); // v3签名不兼容android 6
|
commandList.add("--v3-signing-enabled"); // v3签名不兼容android 6
|
||||||
commandList.add(Boolean.toString(v3));
|
commandList.add(Boolean.toString(v3));
|
||||||
|
commandList.add("--out");
|
||||||
|
commandList.add(outputPath.getAbsolutePath());
|
||||||
commandList.add(apkPath.getAbsolutePath());
|
commandList.add(apkPath.getAbsolutePath());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue