From 61624dafaefe6f30d047e4bc7a7ebd15f7301771 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sat, 19 Jun 2021 12:08:02 +0800 Subject: [PATCH] Multiple files support --- .../main/java/org/lsposed/patch/LSPatch.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/patch/src/main/java/org/lsposed/patch/LSPatch.java b/patch/src/main/java/org/lsposed/patch/LSPatch.java index fba9959..2735f1c 100644 --- a/patch/src/main/java/org/lsposed/patch/LSPatch.java +++ b/patch/src/main/java/org/lsposed/patch/LSPatch.java @@ -38,8 +38,8 @@ public class LSPatch { } } - @Parameter(description = "apk") - private String apkPath = null; + @Parameter(description = "apks") + private ArrayList apkPaths = new ArrayList<>(); @Parameter(names = {"-h", "--help"}, help = true, order = 0, description = "Print this message") private boolean help = false; @@ -105,13 +105,18 @@ public class LSPatch { jCommander.usage(); return; } - if (apkPath == null || apkPath.isEmpty()) { + if (apkPaths == null || apkPaths.isEmpty()) { jCommander.usage(); return; } + for (var apk : apkPaths) { + File srcApkFile = new File(apk).getAbsoluteFile(); + System.out.println("Processing " + srcApkFile); + patch(srcApkFile); + } + } - File srcApkFile = new File(apkPath).getAbsoluteFile(); - + public void patch(File srcApkFile) throws PatchError, IOException { if (!srcApkFile.exists()) throw new PatchError("The source apk file does not exit. Please provide a correct path."); @@ -142,7 +147,7 @@ public class LSPatch { ZFile zFile = ZFile.openReadWrite(tmpApk); // save the apk original signature info, to support crach signature. - String originalSignature = ApkSignatureHelper.getApkSignInfo(apkPath); + String originalSignature = ApkSignatureHelper.getApkSignInfo(srcApkFile.getAbsolutePath()); if (originalSignature == null || originalSignature.isEmpty()) { throw new PatchError("get original signature failed"); }