Commit 2ab7524e authored by Skylot's avatar Skylot

core: better args class

parent d55969bc
package jadx.api;
import java.io.File;
public class DefaultJadxArgs implements IJadxArgs {
@Override
public File getOutDir() {
return new File("jadx-output");
}
@Override
public int getThreadsCount() {
return Runtime.getRuntime().availableProcessors();
}
@Override
public boolean isCFGOutput() {
return false;
}
@Override
public boolean isRawCFGOutput() {
return false;
}
@Override
public boolean isFallbackMode() {
return false;
}
@Override
public boolean isShowInconsistentCode() {
return false;
}
@Override
public boolean isVerbose() {
return false;
}
@Override
public boolean isSkipResources() {
return false;
}
@Override
public boolean isSkipSources() {
return false;
}
@Override
public boolean isDeobfuscationOn() {
return false;
}
@Override
public int getDeobfuscationMinLength() {
return Integer.MIN_VALUE + 1;
}
@Override
public int getDeobfuscationMaxLength() {
return Integer.MAX_VALUE - 1;
}
@Override
public boolean isDeobfuscationForceSave() {
return false;
}
@Override
public boolean useSourceNameAsClassAlias() {
return false;
}
}
package jadx.api;
import java.io.File;
public class JadxArgs implements IJadxArgs {
private File outDir = new File("jadx-output");
private int threadsCount = Math.max(1, Runtime.getRuntime().availableProcessors() - 1);
private boolean cfgOutput = false;
private boolean rawCFGOutput = false;
private boolean isVerbose = false;
private boolean fallbackMode = false;
private boolean showInconsistentCode = false;
private boolean isSkipResources = false;
private boolean isSkipSources = false;
private boolean isDeobfuscationOn = false;
private boolean isDeobfuscationForceSave = false;
private boolean useSourceNameAsClassAlias = false;
private int deobfuscationMinLength = 0;
private int deobfuscationMaxLength = Integer.MAX_VALUE;
@Override
public File getOutDir() {
return outDir;
}
public void setOutDir(File outDir) {
this.outDir = outDir;
}
@Override
public int getThreadsCount() {
return threadsCount;
}
public void setThreadsCount(int threadsCount) {
this.threadsCount = threadsCount;
}
@Override
public boolean isCFGOutput() {
return cfgOutput;
}
public void setCfgOutput(boolean cfgOutput) {
this.cfgOutput = cfgOutput;
}
@Override
public boolean isRawCFGOutput() {
return rawCFGOutput;
}
public void setRawCFGOutput(boolean rawCFGOutput) {
this.rawCFGOutput = rawCFGOutput;
}
@Override
public boolean isFallbackMode() {
return fallbackMode;
}
public void setFallbackMode(boolean fallbackMode) {
this.fallbackMode = fallbackMode;
}
@Override
public boolean isShowInconsistentCode() {
return showInconsistentCode;
}
public void setShowInconsistentCode(boolean showInconsistentCode) {
this.showInconsistentCode = showInconsistentCode;
}
@Override
public boolean isVerbose() {
return isVerbose;
}
public void setVerbose(boolean verbose) {
isVerbose = verbose;
}
@Override
public boolean isSkipResources() {
return isSkipResources;
}
public void setSkipResources(boolean skipResources) {
isSkipResources = skipResources;
}
@Override
public boolean isSkipSources() {
return isSkipSources;
}
public void setSkipSources(boolean skipSources) {
isSkipSources = skipSources;
}
@Override
public boolean isDeobfuscationOn() {
return isDeobfuscationOn;
}
public void setDeobfuscationOn(boolean deobfuscationOn) {
isDeobfuscationOn = deobfuscationOn;
}
@Override
public boolean isDeobfuscationForceSave() {
return isDeobfuscationForceSave;
}
public void setDeobfuscationForceSave(boolean deobfuscationForceSave) {
isDeobfuscationForceSave = deobfuscationForceSave;
}
@Override
public boolean useSourceNameAsClassAlias() {
return useSourceNameAsClassAlias;
}
public void setUseSourceNameAsClassAlias(boolean useSourceNameAsClassAlias) {
this.useSourceNameAsClassAlias = useSourceNameAsClassAlias;
}
@Override
public int getDeobfuscationMinLength() {
return deobfuscationMinLength;
}
public void setDeobfuscationMinLength(int deobfuscationMinLength) {
this.deobfuscationMinLength = deobfuscationMinLength;
}
@Override
public int getDeobfuscationMaxLength() {
return deobfuscationMaxLength;
}
public void setDeobfuscationMaxLength(int deobfuscationMaxLength) {
this.deobfuscationMaxLength = deobfuscationMaxLength;
}
}
......@@ -69,7 +69,7 @@ public final class JadxDecompiler {
private Map<FieldNode, JavaField> fieldsMap = new HashMap<FieldNode, JavaField>();
public JadxDecompiler() {
this(new DefaultJadxArgs());
this(new JadxArgs());
}
public JadxDecompiler(IJadxArgs jadxArgs) {
......@@ -86,7 +86,7 @@ public final class JadxDecompiler {
void init() {
if (outDir == null) {
outDir = new DefaultJadxArgs().getOutDir();
outDir = new JadxArgs().getOutDir();
}
this.passes = Jadx.getPassesList(args, outDir);
this.codeGen = new CodeGen(args);
......
package jadx.core.clsp;
import jadx.api.DefaultJadxArgs;
import jadx.api.JadxArgs;
import jadx.core.dex.nodes.RootNode;
import jadx.core.utils.exceptions.DecodeException;
import jadx.core.utils.files.InputFile;
......@@ -43,7 +43,7 @@ public class ConvertToClsSet {
LOG.info("Loaded: {}", inputFile.getFile());
}
RootNode root = new RootNode(new DefaultJadxArgs());
RootNode root = new RootNode(new JadxArgs());
root.load(inputFiles);
ClsSet set = new ClsSet();
......
package jadx.tests.api;
import jadx.api.DefaultJadxArgs;
import jadx.api.IJadxArgs;
import jadx.api.JadxArgs;
import jadx.api.JadxDecompiler;
import jadx.api.JadxInternalAccess;
import jadx.core.Jadx;
......@@ -135,38 +136,15 @@ public abstract class IntegrationTest extends TestUtils {
assertThat(cls.getCode().toString(), not(containsString("inconsistent")));
}
private DefaultJadxArgs getArgs() {
return new DefaultJadxArgs() {
@Override
public boolean isCFGOutput() {
return outputCFG;
}
@Override
public boolean isRawCFGOutput() {
return outputCFG;
}
@Override
public boolean isFallbackMode() {
return isFallback;
}
@Override
public boolean isShowInconsistentCode() {
return true;
}
@Override
public int getThreadsCount() {
return 1;
}
@Override
public boolean isSkipResources() {
return true;
}
};
private IJadxArgs getArgs() {
JadxArgs args = new JadxArgs();
args.setCfgOutput(outputCFG);
args.setRawCFGOutput(outputCFG);
args.setFallbackMode(isFallback);
args.setShowInconsistentCode(true);
args.setThreadsCount(1);
args.setSkipResources(true);
return args;
}
private void runAutoCheck(String clsName) {
......
package jadx.tests.functional;
import jadx.api.DefaultJadxArgs;
import jadx.api.JadxArgs;
import jadx.core.Jadx;
import jadx.core.dex.visitors.IDexTreeVisitor;
import jadx.core.dex.visitors.JadxVisitor;
......@@ -24,7 +24,7 @@ public class JadxVisitorsOrderTest {
@Test
public void testOrder() {
List<IDexTreeVisitor> passes = Jadx.getPassesList(new DefaultJadxArgs(), new File("out"));
List<IDexTreeVisitor> passes = Jadx.getPassesList(new JadxArgs(), new File("out"));
List<String> errors = check(passes);
for (String str : errors) {
......
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