[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 #409) - Fixed array items incorrectly typed.
-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 non-URI standard characters in apk name (Thanks rover12421)
-Added output to list Apktool version to help debugging.

View File

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

View File

@ -90,22 +90,9 @@ public class ApkDecoder {
LOGGER.info("Using Apktool " + Androlib.getVersion() + " on " + mApkFile.getName());
if (hasResources()) {
Map<String, String> sdkInfo = mAndrolib.getResTable(mApkFile).getSdkInfo();
if (sdkInfo.get("targetSdkVersion") != null) {
mApi = Integer.parseInt(sdkInfo.get("targetSdkVersion"));
}
setTargetSdkVersion();
setAnalysisMode(mAnalysisMode, true);
// 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();
setCompressionMode();
switch (mDecodeResources) {
case DECODE_RESOURCES_NONE:
@ -174,8 +161,7 @@ public class ApkDecoder {
}
public void setDecodeSources(short mode) throws AndrolibException {
if (mode != DECODE_SOURCES_NONE && mode != DECODE_SOURCES_SMALI
&& mode != DECODE_SOURCES_JAVA) {
if (mode != DECODE_SOURCES_NONE && mode != DECODE_SOURCES_SMALI && mode != DECODE_SOURCES_JAVA) {
throw new AndrolibException("Invalid decode sources mode: " + 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) {
mDebugLinePrefix = debugLinePrefix;
}
@ -235,7 +240,7 @@ public class ApkDecoder {
if (mResTable == null) {
boolean hasResources = hasResources();
boolean hasManifest = hasManifest();
if (!(hasManifest || hasResources)) {
if (! (hasManifest || hasResources)) {
throw new AndrolibException(
"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);
for (String file : files) {
if (file.endsWith(".dex")) {
if ( ! file.equalsIgnoreCase("classes.dex")) {
if (! file.equalsIgnoreCase("classes.dex")) {
return true;
}
}
@ -320,8 +325,7 @@ public class ApkDecoder {
mAndrolib.writeMetaFile(mOutDir, meta);
}
private void putUsesFramework(Map<String, Object> meta)
throws AndrolibException {
private void putUsesFramework(Map<String, Object> meta) throws AndrolibException {
Set<ResPackage> pkgs = getResTable().listFramePackages();
if (pkgs.isEmpty()) {
return;
@ -344,16 +348,14 @@ public class ApkDecoder {
meta.put("usesFramework", uses);
}
private void putSdkInfo(Map<String, Object> meta)
throws AndrolibException {
private void putSdkInfo(Map<String, Object> meta) throws AndrolibException {
Map<String, String> info = getResTable().getSdkInfo();
if (info.size() > 0) {
meta.put("sdkInfo", info);
}
}
private void putPackageInfo(Map<String, Object> meta)
throws AndrolibException {
private void putPackageInfo(Map<String, Object> meta) throws AndrolibException {
String renamed = getResTable().getPackageRenamed();
String original = getResTable().getPackageOriginal();
int id = getResTable().getPackageId();
@ -368,24 +370,21 @@ public class ApkDecoder {
meta.put("packageInfo", packages);
}
private void putVersionInfo(Map<String, Object> meta)
throws AndrolibException {
private void putVersionInfo(Map<String, Object> meta) throws AndrolibException {
Map<String, String> info = getResTable().getVersionInfo();
if (info.size() > 0) {
meta.put("versionInfo", info);
}
}
private void putUnknownInfo(Map<String, Object> meta)
throws AndrolibException {
private void putUnknownInfo(Map<String, Object> meta) throws AndrolibException {
Map<String,String> info = mAndrolib.mResUnknownFiles.getUnknownFiles();
if (info.size() > 0) {
meta.put("unknownFiles", info);
}
}
private void putCompressionInfo(Map<String, Object> meta)
throws AndrolibException {
private void putCompressionInfo(Map<String, Object> meta) throws AndrolibException {
meta.put("compressionType", getCompressionType());
}
@ -402,14 +401,14 @@ public class ApkDecoder {
private ResTable mResTable;
private short mDecodeSources = DECODE_SOURCES_SMALI;
private short mDecodeResources = DECODE_RESOURCES_FULL;
private boolean mDebug = false;
private String mDebugLinePrefix = "a=0;// ";
private boolean mForceDelete = false;
private String mFrameTag;
private boolean mKeepBrokenResources = false;
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 mCompressResources = false;
private boolean mAnalysisMode = false;
private int mApi = 15;
}