adding parameter -o, pass apk file name as original

This commit is contained in:
Connor Tumbleson 2012-09-17 17:49:36 -05:00
parent bc10186af0
commit 53e7ffd9a2
3 changed files with 31 additions and 8 deletions

View File

@ -164,19 +164,27 @@ public class Main {
flags.put("update", false);
int i;
int skip = 0;
File mOrigApk = null;
for (i = 0; i < args.length; i++) {
String opt = args[i];
if (! opt.startsWith("-")) {
break;
}
if ("-f".equals(opt) || "--force-all".equals(opt)) {
flags.put("forceBuildA", true);
flags.put("forceBuildAll", true);
} else if ("-d".equals(opt) || "--debug".equals(opt)) {
flags.put("debug", true);
} else if ("-v".equals(opt) || "--verbose".equals(opt)) {
flags.put("verbose", true);
} else if("-o".equals(opt) || "--original".equals(opt)) {
flags.put("injectOriginal", true);
} else if ("-o".equals(opt) || "--original".equals(opt)) {
if (args.length >= 4) {
throw new InvalidArgsError();
} else {
flags.put("injectOriginal", true);
mOrigApk = new File(args[i + 1]);
skip = 1;
}
} else {
throw new InvalidArgsError();
}
@ -184,19 +192,19 @@ public class Main {
String appDirName;
File outFile = null;
switch (args.length - i) {
switch (args.length - i - skip) {
case 0:
appDirName = ".";
break;
case 2:
outFile = new File(args[i + 1]);
outFile = new File(args[i + 1 + skip]);
case 1:
appDirName = args[i];
appDirName = args[i + skip];
break;
default:
throw new InvalidArgsError();
}
new Androlib().build(new File(appDirName), outFile, flags);
}

View File

@ -16,6 +16,7 @@
package brut.androlib;
import brut.androlib.err.InFileNotFoundException;
import brut.androlib.java.AndrolibJava;
import brut.androlib.res.AndrolibResources;
import brut.androlib.res.data.ResPackage;
@ -435,6 +436,13 @@ public class Androlib {
}
mAndRes.aaptPackage(outApk, null, null,
new File(appDir, APK_DIRNAME), assetDir, null, flags);
/* check for re-insert */
if (flags.get("injectOriginal")) {
// if (!mApkFile.isFile() || !mApkFile.canRead()) {
// throw new InFileNotFoundException();
//}
}
}
public void publicizeResources(File arscFile) throws AndrolibException {
@ -508,7 +516,14 @@ public class Androlib {
}
return files;
}
public void setApkFile(File apkFile) {
mOrigApkFile = new ExtFile(apkFile);
}
private ExtFile mOrigApkFile;
private final static Logger LOGGER =
Logger.getLogger(Androlib.class.getName());

View File

@ -53,7 +53,7 @@ public class ApkDecoder {
mApkFile = new ExtFile(apkFile);
mResTable = null;
}
public void setOutDir(File outDir) throws AndrolibException {
mOutDir = outDir;
}