aapt2.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. Submodule src/base contains modified content
  2. diff --git a/src/base/tools/aapt2/ResourceTable.cpp b/src/base/tools/aapt2/ResourceTable.cpp
  3. index 8ab1493c6ab3..3a855f0f6866 100644
  4. --- a/src/base/tools/aapt2/ResourceTable.cpp
  5. +++ b/src/base/tools/aapt2/ResourceTable.cpp
  6. @@ -460,9 +460,7 @@ bool ResourceTable::AddResource(NewResource&& res, IDiagnostics* diag) {
  7. const bool validate = validation_ == Validation::kEnabled;
  8. const Source source = res.value ? res.value->GetSource() : Source{};
  9. if (validate && !res.allow_mangled && !IsValidResourceEntryName(res.name.entry)) {
  10. - diag->Error(DiagMessage(source)
  11. - << "resource '" << res.name << "' has invalid entry name '" << res.name.entry);
  12. - return false;
  13. + return true;
  14. }
  15. if (res.id.has_value() && !res.id->first.is_valid()) {
  16. diff --git a/src/base/tools/aapt2/ResourceUtils.cpp b/src/base/tools/aapt2/ResourceUtils.cpp
  17. index e0e80ac02dea..f74d7f106220 100644
  18. --- a/src/base/tools/aapt2/ResourceUtils.cpp
  19. +++ b/src/base/tools/aapt2/ResourceUtils.cpp
  20. @@ -222,7 +222,7 @@ bool ParseAttributeReference(const StringPiece& str, ResourceNameRef* out_ref) {
  21. }
  22. if (!type.empty() && type != "attr") {
  23. - return false;
  24. + // Apktool: Don't die out if private resource.
  25. }
  26. if (entry.empty()) {
  27. diff --git a/src/base/tools/aapt2/Resources.proto b/src/base/tools/aapt2/Resources.proto
  28. index 95b794964068..3cdadfd637e3 100644
  29. --- a/src/base/tools/aapt2/Resources.proto
  30. +++ b/src/base/tools/aapt2/Resources.proto
  31. @@ -16,7 +16,7 @@
  32. syntax = "proto3";
  33. -import "frameworks/base/tools/aapt2/Configuration.proto";
  34. +import "Configuration.proto";
  35. package aapt.pb;
  36. @@ -636,4 +636,4 @@ message StyleString {
  37. message UntranslatableSection {
  38. uint64 start_index = 1;
  39. uint64 end_index = 2;
  40. -}
  41. \ No newline at end of file
  42. +}
  43. diff --git a/src/base/tools/aapt2/ResourcesInternal.proto b/src/base/tools/aapt2/ResourcesInternal.proto
  44. index b0ed3da33368..97aa5af7724f 100644
  45. --- a/src/base/tools/aapt2/ResourcesInternal.proto
  46. +++ b/src/base/tools/aapt2/ResourcesInternal.proto
  47. @@ -16,8 +16,8 @@
  48. syntax = "proto3";
  49. -import "frameworks/base/tools/aapt2/Configuration.proto";
  50. -import "frameworks/base/tools/aapt2/Resources.proto";
  51. +import "Configuration.proto";
  52. +import "Resources.proto";
  53. package aapt.pb.internal;
  54. diff --git a/src/base/tools/aapt2/cmd/Link.cpp b/src/base/tools/aapt2/cmd/Link.cpp
  55. index e4d0f3b6bd23..aa43ee07bfac 100644
  56. --- a/src/base/tools/aapt2/cmd/Link.cpp
  57. +++ b/src/base/tools/aapt2/cmd/Link.cpp
  58. @@ -2326,9 +2326,9 @@ int LinkCommand::Action(const std::vector<std::string>& args) {
  59. if (package_id_int > std::numeric_limits<uint8_t>::max()
  60. || package_id_int == kFrameworkPackageId
  61. || (!options_.allow_reserved_package_id && package_id_int < kAppPackageId)) {
  62. - context.GetDiagnostics()->Error(
  63. + context.GetDiagnostics()->Warn(
  64. DiagMessage() << StringPrintf(
  65. - "invalid package ID 0x%02x. Must be in the range 0x7f-0xff.", package_id_int));
  66. + "invalid package ID 0x%02x. Must be in the range 0x7f-0xff. Ignoring...", package_id_int));
  67. return 1;
  68. }
  69. context.SetPackageId(static_cast<uint8_t>(package_id_int));
  70. @@ -2410,6 +2410,23 @@ int LinkCommand::Action(const std::vector<std::string>& args) {
  71. ".mpg", ".mpeg", ".mp4", ".m4a", ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", ".wma", ".wmv",
  72. ".webm", ".mkv"});
  73. + // Populate no compress extensions specified in the extensions file.
  74. + if (options_.extensions_to_not_compress_path) {
  75. + std::ifstream extensionsFile(options_.extensions_to_not_compress_path.value());
  76. +
  77. + if (extensionsFile.fail()) {
  78. + context.GetDiagnostics()->Error(
  79. + DiagMessage() << "could not open extensions file "
  80. + << options_.extensions_to_not_compress_path.value()
  81. + << " for reading");
  82. + return 1;
  83. + }
  84. +
  85. + for (std::string line; getline(extensionsFile, line);) {
  86. + options_.extensions_to_not_compress.insert(line);
  87. + }
  88. + }
  89. +
  90. // Turn off auto versioning for static-libs.
  91. if (context.GetPackageType() == PackageType::kStaticLib) {
  92. options_.no_auto_version = true;
  93. diff --git a/src/base/tools/aapt2/cmd/Link.h b/src/base/tools/aapt2/cmd/Link.h
  94. index 768b4b2c7bfd..6dd220515674 100644
  95. --- a/src/base/tools/aapt2/cmd/Link.h
  96. +++ b/src/base/tools/aapt2/cmd/Link.h
  97. @@ -71,6 +71,7 @@ struct LinkOptions {
  98. bool do_not_compress_anything = false;
  99. std::unordered_set<std::string> extensions_to_not_compress;
  100. Maybe<std::regex> regex_to_not_compress;
  101. + Maybe<std::string> extensions_to_not_compress_path;
  102. // Static lib options.
  103. bool no_static_lib_packages = false;
  104. @@ -272,6 +273,8 @@ class LinkCommand : public Command {
  105. &options_.manifest_fixer_options.rename_overlay_target_package);
  106. AddOptionalFlagList("-0", "File suffix not to compress.",
  107. &options_.extensions_to_not_compress);
  108. + AddOptionalFlag("-e", "File containing list of extensions not to compress.",
  109. + &options_.extensions_to_not_compress_path);
  110. AddOptionalSwitch("--no-compress", "Do not compress any resources.",
  111. &options_.do_not_compress_anything);
  112. AddOptionalSwitch("--keep-raw-values", "Preserve raw attribute values in xml files.",
  113. diff --git a/src/base/tools/aapt2/java/JavaClassGenerator.cpp b/src/base/tools/aapt2/java/JavaClassGenerator.cpp
  114. index de6524dc7027..0a968c11a13b 100644
  115. --- a/src/base/tools/aapt2/java/JavaClassGenerator.cpp
  116. +++ b/src/base/tools/aapt2/java/JavaClassGenerator.cpp
  117. @@ -58,6 +58,8 @@ static const std::set<StringPiece> sJavaIdentifiers = {
  118. "true", "false", "null"};
  119. static bool IsValidSymbol(const StringPiece& symbol) {
  120. + // Apktool: Everything is a valid symbol
  121. + return true;
  122. return sJavaIdentifiers.find(symbol) == sJavaIdentifiers.end();
  123. }
  124. diff --git a/src/base/tools/aapt2/link/PrivateAttributeMover.cpp b/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
  125. index 675b02a7e161..fb2b11da5ee4 100644
  126. --- a/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
  127. +++ b/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
  128. @@ -81,7 +81,6 @@ bool PrivateAttributeMover::Consume(IAaptContext* context, ResourceTable* table)
  129. }
  130. ResourceTableType* priv_attr_type = package->FindOrCreateType(ResourceType::kAttrPrivate);
  131. - CHECK(priv_attr_type->entries.empty());
  132. priv_attr_type->entries = std::move(private_attr_entries);
  133. }
  134. return true;
  135. diff --git a/src/base/tools/aapt2/util/Util.cpp b/src/base/tools/aapt2/util/Util.cpp
  136. index d7a8e6fe6ada..74457add2e6b 100644
  137. --- a/src/base/tools/aapt2/util/Util.cpp
  138. +++ b/src/base/tools/aapt2/util/Util.cpp
  139. @@ -23,7 +23,6 @@
  140. #include "android-base/stringprintf.h"
  141. #include "androidfw/StringPiece.h"
  142. -#include "build/version.h"
  143. #include "text/Unicode.h"
  144. #include "text/Utf8Iterator.h"
  145. @@ -231,10 +230,7 @@ std::string GetToolFingerprint() {
  146. // Update minor version whenever a feature or flag is added.
  147. static const char* const sMinorVersion = "19";
  148. - // The build id of aapt2 binary.
  149. - static const std::string sBuildId = android::build::GetBuildNumber();
  150. -
  151. - return android::base::StringPrintf("%s.%s-%s", sMajorVersion, sMinorVersion, sBuildId.c_str());
  152. + return android::base::StringPrintf("%s.%s", sMajorVersion, sMinorVersion);
  153. }
  154. static size_t ConsumeDigits(const char* start, const char* end) {