From now there is no need to use -s/-r switch, when apk doesn't contain sources/resources.

This commit is contained in:
Ryszard Wiśniewski 2010-06-01 14:06:13 +02:00
parent f07aae158a
commit 25ec196cfa
2 changed files with 35 additions and 26 deletions

View File

@ -53,10 +53,8 @@ public class Androlib {
LOGGER.warning("Debug mode not available."); LOGGER.warning("Debug mode not available.");
} }
Directory apk = apkFile.getDirectory(); Directory apk = apkFile.getDirectory();
if (apk.containsFile("classes.dex")) { LOGGER.info("Copying raw classes.dex file...");
LOGGER.info("Copying raw classes.dex file..."); apkFile.getDirectory().copyToDir(outDir, "classes.dex");
apkFile.getDirectory().copyToDir(outDir, "classes.dex");
}
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
throw new AndrolibException(ex); throw new AndrolibException(ex);
} }
@ -85,11 +83,8 @@ public class Androlib {
throws AndrolibException { throws AndrolibException {
try { try {
Directory apk = apkFile.getDirectory(); Directory apk = apkFile.getDirectory();
if (apk.containsFile("resources.arsc")) { LOGGER.info("Copying raw resources...");
LOGGER.info("Copying raw resources..."); apkFile.getDirectory().copyToDir(outDir, APK_RESOURCES_FILENAMES);
apkFile.getDirectory().copyToDir(
outDir, APK_RESOURCES_FILENAMES);
}
} catch (DirectoryException ex) { } catch (DirectoryException ex) {
throw new AndrolibException(ex); throw new AndrolibException(ex);
} }

View File

@ -19,6 +19,8 @@ package brut.androlib;
import brut.androlib.res.data.ResTable; import brut.androlib.res.data.ResTable;
import brut.androlib.res.util.ExtFile; import brut.androlib.res.util.ExtFile;
import brut.common.BrutException; import brut.common.BrutException;
import brut.directory.Directory;
import brut.directory.DirectoryException;
import brut.util.OS; import brut.util.OS;
import java.io.File; import java.io.File;
@ -61,24 +63,36 @@ public class ApkDecoder {
} }
outDir.mkdirs(); outDir.mkdirs();
switch (mDecodeSources) { Directory apk = null;
case DECODE_SOURCES_NONE: try {
mAndrolib.decodeSourcesRaw(mApkFile, outDir, mDebug); apk = mApkFile.getDirectory();
break; } catch (DirectoryException ex) {
case DECODE_SOURCES_SMALI: throw new AndrolibException(ex);
mAndrolib.decodeSourcesSmali(mApkFile, outDir, mDebug);
break;
case DECODE_SOURCES_JAVA:
mAndrolib.decodeSourcesJava(mApkFile, outDir, mDebug);
break;
} }
switch (mDecodeResources) {
case DECODE_RESOURCES_NONE: if (apk.containsFile("classes.dex")) {
mAndrolib.decodeResourcesRaw(mApkFile, outDir); switch (mDecodeSources) {
break; case DECODE_SOURCES_NONE:
case DECODE_RESOURCES_FULL: mAndrolib.decodeSourcesRaw(mApkFile, outDir, mDebug);
mAndrolib.decodeResourcesFull(mApkFile, outDir, getResTable()); break;
break; case DECODE_SOURCES_SMALI:
mAndrolib.decodeSourcesSmali(mApkFile, outDir, mDebug);
break;
case DECODE_SOURCES_JAVA:
mAndrolib.decodeSourcesJava(mApkFile, outDir, mDebug);
break;
}
}
if (apk.containsFile("resources.arsc")) {
switch (mDecodeResources) {
case DECODE_RESOURCES_NONE:
mAndrolib.decodeResourcesRaw(mApkFile, outDir);
break;
case DECODE_RESOURCES_FULL:
mAndrolib.decodeResourcesFull(mApkFile, outDir,
getResTable());
break;
}
} }
mAndrolib.decodeRawFiles(mApkFile, outDir); mAndrolib.decodeRawFiles(mApkFile, outDir);
} }