Skip to content

Commit

Permalink
fix: patch aapt2 to not run custom commands on passed aapt2 binary
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches committed Nov 20, 2019
1 parent d6f38e3 commit b05f19b
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private File createDoNotCompressExtensionsFile(ApkOptions apkOptions) throws And
}

private void aapt2Package(File apkFile, File manifest, File resDir, File rawDir, File assetDir, File[] include,
List<String> cmd)
List<String> cmd, boolean customAapt)
throws AndrolibException {

List<String> compileCommand = new ArrayList<>(cmd);
Expand Down Expand Up @@ -448,10 +448,17 @@ private void aapt2Package(File apkFile, File manifest, File resDir, File rawDir,
cmd.add("-x");
}

if (apkOptions.doNotCompress != null) {
if (apkOptions.doNotCompress != null && !customAapt) {
// Use custom -e option to avoid limits on commandline length.
// Can only be used when custom aapt binary is not used.
String extensionsFilePath = createDoNotCompressExtensionsFile(apkOptions).getAbsolutePath();
cmd.add("-e");
cmd.add(extensionsFilePath);
} else if (apkOptions.doNotCompress != null) {
for (String file : apkOptions.doNotCompress) {
cmd.add("-0");
cmd.add(file);
}
}

if (!apkOptions.resourcesAreCompressed) {
Expand Down Expand Up @@ -627,7 +634,7 @@ public void aaptPackage(File apkFile, File manifest, File resDir, File rawDir, F
}

if (apkOptions.isAapt2()) {
aapt2Package(apkFile, manifest, resDir, rawDir, assetDir, include, cmd);
aapt2Package(apkFile, manifest, resDir, rawDir, assetDir, include, cmd, customAapt);
return;
}
aapt1Package(apkFile, manifest, resDir, rawDir, assetDir, include, cmd, customAapt);
Expand Down

0 comments on commit b05f19b

Please sign in to comment.