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 cc98c0b5..0cf0a9ed 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 @@ -79,7 +79,7 @@ public class ResFileDecoder { // check for raw 9patch images for (String extension : RAW_9PATCH_IMAGE_EXTENSIONS) { if (inFileName.toLowerCase().endsWith("." + extension)) { - copyRaw(inDir, outDir, outFileName); + copyRaw(inDir, outDir, inFileName, outFileName); return; } } @@ -107,7 +107,7 @@ public class ResFileDecoder { // check for raw image for (String extension : RAW_IMAGE_EXTENSIONS) { if (inFileName.toLowerCase().endsWith("." + extension)) { - copyRaw(inDir, outDir, outFileName); + copyRaw(inDir, outDir, inFileName, outFileName); return; } } @@ -144,9 +144,10 @@ public class ResFileDecoder { } } - public void copyRaw(Directory inDir, Directory outDir, String filename) throws AndrolibException { + public void copyRaw(Directory inDir, Directory outDir, String inFilename, + String outFilename) throws AndrolibException { try { - DirUtil.copyToDir(inDir, outDir, filename); + DirUtil.copyToDir(inDir, outDir, inFilename, outFilename); } catch (DirectoryException ex) { throw new AndrolibException(ex); } @@ -168,6 +169,7 @@ public class ResFileDecoder { private final static String[] RAW_IMAGE_EXTENSIONS = new String[] { "m4a", // apple + "qmg", // samsung }; private final static String[] RAW_9PATCH_IMAGE_EXTENSIONS = new String[] { diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt2/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt2/BuildAndDecodeTest.java index f031f4da..9fd26ac0 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt2/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt2/BuildAndDecodeTest.java @@ -26,6 +26,7 @@ import org.junit.BeforeClass; import org.junit.Test; import java.io.File; +import java.io.IOException; import static org.junit.Assert.*; @@ -94,6 +95,11 @@ public class BuildAndDecodeTest extends BaseTest { compareXmlFiles("res/drawable/$avd_hide_password__0.xml"); } + @Test + public void samsungQmgFilesHandledTest() throws IOException, BrutException { + compareBinaryFolder("drawable-xhdpi", true); + } + @Test public void confirmManifestStructureTest() throws BrutException { compareXmlFiles("AndroidManifest.xml"); diff --git a/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/res/drawable-xhdpi/ic_launcher_samsung.qmg b/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/res/drawable-xhdpi/ic_launcher_samsung.qmg new file mode 100644 index 00000000..71c6d760 Binary files /dev/null and b/brut.apktool/apktool-lib/src/test/resources/aapt2/testapp/res/drawable-xhdpi/ic_launcher_samsung.qmg differ diff --git a/brut.j.dir/src/main/java/brut/directory/DirUtil.java b/brut.j.dir/src/main/java/brut/directory/DirUtil.java index 8108a525..ccd94614 100644 --- a/brut.j.dir/src/main/java/brut/directory/DirUtil.java +++ b/brut.j.dir/src/main/java/brut/directory/DirUtil.java @@ -41,17 +41,19 @@ public class DirUtil { public static void copyToDir(Directory in, Directory out, String fileName) throws DirectoryException { + copyToDir(in, out, fileName, fileName); + } + + public static void copyToDir(Directory in, Directory out, String inFile, String outFile) + throws DirectoryException { try { - if (in.containsDir(fileName)) { - // TODO: remove before copying - in.getDir(fileName).copyToDir(out.createDir(fileName)); + if (in.containsDir(inFile)) { + in.getDir(inFile).copyToDir(out.createDir(outFile)); } else { - BrutIO.copyAndClose(in.getFileInput(fileName), - out.getFileOutput(fileName)); + BrutIO.copyAndClose(in.getFileInput(inFile), out.getFileOutput(outFile)); } } catch (IOException ex) { - throw new DirectoryException( - "Error copying file: " + fileName, ex); + throw new DirectoryException("Error copying file: " + inFile, ex); } }