Skip to content

Commit d614166

Browse files
committed
Skip split apks when possible
When the split apks are loaded by appComponentFactory, we skip patching them to reduce the file size.
1 parent 0f21e89 commit d614166

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

patch/src/main/java/org/lsposed/patch/LSPatch.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,18 @@ public void patch(File srcApkFile, File outputFile) throws PatchError, IOExcepti
233233
logger.d("original minSdkVersion: " + minSdkVersion);
234234
}
235235

236+
final boolean skipSplit = apkPaths.size() > 1 && srcApkFile.getName().startsWith("split_") && appComponentFactory == null;
237+
if (skipSplit) {
238+
logger.i("Packing split apk...");
239+
for (StoredEntry entry : srcZFile.entries()) {
240+
String name = entry.getCentralDirectoryHeader().getName();
241+
if (dstZFile.get(name) != null) continue;
242+
if (name.startsWith("META-INF") && (name.endsWith(".SF") || name.endsWith(".MF") || name.endsWith(".RSA"))) continue;
243+
srcZFile.addFileLink(name, name);
244+
}
245+
return;
246+
}
247+
236248
logger.i("Patching apk...");
237249
// modify manifest
238250
final var config = new PatchConfig(useManager, debuggableFlag, overrideVersionCode, sigbypassLevel, originalSignature, appComponentFactory);

0 commit comments

Comments
 (0)