diff options
author | Mohamed Heikal <mheikal@google.com> | 2019-04-25 17:39:43 -0400 |
---|---|---|
committer | Mohamed Heikal <mheikal@google.com> | 2019-04-26 10:48:54 -0400 |
commit | 7c7573040ade65f70560bfdb508cdb29d41b1254 (patch) | |
tree | 60339ebe273d89bf82c9a28d67b7baf25a3139c5 /tools/aapt2/optimize/ResourcePathShortener.cpp | |
parent | cad94f9695a0f07e592b7a12002f0bd237991468 (diff) |
Fix bug where path shortening breaks ColorStateLists
Android resource loader uses the file path to check if a resource is a
ColorStateList. Path shortening removed that part of the path and thus
broke the resource loader of APKs optimized with path shortening. This
cl skips path shortening for resources under "res/color/"
Test: make aapt2_tests
Bug: b/75965637
Change-Id: If94dfa398efd81522d4faed157afd35f6dabe856
Diffstat (limited to 'tools/aapt2/optimize/ResourcePathShortener.cpp')
-rw-r--r-- | tools/aapt2/optimize/ResourcePathShortener.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/aapt2/optimize/ResourcePathShortener.cpp b/tools/aapt2/optimize/ResourcePathShortener.cpp index c5df3dd00db9..845262bcb0d9 100644 --- a/tools/aapt2/optimize/ResourcePathShortener.cpp +++ b/tools/aapt2/optimize/ResourcePathShortener.cpp @@ -95,6 +95,10 @@ 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/")) + continue; + std::string shortened_filename = ShortenFileName(*file_ref->path, num_chars); int collision_count = 0; std::string shortened_path = GetShortenedPath(shortened_filename, extension, collision_count); |