Search in sources :

Example 6 with ICodeInfo

use of jadx.api.ICodeInfo in project jadx by skylot.

the class ResXmlGen method makeResourcesXml.

public List<ResContainer> makeResourcesXml() {
    Map<String, ICodeWriter> contMap = new HashMap<>();
    for (ResourceEntry ri : resStorage.getResources()) {
        if (SKIP_RES_TYPES.contains(ri.getTypeName())) {
            continue;
        }
        String fn = getFileName(ri);
        ICodeWriter cw = contMap.get(fn);
        if (cw == null) {
            cw = new SimpleCodeWriter();
            cw.add("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            cw.startLine("<resources>");
            cw.incIndent();
            contMap.put(fn, cw);
        }
        addValue(cw, ri);
    }
    List<ResContainer> files = new ArrayList<>(contMap.size());
    for (Map.Entry<String, ICodeWriter> entry : contMap.entrySet()) {
        String fileName = entry.getKey();
        ICodeWriter content = entry.getValue();
        content.decIndent();
        content.startLine("</resources>");
        ICodeInfo codeInfo = content.finish();
        files.add(ResContainer.textResource(fileName, codeInfo));
    }
    Collections.sort(files);
    return files;
}
Also used : HashMap(java.util.HashMap) ResourceEntry(jadx.core.xmlgen.entry.ResourceEntry) SimpleCodeWriter(jadx.api.impl.SimpleCodeWriter) ArrayList(java.util.ArrayList) ICodeInfo(jadx.api.ICodeInfo) ICodeWriter(jadx.api.ICodeWriter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with ICodeInfo

use of jadx.api.ICodeInfo in project jadx by skylot.

the class IntegrationTest method decompileAndCheck.

protected void decompileAndCheck(List<ClassNode> clsList) {
    // keep error and warning attributes
    clsList.forEach(cls -> cls.add(AFlag.DONT_UNLOAD_CLASS));
    clsList.forEach(ClassNode::decompile);
    for (ClassNode cls : clsList) {
        System.out.println("-----------------------------------------------------------");
        ICodeInfo code = cls.getCode();
        if (printLineNumbers) {
            printCodeWithLineNumbers(code);
        } else if (printOffsets) {
            printCodeWithOffsets(code);
        } else {
            System.out.println(code);
        }
    }
    System.out.println("-----------------------------------------------------------");
    if (printDisassemble) {
        clsList.forEach(this::printDisasm);
    }
    runChecks(clsList);
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) ICodeInfo(jadx.api.ICodeInfo)

Example 8 with ICodeInfo

use of jadx.api.ICodeInfo in project jadx by skylot.

the class ExportGradleTest method createResourceContainer.

protected ResContainer createResourceContainer(String filename) {
    final ResContainer container = mock(ResContainer.class);
    ICodeInfo codeInfo = mock(ICodeInfo.class);
    when(codeInfo.getCodeStr()).thenReturn(loadFileContent(new File(MANIFEST_TESTS_DIR, filename)));
    when(container.getText()).thenReturn(codeInfo);
    return container;
}
Also used : ResContainer(jadx.core.xmlgen.ResContainer) ICodeInfo(jadx.api.ICodeInfo) ResourceFile(jadx.api.ResourceFile) File(java.io.File)

Example 9 with ICodeInfo

use of jadx.api.ICodeInfo in project jadx by skylot.

the class JadxClassNodeAssertions method decompile.

public JadxCodeInfoAssertions decompile() {
    isNotNull();
    ICodeInfo codeInfo = actual.getCode();
    Assertions.assertThat(codeInfo).isNotNull();
    return new JadxCodeInfoAssertions(codeInfo);
}
Also used : ICodeInfo(jadx.api.ICodeInfo)

Example 10 with ICodeInfo

use of jadx.api.ICodeInfo in project jadx by skylot.

the class CodePanel method canShowDebugLines.

private boolean canShowDebugLines() {
    ICodeInfo codeInfo = codeArea.getNode().getCodeInfo();
    if (codeInfo == null) {
        return false;
    }
    Map<Integer, Integer> lineMapping = codeInfo.getLineMapping();
    if (lineMapping.isEmpty()) {
        return false;
    }
    Set<Integer> uniqueDebugLines = new HashSet<>(lineMapping.values());
    return uniqueDebugLines.size() > 3;
}
Also used : ICodeInfo(jadx.api.ICodeInfo) HashSet(java.util.HashSet)

Aggregations

ICodeInfo (jadx.api.ICodeInfo)17 ClassNode (jadx.core.dex.nodes.ClassNode)3 ICodeCache (jadx.api.ICodeCache)2 ICodeWriter (jadx.api.ICodeWriter)2 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)2 ResContainer (jadx.core.xmlgen.ResContainer)2 ValuesParser (jadx.core.xmlgen.entry.ValuesParser)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Nullable (org.jetbrains.annotations.Nullable)2 Package (com.android.aapt.Resources.Package)1 ResourceTable (com.android.aapt.Resources.ResourceTable)1 CodePosition (jadx.api.CodePosition)1 JadxDecompiler (jadx.api.JadxDecompiler)1 ResourceFile (jadx.api.ResourceFile)1 ResourceFileContent (jadx.api.ResourceFileContent)1 InsnCodeOffset (jadx.api.data.annotations.InsnCodeOffset)1 SimpleCodeWriter (jadx.api.impl.SimpleCodeWriter)1 JsonCodeLine (jadx.core.codegen.json.cls.JsonCodeLine)1 AFlag (jadx.core.dex.attributes.AFlag)1