Fix « doNotCompress » in case of obfuscated resources.

This commit is contained in:
Kirlif 2022-11-07 14:06:22 +01:00
parent f8df056a2c
commit c4e8f88499
No known key found for this signature in database
3 changed files with 14 additions and 2 deletions

View File

@ -184,6 +184,9 @@ public class Androlib {
if (ext.isEmpty() || !NO_COMPRESS_PATTERN.matcher(ext).find()) { if (ext.isEmpty() || !NO_COMPRESS_PATTERN.matcher(ext).find()) {
ext = file; ext = file;
if (mAndRes.ObfFiles.containsKey(ext)) {
ext = mAndRes.ObfFiles.get(ext);
}
} }
if (!uncompressedFilesOrExts.contains(ext)) { if (!uncompressedFilesOrExts.contains(ext)) {
uncompressedFilesOrExts.add(ext); uncompressedFilesOrExts.add(ext);

View File

@ -247,7 +247,7 @@ final public class AndrolibResources {
LOGGER.info("Decoding file-resources..."); LOGGER.info("Decoding file-resources...");
for (ResResource res : pkg.listFiles()) { for (ResResource res : pkg.listFiles()) {
fileDecoder.decode(res, in, out); fileDecoder.decode(res, in, out, ObfFiles);
} }
LOGGER.info("Decoding values */* XMLs..."); LOGGER.info("Decoding values */* XMLs...");
@ -1041,6 +1041,8 @@ final public class AndrolibResources {
public BuildOptions buildOptions; public BuildOptions buildOptions;
public Map<String, String> ObfFiles = new HashMap();
// TODO: dirty static hack. I have to refactor decoding mechanisms. // TODO: dirty static hack. I have to refactor decoding mechanisms.
public static boolean sKeepBroken = false; public static boolean sKeepBroken = false;

View File

@ -27,6 +27,7 @@ import brut.directory.Directory;
import brut.directory.DirectoryException; import brut.directory.DirectoryException;
import java.io.*; import java.io.*;
import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -37,10 +38,11 @@ public class ResFileDecoder {
this.mDecoders = decoders; this.mDecoders = decoders;
} }
public void decode(ResResource res, Directory inDir, Directory outDir) public void decode(ResResource res, Directory inDir, Directory outDir, Map<String, String> obfFiles)
throws AndrolibException { throws AndrolibException {
ResFileValue fileValue = (ResFileValue) res.getValue(); ResFileValue fileValue = (ResFileValue) res.getValue();
String inFileFullName = fileValue.toString();
String inFileName = fileValue.getStrippedPath(); String inFileName = fileValue.getStrippedPath();
String outResName = res.getFilePath(); String outResName = res.getFilePath();
String typeName = res.getResSpec().getType().getName(); String typeName = res.getResSpec().getType().getName();
@ -55,6 +57,11 @@ public class ResFileDecoder {
outFileName = outResName + ext; outFileName = outResName + ext;
} }
String outFileFullName = "res/"+outFileName;
if (!inFileFullName.equals(outFileFullName)) {
obfFiles.put(inFileFullName, outFileFullName);
}
try { try {
if (typeName.equals("raw")) { if (typeName.equals("raw")) {
decode(inDir, inFileName, outDir, outFileName, "raw"); decode(inDir, inFileName, outDir, outFileName, "raw");