mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-25 02:52:09 +02:00
Issue 2943 - Support raw disassembly w/ AndResGuard (#2944)
* fix: allow copying r/R if in raw mode * test: assert raw files disassembled from AndResGuard
This commit is contained in:
parent
e32309c96f
commit
35ce8fc061
@ -842,7 +842,7 @@ public class Androlib {
|
|||||||
private final static String APK_DIRNAME = "build/apk";
|
private final static String APK_DIRNAME = "build/apk";
|
||||||
private final static String UNK_DIRNAME = "unknown";
|
private final static String UNK_DIRNAME = "unknown";
|
||||||
private final static String[] APK_RESOURCES_FILENAMES = new String[] {
|
private final static String[] APK_RESOURCES_FILENAMES = new String[] {
|
||||||
"resources.arsc", "AndroidManifest.xml", "res" };
|
"resources.arsc", "AndroidManifest.xml", "res", "r", "R" };
|
||||||
private final static String[] APK_RESOURCES_WITHOUT_RES_FILENAMES = new String[] {
|
private final static String[] APK_RESOURCES_WITHOUT_RES_FILENAMES = new String[] {
|
||||||
"resources.arsc", "AndroidManifest.xml" };
|
"resources.arsc", "AndroidManifest.xml" };
|
||||||
private final static String[] APP_RESOURCES_FILENAMES = new String[] {
|
private final static String[] APP_RESOURCES_FILENAMES = new String[] {
|
||||||
|
@ -56,4 +56,18 @@ public class AndResGuardTest extends BaseTest {
|
|||||||
File aPng = new File(sTestOrigDir,"res/mipmap-hdpi-v4/a.png");
|
File aPng = new File(sTestOrigDir,"res/mipmap-hdpi-v4/a.png");
|
||||||
assertTrue(aPng.isFile());
|
assertTrue(aPng.isFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkifAndResDecodeRemapsRFolderInRawMode() throws BrutException, IOException {
|
||||||
|
String apk = "issue1170.apk";
|
||||||
|
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk));
|
||||||
|
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".raw.out");
|
||||||
|
|
||||||
|
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".raw.out"));
|
||||||
|
apkDecoder.setDecodeResources(ApkDecoder.DECODE_RESOURCES_NONE);
|
||||||
|
apkDecoder.decode();
|
||||||
|
|
||||||
|
File aPng = new File(sTestOrigDir,"r/a/a.png");
|
||||||
|
assertTrue(aPng.isFile());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import brut.common.TraversalUnknownFileException;
|
|||||||
import brut.util.BrutIO;
|
import brut.util.BrutIO;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class DirUtil {
|
public class DirUtil {
|
||||||
@ -84,14 +85,13 @@ public class DirUtil {
|
|||||||
if (in.containsDir(fileName)) {
|
if (in.containsDir(fileName)) {
|
||||||
OS.rmdir(new File(out, fileName));
|
OS.rmdir(new File(out, fileName));
|
||||||
in.getDir(fileName).copyToDir(new File(out, fileName));
|
in.getDir(fileName).copyToDir(new File(out, fileName));
|
||||||
|
} else if (!in.containsDir(fileName) && !in.containsFile(fileName)) {
|
||||||
|
// Skip copies of directories/files not found.
|
||||||
} else {
|
} else {
|
||||||
if (fileName.equals("res") && !in.containsFile(fileName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String cleanedFilename = BrutIO.sanitizeUnknownFile(out, fileName);
|
String cleanedFilename = BrutIO.sanitizeUnknownFile(out, fileName);
|
||||||
File outFile = new File(out, cleanedFilename);
|
File outFile = new File(out, cleanedFilename);
|
||||||
outFile.getParentFile().mkdirs();
|
outFile.getParentFile().mkdirs();
|
||||||
BrutIO.copyAndClose(in.getFileInput(fileName), new FileOutputStream(outFile));
|
BrutIO.copyAndClose(in.getFileInput(fileName), Files.newOutputStream(outFile.toPath()));
|
||||||
}
|
}
|
||||||
} catch (RootUnknownFileException | InvalidUnknownFileException | TraversalUnknownFileException exception) {
|
} catch (RootUnknownFileException | InvalidUnknownFileException | TraversalUnknownFileException exception) {
|
||||||
LOGGER.warning(String.format("Skipping file %s (%s)", fileName, exception.getMessage()));
|
LOGGER.warning(String.format("Skipping file %s (%s)", fileName, exception.getMessage()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user