auto copy original apk to assets

This commit is contained in:
327135569 2021-01-31 12:06:57 +08:00
parent 2c80821646
commit 581aaf74f7
3 changed files with 796 additions and 788 deletions

View File

@ -215,6 +215,12 @@ public class MainCommand extends BaseCommand {
// compress all files into an apk and then sign it.
mXpatchTasks.add(new BuildAndSignApkTask(keepBuildFiles, unzipApkFilePath, output));
// copy origin apk to assets
// convenient to bypass some check like CRC
if(!FileUtils.copyFile(srcApkFile, new File(unzipApkFilePath, "assets/origin_apk.bin"))){
throw new IllegalStateException("orignal apk copy fail");
}
// excute these tasks
for (Runnable executor : mXpatchTasks) {
currentTime = System.currentTimeMillis();

View File

@ -32,8 +32,8 @@ public abstract class BaseCommand {
@Opt(opt = "h", longOpt = "help", hasArg = false, description = "Print this help message")
private boolean printHelp = false;
protected String remainingArgs[];
protected String orginalArgs[];
protected String[] remainingArgs;
protected String[] orginalArgs;
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.FIELD })

View File

@ -125,7 +125,7 @@ public class FileUtils {
copyFile(new File(sourcePath), new File(targetPath));
}
public static void copyFile(File source, File target) {
public static boolean copyFile(File source, File target) {
FileInputStream inputStream = null;
FileOutputStream outputStream = null;
@ -146,12 +146,14 @@ public class FileUtils {
buffer.position(0);
oChannel.write(buffer);
}
return true;
} catch (IOException e) {
e.printStackTrace();
} finally {
close(inputStream);
close(outputStream);
}
return false;
}
public static void deleteDir(File file) {