diff options
author | 2017-08-30 16:12:05 -0700 | |
---|---|---|
committer | 2017-08-30 16:12:05 -0700 | |
commit | 5d94fb7040c710af38119eebb60e0ecae122d650 (patch) | |
tree | f569ce93b71d4a3a9a367d5475930b82556e8031 | |
parent | d48474969e786eaf911ac51bcd05faa3399b788a (diff) |
AAPT2: Fix issue with resource deduping
Resource deduping relies on the definitions of
ConfigDescription.ConflictsWith, ConfigDescription.IsCompatibleWith,
and ConfigDescription.Dominates.
ConflictsWith is supposed to ignore range-based qualifiers, like
version, density, smallest width, screen size, etc.
This was not the case for screen size, and was assumed that the
choice of screen size is mutually exclusive.
This CL fixes the assumption and includes screen size (small, normal, large, xlarge)
as a qualifier that does not conflict.
Bug: 64397629
Test: make aapt2_tests
Change-Id: I573a6735fedd7721a10ba32902bc5d27ef99b88e
-rw-r--r-- | tools/aapt2/ConfigDescription.cpp | 2 | ||||
-rw-r--r-- | tools/aapt2/ConfigDescription_test.cpp | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/tools/aapt2/ConfigDescription.cpp b/tools/aapt2/ConfigDescription.cpp index 6a099651f2ce..a9278c136cff 100644 --- a/tools/aapt2/ConfigDescription.cpp +++ b/tools/aapt2/ConfigDescription.cpp @@ -967,8 +967,6 @@ bool ConfigDescription::ConflictsWith(const ConfigDescription& o) const { o.screenLayout & MASK_LAYOUTDIR) || !pred(screenLayout & MASK_SCREENLONG, o.screenLayout & MASK_SCREENLONG) || - !pred(screenLayout & MASK_UI_MODE_TYPE, - o.screenLayout & MASK_UI_MODE_TYPE) || !pred(uiMode & MASK_UI_MODE_TYPE, o.uiMode & MASK_UI_MODE_TYPE) || !pred(uiMode & MASK_UI_MODE_NIGHT, o.uiMode & MASK_UI_MODE_NIGHT) || !pred(screenLayout2 & MASK_SCREENROUND, diff --git a/tools/aapt2/ConfigDescription_test.cpp b/tools/aapt2/ConfigDescription_test.cpp index 14a565624e01..1f351bf7481d 100644 --- a/tools/aapt2/ConfigDescription_test.cpp +++ b/tools/aapt2/ConfigDescription_test.cpp @@ -140,4 +140,16 @@ TEST(ConfigDescriptionTest, ParseVrAttribute) { EXPECT_EQ(std::string("vrheadset-v26"), config.toString().string()); } +TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) { + using test::ParseConfigOrDie; + + EXPECT_FALSE(ParseConfigOrDie("large").ConflictsWith(ParseConfigOrDie("normal-land"))); + EXPECT_FALSE(ParseConfigOrDie("long-hdpi").ConflictsWith(ParseConfigOrDie("xhdpi"))); + EXPECT_FALSE(ParseConfigOrDie("sw600dp").ConflictsWith(ParseConfigOrDie("sw700dp"))); + EXPECT_FALSE(ParseConfigOrDie("v11").ConflictsWith(ParseConfigOrDie("v21"))); + EXPECT_FALSE(ParseConfigOrDie("h600dp").ConflictsWith(ParseConfigOrDie("h300dp"))); + EXPECT_FALSE(ParseConfigOrDie("w400dp").ConflictsWith(ParseConfigOrDie("w300dp"))); + EXPECT_FALSE(ParseConfigOrDie("600x400").ConflictsWith(ParseConfigOrDie("300x200"))); +} + } // namespace aapt |