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 ded97b98..9f2499e3 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 @@ -221,22 +221,12 @@ final public class AndrolibResources { ResAttrDecoder attrDecoder = duo.m2.getAttrDecoder(); attrDecoder.setCurrentPackage(resTable.listMainPackages().iterator().next()); - Directory inApk, in = null, out; + Directory in, out; try { out = new FileDirectory(outDir); - - inApk = apkFile.getDirectory(); + in = apkFile.getDirectory(); out = out.createDir("res"); - if (inApk.containsDir("res")) { - in = inApk.getDir("res"); - } - if (in == null && inApk.containsDir("r")) { - in = inApk.getDir("r"); - } - if (in == null && inApk.containsDir("R")) { - in = inApk.getDir("R"); - } } catch (DirectoryException ex) { throw new AndrolibException(ex); } 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 75f67a8c..a3174411 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 @@ -64,11 +64,11 @@ public class ResFileDecoder { try { if (typeName.equals("raw")) { - decode(inDir, inFileName, outDir, outFileName, "raw"); + decode(inDir, inFilePath, outDir, outFileName, "raw"); return; } if (typeName.equals("font") && !".xml".equals(ext)) { - decode(inDir, inFileName, outDir, outFileName, "raw"); + decode(inDir, inFilePath, outDir, outFileName, "raw"); return; } if (typeName.equals("drawable") || typeName.equals("mipmap")) { @@ -83,26 +83,24 @@ public class ResFileDecoder { // check for raw 9patch images for (String extension : RAW_9PATCH_IMAGE_EXTENSIONS) { if (inFileName.toLowerCase().endsWith("." + extension)) { - copyRaw(inDir, outDir, inFileName, outFileName); + copyRaw(inDir, outDir, inFilePath, outFileName); return; } } // check for xml 9 patches which are just xml files if (inFileName.toLowerCase().endsWith(".xml")) { - decode(inDir, inFileName, outDir, outFileName, "xml"); + decode(inDir, inFilePath, outDir, outFileName, "xml"); return; } try { - decode(inDir, inFileName, outDir, outFileName, "9patch"); + decode(inDir, inFilePath, outDir, outFileName, "9patch"); return; } catch (CantFind9PatchChunkException ex) { - LOGGER.log( - Level.WARNING, - String.format( - "Cant find 9patch chunk in file: \"%s\". Renaming it to *.png.", - inFileName), ex); + LOGGER.log(Level.WARNING, String.format( + "Cant find 9patch chunk in file: \"%s\". Renaming it to *.png.", inFileName + ), ex); outDir.removeFile(outFileName); outFileName = outResName + ext; } @@ -111,27 +109,27 @@ public class ResFileDecoder { // check for raw image for (String extension : RAW_IMAGE_EXTENSIONS) { if (inFileName.toLowerCase().endsWith("." + extension)) { - copyRaw(inDir, outDir, inFileName, outFileName); + copyRaw(inDir, outDir, inFilePath, outFileName); return; } } if (!".xml".equals(ext)) { - decode(inDir, inFileName, outDir, outFileName, "raw"); + decode(inDir, inFilePath, outDir, outFileName, "raw"); return; } } - decode(inDir, inFileName, outDir, outFileName, "xml"); + decode(inDir, inFilePath, outDir, outFileName, "xml"); } catch (RawXmlEncounteredException ex) { // If we got an error to decode XML, lets assume the file is in raw format. // This is a large assumption, that might increase runtime, but will save us for situations where // XSD files are AXML`d on aapt1, but left in plaintext in aapt2. - decode(inDir, inFileName, outDir, outFileName, "raw"); + decode(inDir, inFilePath, outDir, outFileName, "raw"); } catch (AndrolibException ex) { LOGGER.log(Level.SEVERE, String.format( - "Could not decode file, replacing by FALSE value: %s", - inFileName), ex); + "Could not decode file, replacing by FALSE value: %s", + inFileName), ex); res.replace(new ResBoolValue(false, 0, null)); } }