Search in sources :

Example 11 with ResourceFile

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

the class RootNode method updateObfuscatedFiles.

private void updateObfuscatedFiles(ResTableParser parser, List<ResourceFile> resources) {
    if (args.isSkipResources()) {
        return;
    }
    long start = System.currentTimeMillis();
    int renamedCount = 0;
    ResourceStorage resStorage = parser.getResStorage();
    ValuesParser valuesParser = new ValuesParser(parser.getStrings(), resStorage.getResourcesNames());
    Map<String, ResourceEntry> entryNames = new HashMap<>();
    for (ResourceEntry resEntry : resStorage.getResources()) {
        String val = valuesParser.getSimpleValueString(resEntry);
        if (val != null) {
            entryNames.put(val, resEntry);
        }
    }
    for (ResourceFile resource : resources) {
        ResourceEntry resEntry = entryNames.get(resource.getOriginalName());
        if (resEntry != null) {
            resource.setAlias(resEntry);
            renamedCount++;
        }
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Renamed obfuscated resources: {}, duration: {}ms", renamedCount, System.currentTimeMillis() - start);
    }
}
Also used : ResourceFile(jadx.api.ResourceFile) ResourceEntry(jadx.core.xmlgen.entry.ResourceEntry) HashMap(java.util.HashMap) ResourceStorage(jadx.core.xmlgen.ResourceStorage) ValuesParser(jadx.core.xmlgen.entry.ValuesParser)

Aggregations

ResourceFile (jadx.api.ResourceFile)11 JResource (jadx.gui.treemodel.JResource)6 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)3 ResContainer (jadx.core.xmlgen.ResContainer)2 JNode (jadx.gui.treemodel.JNode)2 File (java.io.File)2 IOException (java.io.IOException)2 TreeNode (javax.swing.tree.TreeNode)2 Nullable (org.jetbrains.annotations.Nullable)2 ImageViewer (hu.kazocsaba.imageviewer.ImageViewer)1 ICodeWriter (jadx.api.ICodeWriter)1 JadxDecompiler (jadx.api.JadxDecompiler)1 ResourcesLoader (jadx.api.ResourcesLoader)1 RootNode (jadx.core.dex.nodes.RootNode)1 ExportGradleProject (jadx.core.export.ExportGradleProject)1 Utils (jadx.core.utils.Utils)1 JadxException (jadx.core.utils.exceptions.JadxException)1 ResTableParser (jadx.core.xmlgen.ResTableParser)1 ResourceStorage (jadx.core.xmlgen.ResourceStorage)1 ResourceEntry (jadx.core.xmlgen.entry.ResourceEntry)1