mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-05 17:45:52 +01:00
add support for automatically patch signatures
Conflicts: brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java
This commit is contained in:
parent
213f6f8a65
commit
3578010262
@ -183,9 +183,11 @@ public class Main {
|
||||
flags.put("verbose", false);
|
||||
flags.put("framework", false);
|
||||
flags.put("update", false);
|
||||
flags.put("copyOriginal", false);
|
||||
|
||||
int i;
|
||||
int skip = 0;
|
||||
|
||||
ExtFile mOrigApk = null;
|
||||
String mAaptPath = "";
|
||||
for (i = 0; i < args.length; i++) {
|
||||
@ -202,6 +204,8 @@ public class Main {
|
||||
} else if ("-a".equals(opt) || "--aapt".equals(opt)) {
|
||||
mAaptPath = args[i + 1];
|
||||
skip = 1;
|
||||
} else if ("-c".equals(opt) || "--copy-original".equals(opt)) {
|
||||
flags.put("copyOriginal", true);
|
||||
} else if ("--frame-path".equals(opt)) {
|
||||
i++;
|
||||
instance.setFrameworkFolder(args[i]);
|
||||
@ -329,6 +333,8 @@ public class Main {
|
||||
+ " Build in debug mode. Check project page for more info.\n"
|
||||
+ " -a, --aapt\n"
|
||||
+ " Loads aapt from specified location.\n"
|
||||
+ " -c, --copy-original\n"
|
||||
+ " Copies original AndroidManifest.xml and META-INF.\n"
|
||||
+ " --frame-path <dir>\n"
|
||||
+ " Use the specified directory for framework files\n"
|
||||
+ "\n"
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
package brut.androlib;
|
||||
|
||||
import brut.androlib.err.InFileNotFoundException;
|
||||
import brut.androlib.java.AndrolibJava;
|
||||
import brut.androlib.res.AndrolibResources;
|
||||
import brut.androlib.res.data.ResPackage;
|
||||
@ -129,6 +128,27 @@ public class Androlib {
|
||||
}
|
||||
}
|
||||
|
||||
public void writeOriginalFiles(ExtFile apkFile, File outDir)
|
||||
throws AndrolibException {
|
||||
LOGGER.info("Copying original files...");
|
||||
File originalDir = new File(outDir, "original");
|
||||
if (!originalDir.exists()) {
|
||||
originalDir.mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
Directory in = apkFile.getDirectory();
|
||||
if(in.containsFile("AndroidManifest.xml")) {
|
||||
in.copyToDir(originalDir, "AndroidManifest.xml");
|
||||
}
|
||||
if (in.containsDir("META-INF")) {
|
||||
in.copyToDir(originalDir, "META-INF");
|
||||
}
|
||||
} catch (DirectoryException ex) {
|
||||
throw new AndrolibException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeMetaFile(File mOutDir, Map<String, Object> meta)
|
||||
throws AndrolibException {
|
||||
DumperOptions options = new DumperOptions();
|
||||
@ -200,6 +220,7 @@ public class Androlib {
|
||||
buildResources(appDir, flags,
|
||||
(Map<String, Object>) meta.get("usesFramework"));
|
||||
buildLib(appDir, flags);
|
||||
buildCopyOriginalFiles(appDir, flags);
|
||||
buildApk(appDir, outFile, flags);
|
||||
}
|
||||
|
||||
@ -424,6 +445,29 @@ public class Androlib {
|
||||
}
|
||||
}
|
||||
|
||||
public void buildCopyOriginalFiles(File appDir,
|
||||
HashMap<String, Boolean> flags) throws AndrolibException {
|
||||
if (flags.get("copyOriginal")) {
|
||||
File originalDir = new File(appDir, "original");
|
||||
if(originalDir.exists()) {
|
||||
try {
|
||||
LOGGER.info("Copy original files...");
|
||||
Directory in = (new ExtFile(originalDir)).getDirectory();
|
||||
if(in.containsFile("AndroidManifest.xml")) {
|
||||
LOGGER.info("Copy AndroidManifest.xml...");
|
||||
in.copyToDir(new File(appDir, APK_DIRNAME), "AndroidManifest.xml");
|
||||
}
|
||||
if (in.containsDir("META-INF")) {
|
||||
LOGGER.info("Copy META-INF...");
|
||||
in.copyToDir(new File(appDir, APK_DIRNAME), "META-INF");
|
||||
}
|
||||
} catch (DirectoryException ex) {
|
||||
throw new AndrolibException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void buildApk(File appDir, File outApk,
|
||||
HashMap<String, Boolean> flags) throws AndrolibException {
|
||||
LOGGER.info("Building apk file...");
|
||||
@ -514,16 +558,11 @@ public class Androlib {
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
public void setApkFile(File apkFile) {
|
||||
mOrigApkFile = new ExtFile(apkFile);
|
||||
}
|
||||
|
||||
public void setFrameworkFolder(String path) {
|
||||
mAndRes.setFrameworkFolder(path);
|
||||
}
|
||||
|
||||
private ExtFile mOrigApkFile = null;
|
||||
private String mAaptPath = null;
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(Androlib.class
|
||||
|
@ -133,6 +133,7 @@ public class ApkDecoder {
|
||||
}
|
||||
|
||||
mAndrolib.decodeRawFiles(mApkFile, outDir);
|
||||
mAndrolib.writeOriginalFiles(mApkFile, outDir);
|
||||
writeMetaFile();
|
||||
}
|
||||
|
||||
|
@ -184,6 +184,7 @@ public class BuildAndDecodeTest {
|
||||
tmp.put("verbose", false);
|
||||
tmp.put("framework", false);
|
||||
tmp.put("update", false);
|
||||
tmp.put("copyOriginal", false);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user