diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java index 4077ca6f..a36468ae 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java @@ -177,16 +177,19 @@ public class Androlib { for (String file : files) { if (isAPKFileNames(file) && unk.getCompressionLevel(file) == 0) { - String ext = ""; + String extOrFile = ""; if (unk.getSize(file) != 0) { - ext = FilenameUtils.getExtension(file); + extOrFile = FilenameUtils.getExtension(file); } - if (ext.isEmpty() || !NO_COMPRESS_PATTERN.matcher(ext).find()) { - ext = file; + if (extOrFile.isEmpty() || !NO_COMPRESS_PATTERN.matcher(extOrFile).find()) { + extOrFile = file; + if (mAndRes.mResFileMapping.containsKey(extOrFile)) { + extOrFile = mAndRes.mResFileMapping.get(extOrFile); + } } - if (!uncompressedFilesOrExts.contains(ext)) { - uncompressedFilesOrExts.add(ext); + if (!uncompressedFilesOrExts.contains(extOrFile)) { + uncompressedFilesOrExts.add(extOrFile); } } } diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java index 9ed36078..ded97b98 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java @@ -247,7 +247,7 @@ final public class AndrolibResources { LOGGER.info("Decoding file-resources..."); for (ResResource res : pkg.listFiles()) { - fileDecoder.decode(res, in, out); + fileDecoder.decode(res, in, out, mResFileMapping); } LOGGER.info("Decoding values */* XMLs..."); @@ -1046,6 +1046,8 @@ final public class AndrolibResources { public BuildOptions buildOptions; + public Map mResFileMapping = new HashMap(); + // TODO: dirty static hack. I have to refactor decoding mechanisms. public static boolean sKeepBroken = false; diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecoder.java index 7d32581d..75f67a8c 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResFileDecoder.java @@ -27,6 +27,7 @@ import brut.directory.Directory; import brut.directory.DirectoryException; import java.io.*; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -37,10 +38,11 @@ public class ResFileDecoder { this.mDecoders = decoders; } - public void decode(ResResource res, Directory inDir, Directory outDir) + public void decode(ResResource res, Directory inDir, Directory outDir, Map resFileMapping) throws AndrolibException { ResFileValue fileValue = (ResFileValue) res.getValue(); + String inFilePath = fileValue.toString(); String inFileName = fileValue.getStrippedPath(); String outResName = res.getFilePath(); String typeName = res.getResSpec().getType().getName(); @@ -55,6 +57,11 @@ public class ResFileDecoder { outFileName = outResName + ext; } + String outFilePath = "res/" + outFileName; + if (!inFilePath.equals(outFilePath)) { + resFileMapping.put(inFilePath, outFilePath); + } + try { if (typeName.equals("raw")) { decode(inDir, inFileName, outDir, outFileName, "raw");