mirror of
https://github.com/revanced/aapt2.git
synced 2024-11-01 01:03:10 +01:00
188 lines
7.6 KiB
Diff
188 lines
7.6 KiB
Diff
|
Submodule src/base contains modified content
|
||
|
diff --git a/src/base/libs/androidfw/ResourceTypes.cpp b/src/base/libs/androidfw/ResourceTypes.cpp
|
||
|
index cae2d0bc16b3..13c5f8fc84e8 100644
|
||
|
--- a/src/base/libs/androidfw/ResourceTypes.cpp
|
||
|
+++ b/src/base/libs/androidfw/ResourceTypes.cpp
|
||
|
@@ -43,7 +43,7 @@
|
||
|
#include <utils/String16.h>
|
||
|
#include <utils/String8.h>
|
||
|
|
||
|
-#ifdef __ANDROID__
|
||
|
+#if 0
|
||
|
#include <binder/TextOutput.h>
|
||
|
|
||
|
#endif
|
||
|
diff --git a/src/base/tools/aapt2/ResourceTable.cpp b/src/base/tools/aapt2/ResourceTable.cpp
|
||
|
index 8ab1493c6ab3..3a855f0f6866 100644
|
||
|
--- a/src/base/tools/aapt2/ResourceTable.cpp
|
||
|
+++ b/src/base/tools/aapt2/ResourceTable.cpp
|
||
|
@@ -460,9 +460,7 @@ bool ResourceTable::AddResource(NewResource&& res, IDiagnostics* diag) {
|
||
|
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;
|
||
|
+ return true;
|
||
|
}
|
||
|
|
||
|
if (res.id.has_value() && !res.id->first.is_valid()) {
|
||
|
diff --git a/src/base/tools/aapt2/ResourceUtils.cpp b/src/base/tools/aapt2/ResourceUtils.cpp
|
||
|
index e0e80ac02dea..f74d7f106220 100644
|
||
|
--- a/src/base/tools/aapt2/ResourceUtils.cpp
|
||
|
+++ b/src/base/tools/aapt2/ResourceUtils.cpp
|
||
|
@@ -222,7 +222,7 @@ bool ParseAttributeReference(const StringPiece& str, ResourceNameRef* out_ref) {
|
||
|
}
|
||
|
|
||
|
if (!type.empty() && type != "attr") {
|
||
|
- return false;
|
||
|
+ // Apktool: Don't die out if private resource.
|
||
|
}
|
||
|
|
||
|
if (entry.empty()) {
|
||
|
diff --git a/src/base/tools/aapt2/Resources.proto b/src/base/tools/aapt2/Resources.proto
|
||
|
index 95b794964068..3cdadfd637e3 100644
|
||
|
--- a/src/base/tools/aapt2/Resources.proto
|
||
|
+++ b/src/base/tools/aapt2/Resources.proto
|
||
|
@@ -16,7 +16,7 @@
|
||
|
|
||
|
syntax = "proto3";
|
||
|
|
||
|
-import "frameworks/base/tools/aapt2/Configuration.proto";
|
||
|
+import "Configuration.proto";
|
||
|
|
||
|
package aapt.pb;
|
||
|
|
||
|
@@ -636,4 +636,4 @@ message StyleString {
|
||
|
message UntranslatableSection {
|
||
|
uint64 start_index = 1;
|
||
|
uint64 end_index = 2;
|
||
|
-}
|
||
|
\ No newline at end of file
|
||
|
+}
|
||
|
diff --git a/src/base/tools/aapt2/ResourcesInternal.proto b/src/base/tools/aapt2/ResourcesInternal.proto
|
||
|
index b0ed3da33368..97aa5af7724f 100644
|
||
|
--- a/src/base/tools/aapt2/ResourcesInternal.proto
|
||
|
+++ b/src/base/tools/aapt2/ResourcesInternal.proto
|
||
|
@@ -16,8 +16,8 @@
|
||
|
|
||
|
syntax = "proto3";
|
||
|
|
||
|
-import "frameworks/base/tools/aapt2/Configuration.proto";
|
||
|
-import "frameworks/base/tools/aapt2/Resources.proto";
|
||
|
+import "Configuration.proto";
|
||
|
+import "Resources.proto";
|
||
|
|
||
|
package aapt.pb.internal;
|
||
|
|
||
|
diff --git a/src/base/tools/aapt2/cmd/Link.cpp b/src/base/tools/aapt2/cmd/Link.cpp
|
||
|
index e4d0f3b6bd23..aa43ee07bfac 100644
|
||
|
--- a/src/base/tools/aapt2/cmd/Link.cpp
|
||
|
+++ b/src/base/tools/aapt2/cmd/Link.cpp
|
||
|
@@ -2326,9 +2326,9 @@ int LinkCommand::Action(const std::vector<std::string>& args) {
|
||
|
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 @@ int LinkCommand::Action(const std::vector<std::string>& args) {
|
||
|
".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;
|
||
|
diff --git a/src/base/tools/aapt2/cmd/Link.h b/src/base/tools/aapt2/cmd/Link.h
|
||
|
index 768b4b2c7bfd..6dd220515674 100644
|
||
|
--- a/src/base/tools/aapt2/cmd/Link.h
|
||
|
+++ b/src/base/tools/aapt2/cmd/Link.h
|
||
|
@@ -71,6 +71,7 @@ struct LinkOptions {
|
||
|
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 @@ class LinkCommand : public Command {
|
||
|
&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.",
|
||
|
diff --git a/src/base/tools/aapt2/java/JavaClassGenerator.cpp b/src/base/tools/aapt2/java/JavaClassGenerator.cpp
|
||
|
index de6524dc7027..0a968c11a13b 100644
|
||
|
--- a/src/base/tools/aapt2/java/JavaClassGenerator.cpp
|
||
|
+++ b/src/base/tools/aapt2/java/JavaClassGenerator.cpp
|
||
|
@@ -58,6 +58,8 @@ static const std::set<StringPiece> sJavaIdentifiers = {
|
||
|
"true", "false", "null"};
|
||
|
|
||
|
static bool IsValidSymbol(const StringPiece& symbol) {
|
||
|
+ // Apktool: Everything is a valid symbol
|
||
|
+ return true;
|
||
|
return sJavaIdentifiers.find(symbol) == sJavaIdentifiers.end();
|
||
|
}
|
||
|
|
||
|
diff --git a/src/base/tools/aapt2/link/PrivateAttributeMover.cpp b/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
|
||
|
index 675b02a7e161..fb2b11da5ee4 100644
|
||
|
--- a/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
|
||
|
+++ b/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
|
||
|
@@ -81,7 +81,6 @@ bool PrivateAttributeMover::Consume(IAaptContext* context, ResourceTable* table)
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
diff --git a/src/base/tools/aapt2/util/Util.cpp b/src/base/tools/aapt2/util/Util.cpp
|
||
|
index d7a8e6fe6ada..74457add2e6b 100644
|
||
|
--- a/src/base/tools/aapt2/util/Util.cpp
|
||
|
+++ b/src/base/tools/aapt2/util/Util.cpp
|
||
|
@@ -23,7 +23,6 @@
|
||
|
|
||
|
#include "android-base/stringprintf.h"
|
||
|
#include "androidfw/StringPiece.h"
|
||
|
-#include "build/version.h"
|
||
|
|
||
|
#include "text/Unicode.h"
|
||
|
#include "text/Utf8Iterator.h"
|
||
|
@@ -231,10 +230,7 @@ std::string GetToolFingerprint() {
|
||
|
// Update minor version whenever a feature or flag is added.
|
||
|
static const char* const sMinorVersion = "19";
|
||
|
|
||
|
- // The build id of aapt2 binary.
|
||
|
- static const std::string sBuildId = android::build::GetBuildNumber();
|
||
|
-
|
||
|
- return android::base::StringPrintf("%s.%s-%s", sMajorVersion, sMinorVersion, sBuildId.c_str());
|
||
|
+ return android::base::StringPrintf("%s.%s", sMajorVersion, sMinorVersion);
|
||
|
}
|
||
|
|
||
|
static size_t ConsumeDigits(const char* start, const char* end) {
|