Skip to content

Commit

Permalink
Merge pull request #11 from HSSkyBoy/HSSkyBoy-patch-2
Browse files Browse the repository at this point in the history
Skip split apks when possible
  • Loading branch information
HSSkyBoy authored Feb 25, 2024
2 parents caa2111 + da53f62 commit 04154c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion patch/src/main/java/org/lsposed/patch/LSPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void doCommandLine() throws PatchError, IOException {
outputDir.mkdirs();

File outputFile = new File(outputDir, String.format(
Locale.getDefault(), "%s-%d-lspatched.apk",
Locale.getDefault(), "%s-%d-npatched.apk",
FilenameUtils.getBaseName(apkFileName),
LSPConfig.instance.VERSION_CODE)
).getAbsoluteFile();
Expand Down Expand Up @@ -232,6 +232,18 @@ public void patch(File srcApkFile, File outputFile) throws PatchError, IOExcepti
logger.d("original minSdkVersion: " + minSdkVersion);
}

final boolean skipSplit = apkPaths.size() > 1 && srcApkFile.getName().startsWith("split_") && appComponentFactory == null;
if (skipSplit) {
logger.i("Packing split apk...");
for (StoredEntry entry : srcZFile.entries()) {
String name = entry.getCentralDirectoryHeader().getName();
if (dstZFile.get(name) != null) continue;
if (name.startsWith("META-INF") && (name.endsWith(".SF") || name.endsWith(".MF") || name.endsWith(".RSA"))) continue;
srcZFile.addFileLink(name, name);
}
return;
}

logger.i("Patching apk...");
// modify manifest
final var config = new PatchConfig(useManager, debuggableFlag, overrideVersionCode, sigbypassLevel, originalSignature, appComponentFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Constants {
final static public String ORIGINAL_APK_ASSET_PATH = "assets/lspatch/origin.apk";
final static public String EMBEDDED_MODULES_ASSET_PATH = "assets/lspatch/modules/";

final static public String PATCH_FILE_SUFFIX = "-lspatched.apk";
final static public String PATCH_FILE_SUFFIX = "-npatched.apk";
final static public String PROXY_APP_COMPONENT_FACTORY = "org.lsposed.lspatch.metaloader.LSPAppComponentFactoryStub";
final static public String MANAGER_PACKAGE_NAME = "org.lsposed.lspatch";
final static public int MIN_ROLLING_VERSION_CODE = 348;
Expand Down

0 comments on commit 04154c8

Please sign in to comment.