aapt2/aapt2-Apktool-patches.patch

123 lines
4.5 KiB
Diff

--- a/base/tools/aapt2/Android.bp
+++ b/base/tools/aapt2/Android.bp
@@ -54,6 +54,7 @@
},
darwin: {
cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
+ static_libs: ["libc++_static"]
},
},
header_libs: ["jni_headers"],
@@ -210,6 +211,8 @@
name: "aapt2",
srcs: ["Main.cpp"] + toolSources,
use_version_lib: true,
+ stl: "libc++_static",
+ static_executable: true,
static_libs: ["libaapt2"],
defaults: ["aapt2_defaults"],
dist: {
--- a/base/tools/aapt2/ResourceTable.cpp
+++ b/base/tools/aapt2/ResourceTable.cpp
@@ -460,9 +460,8 @@
const bool validate = validation_ == Validation::kEnabled;
const Source source = res.value ? res.value->GetSource() : Source{};
if (validate && !res.allow_mangled && !IsValidResourceEntryName(res.name.entry)) {
- diag->Error(DiagMessage(source)
- << "resource '" << res.name << "' has invalid entry name '" << res.name.entry);
- return false;
+ // Apktool: Allow invalid entry names.
+ return true;
}
if (res.id.has_value() && !res.id->first.is_valid()) {
--- a/base/tools/aapt2/ResourceUtils.cpp
+++ b/base/tools/aapt2/ResourceUtils.cpp
@@ -222,7 +222,7 @@
}
if (!type.empty() && type != "attr") {
- return false;
+ // Apktool: Don't die out if private resource.
}
if (entry.empty()) {
--- a/base/tools/aapt2/cmd/Link.cpp
+++ b/base/tools/aapt2/cmd/Link.cpp
@@ -2326,9 +2326,9 @@
if (package_id_int > std::numeric_limits<uint8_t>::max()
|| package_id_int == kFrameworkPackageId
|| (!options_.allow_reserved_package_id && package_id_int < kAppPackageId)) {
- context.GetDiagnostics()->Error(
+ context.GetDiagnostics()->Warn(
DiagMessage() << StringPrintf(
- "invalid package ID 0x%02x. Must be in the range 0x7f-0xff.", package_id_int));
+ "invalid package ID 0x%02x. Must be in the range 0x7f-0xff. Ignoring...", package_id_int));
return 1;
}
context.SetPackageId(static_cast<uint8_t>(package_id_int));
@@ -2410,6 +2410,23 @@
".mpg", ".mpeg", ".mp4", ".m4a", ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", ".wma", ".wmv",
".webm", ".mkv"});
+ // Populate no compress extensions specified in the extensions file.
+ if (options_.extensions_to_not_compress_path) {
+ std::ifstream extensionsFile(options_.extensions_to_not_compress_path.value());
+
+ if (extensionsFile.fail()) {
+ context.GetDiagnostics()->Error(
+ DiagMessage() << "could not open extensions file "
+ << options_.extensions_to_not_compress_path.value()
+ << " for reading");
+ return 1;
+ }
+
+ for (std::string line; getline(extensionsFile, line);) {
+ options_.extensions_to_not_compress.insert(line);
+ }
+ }
+
// Turn off auto versioning for static-libs.
if (context.GetPackageType() == PackageType::kStaticLib) {
options_.no_auto_version = true;
--- a/base/tools/aapt2/cmd/Link.h
+++ b/base/tools/aapt2/cmd/Link.h
@@ -71,6 +71,7 @@
bool do_not_compress_anything = false;
std::unordered_set<std::string> extensions_to_not_compress;
Maybe<std::regex> regex_to_not_compress;
+ Maybe<std::string> extensions_to_not_compress_path;
// Static lib options.
bool no_static_lib_packages = false;
@@ -272,6 +273,8 @@
&options_.manifest_fixer_options.rename_overlay_target_package);
AddOptionalFlagList("-0", "File suffix not to compress.",
&options_.extensions_to_not_compress);
+ AddOptionalFlag("-e", "File containing list of extensions not to compress.",
+ &options_.extensions_to_not_compress_path);
AddOptionalSwitch("--no-compress", "Do not compress any resources.",
&options_.do_not_compress_anything);
AddOptionalSwitch("--keep-raw-values", "Preserve raw attribute values in xml files.",
--- a/base/tools/aapt2/java/JavaClassGenerator.cpp
+++ b/base/tools/aapt2/java/JavaClassGenerator.cpp
@@ -58,6 +58,8 @@
"true", "false", "null"};
static bool IsValidSymbol(const StringPiece& symbol) {
+ // Apktool: Everything is a valid symbol
+ return true;
return sJavaIdentifiers.find(symbol) == sJavaIdentifiers.end();
}
--- a/base/tools/aapt2/link/PrivateAttributeMover.cpp
+++ b/base/tools/aapt2/link/PrivateAttributeMover.cpp
@@ -81,7 +81,6 @@
}
ResourceTableType* priv_attr_type = package->FindOrCreateType(ResourceType::kAttrPrivate);
- CHECK(priv_attr_type->entries.empty());
priv_attr_type->entries = std::move(private_attr_entries);
}
return true;