diff options
| author | 2019-07-09 15:39:45 +0000 | |
|---|---|---|
| committer | 2019-07-09 15:39:45 +0000 | |
| commit | 582e98ef762429c15cfe677409d489aa96aad496 (patch) | |
| tree | 43536eabf0415691031b1e6126e45c68261f4f76 | |
| parent | 6a727cafa676aca603457fb93f210295785ae514 (diff) | |
| parent | 61d528f49d7d5d17159a9c87813fa061854e39f6 (diff) | |
Merge "Fix bug where aapt2 optimize obfuscated color-* resources"
| -rw-r--r-- | tools/aapt2/optimize/ResourcePathShortener.cpp | 5 | ||||
| -rw-r--r-- | tools/aapt2/optimize/ResourcePathShortener_test.cpp | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/tools/aapt2/optimize/ResourcePathShortener.cpp b/tools/aapt2/optimize/ResourcePathShortener.cpp index 845262bcb0d9..6b11de759d2d 100644 --- a/tools/aapt2/optimize/ResourcePathShortener.cpp +++ b/tools/aapt2/optimize/ResourcePathShortener.cpp @@ -23,6 +23,7 @@ #include "ResourceTable.h" #include "ValueVisitor.h" +#include "util/Util.h" static const std::string base64_chars = @@ -95,8 +96,8 @@ bool ResourcePathShortener::Consume(IAaptContext* context, ResourceTable* table) android::StringPiece res_subdir, actual_filename, extension; util::ExtractResFilePathParts(*file_ref->path, &res_subdir, &actual_filename, &extension); - // Android detects ColorStateLists via pathname, skip res/color/* - if (res_subdir == android::StringPiece("res/color/")) + // Android detects ColorStateLists via pathname, skip res/color* + if (util::StartsWith(res_subdir, "res/color")) continue; std::string shortened_filename = ShortenFileName(*file_ref->path, num_chars); diff --git a/tools/aapt2/optimize/ResourcePathShortener_test.cpp b/tools/aapt2/optimize/ResourcePathShortener_test.cpp index efbef8f40722..1f4569495186 100644 --- a/tools/aapt2/optimize/ResourcePathShortener_test.cpp +++ b/tools/aapt2/optimize/ResourcePathShortener_test.cpp @@ -75,6 +75,9 @@ TEST(ResourcePathShortenerTest, SkipColorFileRefPaths) { std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder() .AddFileReference("android:color/colorlist", "res/color/colorlist.xml") + .AddFileReference("android:color/colorlist", + "res/color-mdp-v21/colorlist.xml", + test::ParseConfigOrDie("mdp-v21")) .Build(); std::map<std::string, std::string> path_map; @@ -82,6 +85,7 @@ TEST(ResourcePathShortenerTest, SkipColorFileRefPaths) { // Expect that the path map to not contain the ColorStateList ASSERT_THAT(path_map.find("res/color/colorlist.xml"), Eq(path_map.end())); + ASSERT_THAT(path_map.find("res/color-mdp-v21/colorlist.xml"), Eq(path_map.end())); } TEST(ResourcePathShortenerTest, KeepExtensions) { |