[skip] cs fixes, added changes to changelog

This commit is contained in:
Connor Tumbleson 2014-08-16 09:48:02 -05:00
parent a6ce26622d
commit b2b5eb5f01
3 changed files with 46 additions and 50 deletions

View File

@ -41,6 +41,7 @@ v2.0.0 (TBA)
-Fixed (issue #630) - Fixed handling renamed manifests with ("com.lge") -Fixed (issue #630) - Fixed handling renamed manifests with ("com.lge")
-Fixed (issue #409) - Fixed array items incorrectly typed. -Fixed (issue #409) - Fixed array items incorrectly typed.
-Fixed (issue #512) - Fixed AndroidManifest missing attributes. -Fixed (issue #512) - Fixed AndroidManifest missing attributes.
-Fixed issue with APKs with multiple dex files.
-Fixed issue with using Apktool without smali/baksmali for ApktoolProperties (Thanks teprrr) -Fixed issue with using Apktool without smali/baksmali for ApktoolProperties (Thanks teprrr)
-Fixed issue with non-URI standard characters in apk name (Thanks rover12421) -Fixed issue with non-URI standard characters in apk name (Thanks rover12421)
-Added output to list Apktool version to help debugging. -Added output to list Apktool version to help debugging.

View File

@ -164,7 +164,6 @@ public class Androlib {
if (!isAPKFileNames(file) && !file.endsWith(".dex")) { if (!isAPKFileNames(file) && !file.endsWith(".dex")) {
// copy file out of archive into special "unknown" folder // copy file out of archive into special "unknown" folder
// to be re-included on build
unk.copyToDir(unknownOut, file); unk.copyToDir(unknownOut, file);
try { try {
// ignore encryption // ignore encryption
@ -176,9 +175,7 @@ public class Androlib {
if (invZipFile != null) { if (invZipFile != null) {
mResUnknownFiles.addUnknownFileInfo(invZipFile.getName(), String.valueOf(invZipFile.getMethod())); mResUnknownFiles.addUnknownFileInfo(invZipFile.getName(), String.valueOf(invZipFile.getMethod()));
} }
} catch (NullPointerException ignored) { } catch (NullPointerException ignored) { }
}
} }
} }
apkZipFile.close(); apkZipFile.close();
@ -216,7 +213,6 @@ public class Androlib {
throws AndrolibException { throws AndrolibException {
DumperOptions options = new DumperOptions(); DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
// options.setIndent(4);
Yaml yaml = new Yaml(options); Yaml yaml = new Yaml(options);
Writer writer = null; Writer writer = null;
@ -230,8 +226,7 @@ public class Androlib {
if (writer != null) { if (writer != null) {
try { try {
writer.close(); writer.close();
} catch (IOException ex) { } catch (IOException ex) { }
}
} }
} }
} }
@ -249,14 +244,12 @@ public class Androlib {
if (in != null) { if (in != null) {
try { try {
in.close(); in.close();
} catch (IOException ex) { } catch (IOException ex) { }
}
} }
} }
} }
public void build(File appDir, File outFile, HashMap<String, Boolean> flags, String aaptPath) public void build(File appDir, File outFile, HashMap<String, Boolean> flags, String aaptPath) throws BrutException {
throws BrutException {
build(new ExtFile(appDir), outFile, flags, aaptPath); build(new ExtFile(appDir), outFile, flags, aaptPath);
} }
@ -279,8 +272,7 @@ public class Androlib {
if (outFile == null) { if (outFile == null) {
String outFileName = (String) meta.get("apkFileName"); String outFileName = (String) meta.get("apkFileName");
outFile = new File(appDir, "dist" + File.separator outFile = new File(appDir, "dist" + File.separator + (outFileName == null ? "out.apk" : outFileName));
+ (outFileName == null ? "out.apk" : outFileName));
} }
new File(appDir, APK_DIRNAME).mkdirs(); new File(appDir, APK_DIRNAME).mkdirs();
@ -298,7 +290,9 @@ public class Androlib {
public void buildSources(File appDir, HashMap<String, Boolean> flags) public void buildSources(File appDir, HashMap<String, Boolean> flags)
throws AndrolibException { throws AndrolibException {
if (!buildSourcesRaw(appDir, "classes.dex", flags) && !buildSourcesSmali(appDir, "smali", "classes.dex", flags) && !buildSourcesJava(appDir, flags)) { if (!buildSourcesRaw(appDir, "classes.dex", flags)
&& !buildSourcesSmali(appDir, "smali", "classes.dex", flags)
&& !buildSourcesJava(appDir, flags)) {
LOGGER.warning("Could not find sources"); LOGGER.warning("Could not find sources");
} }
} }
@ -312,7 +306,9 @@ public class Androlib {
if (name.startsWith("smali_")) { if (name.startsWith("smali_")) {
String filename = name.substring(name.indexOf("_") + 1) + ".dex"; String filename = name.substring(name.indexOf("_") + 1) + ".dex";
if (!buildSourcesRaw(appDir, filename, flags) && !buildSourcesSmali(appDir, name, filename, flags) && !buildSourcesJava(appDir, flags)) { if (!buildSourcesRaw(appDir, filename, flags)
&& !buildSourcesSmali(appDir, name, filename, flags)
&& !buildSourcesJava(appDir, flags)) {
LOGGER.warning("Could not find sources"); LOGGER.warning("Could not find sources");
} }
} }

View File

@ -90,22 +90,9 @@ public class ApkDecoder {
LOGGER.info("Using Apktool " + Androlib.getVersion() + " on " + mApkFile.getName()); LOGGER.info("Using Apktool " + Androlib.getVersion() + " on " + mApkFile.getName());
if (hasResources()) { if (hasResources()) {
setTargetSdkVersion();
Map<String, String> sdkInfo = mAndrolib.getResTable(mApkFile).getSdkInfo();
if (sdkInfo.get("targetSdkVersion") != null) {
mApi = Integer.parseInt(sdkInfo.get("targetSdkVersion"));
}
setAnalysisMode(mAnalysisMode, true); setAnalysisMode(mAnalysisMode, true);
// read the resources.arsc checking for STORED vs DEFLATE setCompressionMode();
// this will determine whether we compress on rebuild or not.
ZipExtFile zef = new ZipExtFile(mApkFile.getAbsolutePath());
ZipArchiveEntry ze = zef.getEntry("resources.arsc");
if (ze != null) {
int compression = ze.getMethod();
mCompressResources = (compression == ZipEntry.DEFLATED);
}
zef.close();
switch (mDecodeResources) { switch (mDecodeResources) {
case DECODE_RESOURCES_NONE: case DECODE_RESOURCES_NONE:
@ -174,8 +161,7 @@ public class ApkDecoder {
} }
public void setDecodeSources(short mode) throws AndrolibException { public void setDecodeSources(short mode) throws AndrolibException {
if (mode != DECODE_SOURCES_NONE && mode != DECODE_SOURCES_SMALI if (mode != DECODE_SOURCES_NONE && mode != DECODE_SOURCES_SMALI && mode != DECODE_SOURCES_JAVA) {
&& mode != DECODE_SOURCES_JAVA) {
throw new AndrolibException("Invalid decode sources mode: " + mode); throw new AndrolibException("Invalid decode sources mode: " + mode);
} }
mDecodeSources = mode; mDecodeSources = mode;
@ -204,6 +190,25 @@ public class ApkDecoder {
} }
} }
public void setCompressionMode() throws AndrolibException, IOException {
// read the resources.arsc checking for STORED vs DEFLATE
// this will determine whether we compress on rebuild or not.
ZipExtFile zef = new ZipExtFile(mApkFile.getAbsolutePath());
ZipArchiveEntry ze = zef.getEntry("resources.arsc");
if (ze != null) {
int compression = ze.getMethod();
mCompressResources = (compression == ZipEntry.DEFLATED);
}
zef.close();
}
public void setTargetSdkVersion() throws AndrolibException, IOException {
Map<String, String> sdkInfo = mAndrolib.getResTable(mApkFile).getSdkInfo();
if (sdkInfo.get("targetSdkVersion") != null) {
mApi = Integer.parseInt(sdkInfo.get("targetSdkVersion"));
}
}
public void setDebugLinePrefix(String debugLinePrefix) { public void setDebugLinePrefix(String debugLinePrefix) {
mDebugLinePrefix = debugLinePrefix; mDebugLinePrefix = debugLinePrefix;
} }
@ -235,7 +240,7 @@ public class ApkDecoder {
if (mResTable == null) { if (mResTable == null) {
boolean hasResources = hasResources(); boolean hasResources = hasResources();
boolean hasManifest = hasManifest(); boolean hasManifest = hasManifest();
if (!(hasManifest || hasResources)) { if (! (hasManifest || hasResources)) {
throw new AndrolibException( throw new AndrolibException(
"Apk doesn't contain either AndroidManifest.xml file or resources.arsc file"); "Apk doesn't contain either AndroidManifest.xml file or resources.arsc file");
} }
@ -260,7 +265,7 @@ public class ApkDecoder {
Set<String> files = mApkFile.getDirectory().getFiles(true); Set<String> files = mApkFile.getDirectory().getFiles(true);
for (String file : files) { for (String file : files) {
if (file.endsWith(".dex")) { if (file.endsWith(".dex")) {
if ( ! file.equalsIgnoreCase("classes.dex")) { if (! file.equalsIgnoreCase("classes.dex")) {
return true; return true;
} }
} }
@ -320,8 +325,7 @@ public class ApkDecoder {
mAndrolib.writeMetaFile(mOutDir, meta); mAndrolib.writeMetaFile(mOutDir, meta);
} }
private void putUsesFramework(Map<String, Object> meta) private void putUsesFramework(Map<String, Object> meta) throws AndrolibException {
throws AndrolibException {
Set<ResPackage> pkgs = getResTable().listFramePackages(); Set<ResPackage> pkgs = getResTable().listFramePackages();
if (pkgs.isEmpty()) { if (pkgs.isEmpty()) {
return; return;
@ -344,16 +348,14 @@ public class ApkDecoder {
meta.put("usesFramework", uses); meta.put("usesFramework", uses);
} }
private void putSdkInfo(Map<String, Object> meta) private void putSdkInfo(Map<String, Object> meta) throws AndrolibException {
throws AndrolibException {
Map<String, String> info = getResTable().getSdkInfo(); Map<String, String> info = getResTable().getSdkInfo();
if (info.size() > 0) { if (info.size() > 0) {
meta.put("sdkInfo", info); meta.put("sdkInfo", info);
} }
} }
private void putPackageInfo(Map<String, Object> meta) private void putPackageInfo(Map<String, Object> meta) throws AndrolibException {
throws AndrolibException {
String renamed = getResTable().getPackageRenamed(); String renamed = getResTable().getPackageRenamed();
String original = getResTable().getPackageOriginal(); String original = getResTable().getPackageOriginal();
int id = getResTable().getPackageId(); int id = getResTable().getPackageId();
@ -368,24 +370,21 @@ public class ApkDecoder {
meta.put("packageInfo", packages); meta.put("packageInfo", packages);
} }
private void putVersionInfo(Map<String, Object> meta) private void putVersionInfo(Map<String, Object> meta) throws AndrolibException {
throws AndrolibException {
Map<String, String> info = getResTable().getVersionInfo(); Map<String, String> info = getResTable().getVersionInfo();
if (info.size() > 0) { if (info.size() > 0) {
meta.put("versionInfo", info); meta.put("versionInfo", info);
} }
} }
private void putUnknownInfo(Map<String, Object> meta) private void putUnknownInfo(Map<String, Object> meta) throws AndrolibException {
throws AndrolibException {
Map<String,String> info = mAndrolib.mResUnknownFiles.getUnknownFiles(); Map<String,String> info = mAndrolib.mResUnknownFiles.getUnknownFiles();
if (info.size() > 0) { if (info.size() > 0) {
meta.put("unknownFiles", info); meta.put("unknownFiles", info);
} }
} }
private void putCompressionInfo(Map<String, Object> meta) private void putCompressionInfo(Map<String, Object> meta) throws AndrolibException {
throws AndrolibException {
meta.put("compressionType", getCompressionType()); meta.put("compressionType", getCompressionType());
} }
@ -402,14 +401,14 @@ public class ApkDecoder {
private ResTable mResTable; private ResTable mResTable;
private short mDecodeSources = DECODE_SOURCES_SMALI; private short mDecodeSources = DECODE_SOURCES_SMALI;
private short mDecodeResources = DECODE_RESOURCES_FULL; private short mDecodeResources = DECODE_RESOURCES_FULL;
private boolean mDebug = false;
private String mDebugLinePrefix = "a=0;// "; private String mDebugLinePrefix = "a=0;// ";
private boolean mForceDelete = false;
private String mFrameTag; private String mFrameTag;
private boolean mKeepBrokenResources = false;
private String mFrameworkDir = null; private String mFrameworkDir = null;
private int mApi = 15; private boolean mDebug = false;
private boolean mForceDelete = false;
private boolean mKeepBrokenResources = false;
private boolean mBakDeb = true; private boolean mBakDeb = true;
private boolean mCompressResources = false; private boolean mCompressResources = false;
private boolean mAnalysisMode = false; private boolean mAnalysisMode = false;
private int mApi = 15;
} }