Commit b55975a3 authored by Skylot's avatar Skylot

core: reformat code and fix small issues in BinaryXMLParser

parent 4cb34394
...@@ -41,7 +41,6 @@ subprojects { ...@@ -41,7 +41,6 @@ subprojects {
} }
dependencies { dependencies {
compile 'com.google.android:android:4.1.1.4'
compile 'org.slf4j:slf4j-api:1.7.7' compile 'org.slf4j:slf4j-api:1.7.7'
testCompile 'ch.qos.logback:logback-classic:1.1.2' testCompile 'ch.qos.logback:logback-classic:1.1.2'
......
...@@ -8,17 +8,10 @@ import java.io.File; ...@@ -8,17 +8,10 @@ import java.io.File;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
//import jadx.core.xmlgen.BinaryXMLParser;
public class JadxCLI { public class JadxCLI {
private static final Logger LOG = LoggerFactory.getLogger(JadxCLI.class); private static final Logger LOG = LoggerFactory.getLogger(JadxCLI.class);
public static void main(String[] args) throws JadxException { public static void main(String[] args) throws JadxException {
/*
BinaryXMLParser bxp = new BinaryXMLParser(args[0],args[1]);
bxp.parse();
System.exit(4);
*/
try { try {
JadxCLIArgs jadxArgs = new JadxCLIArgs(); JadxCLIArgs jadxArgs = new JadxCLIArgs();
if (processArgs(jadxArgs, args)) { if (processArgs(jadxArgs, args)) {
......
...@@ -47,7 +47,7 @@ public final class JadxCLIArgs implements IJadxArgs { ...@@ -47,7 +47,7 @@ public final class JadxCLIArgs implements IJadxArgs {
@Parameter(names = {"-h", "--help"}, description = "print this help", help = true) @Parameter(names = {"-h", "--help"}, description = "print this help", help = true)
protected boolean printHelp = false; protected boolean printHelp = false;
@Parameter(names = {"-x", "--xml"}, description = "try to decode the AndroidManifest.xml, save at current dir") @Parameter(names = {"-x", "--xml"}, description = "try to decode the AndroidManifest.xml")
protected boolean xmlTest = false; protected boolean xmlTest = false;
private final List<File> input = new ArrayList<File>(1); private final List<File> input = new ArrayList<File>(1);
......
...@@ -203,14 +203,17 @@ public final class JadxDecompiler { ...@@ -203,14 +203,17 @@ public final class JadxDecompiler {
reset(); reset();
root = new RootNode(); root = new RootNode();
LOG.info("loading ..."); LOG.info("loading ...");
if(this.args.isXMLTest()) { if (this.args.isXMLTest()) {
InputFile inf = inputFiles.get(0); InputFile inf = inputFiles.get(0);
try { try {
BinaryXMLParser bxp = new BinaryXMLParser(InputFile.loadXMLBuffer(inf.getFile()), "./AndroidManifest.xml"); byte[] buffer = InputFile.loadXMLBuffer(inf.getFile());
//BinaryXMLParser bxp = new BinaryXMLParser(InputFile.loadXMLBuffer(inf.getFile()), "AndroidManifest.xml"); if (buffer != null) {
bxp.parse(); File out = new File(args.getOutDir(), "AndroidManifest.xml");
} catch(IOException ioe) { BinaryXMLParser bxp = new BinaryXMLParser();
LOG.info("Decompiling AndroidManifest.xml failed!"); bxp.parse(buffer, out);
}
} catch (Exception e) {
LOG.info("Decompiling AndroidManifest.xml failed!", e);
} }
} }
root.load(inputFiles); root.load(inputFiles);
......
...@@ -77,7 +77,7 @@ public class InputFile { ...@@ -77,7 +77,7 @@ public class InputFile {
public static byte[] loadXMLBuffer(File file) throws IOException { // FIXME: Public.. Please fix public static byte[] loadXMLBuffer(File file) throws IOException { // FIXME: Public.. Please fix
ZipFile zf = new ZipFile(file); ZipFile zf = new ZipFile(file);
ZipEntry xml = zf.getEntry("AndroidManifest.xml"); ZipEntry xml = zf.getEntry("AndroidManifest.xml");
if(null == xml) { if (xml == null) {
zf.close(); zf.close();
return null; return null;
} }
...@@ -91,7 +91,9 @@ public class InputFile { ...@@ -91,7 +91,9 @@ public class InputFile {
bytesOut.write(buffer, 0, count); bytesOut.write(buffer, 0, count);
} }
} finally { } finally {
if(null != in) in.close(); if (null != in) {
in.close();
}
zf.close(); zf.close();
} }
return bytesOut.toByteArray(); return bytesOut.toByteArray();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment