summaryrefslogtreecommitdiff
path: root/tools/split-select/RuleGenerator.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2014-11-06 12:54:36 -0800
committerAdam Lesinski <adamlesinski@google.com>2014-11-06 14:57:34 -0800
commitdcdfe9fef4b07ee53d312c3fbecc74cb215ace6f (patch)
tree1e689ea612de5ab03f10144b4103fae511b564e8 /tools/split-select/RuleGenerator.cpp
parentd12b69518daabff3c13482f4b5140020b747b71f (diff)
split-select: Fix rules generated for anydpi density
Change-Id: I9de569ca9a76eb22df4d0e178df847ba1c7d0b01
Diffstat (limited to 'tools/split-select/RuleGenerator.cpp')
-rw-r--r--tools/split-select/RuleGenerator.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/tools/split-select/RuleGenerator.cpp b/tools/split-select/RuleGenerator.cpp
index b8f3bcbb422d..72bb0c7def23 100644
--- a/tools/split-select/RuleGenerator.cpp
+++ b/tools/split-select/RuleGenerator.cpp
@@ -15,6 +15,7 @@
*/
#include "RuleGenerator.h"
+#include "aapt/SdkConstants.h"
#include <algorithm>
#include <cmath>
@@ -32,18 +33,21 @@ static inline int findMid(int l, int h) {
}
sp<Rule> RuleGenerator::generateDensity(const Vector<int>& allDensities, size_t index) {
- sp<Rule> densityRule = new Rule();
- densityRule->op = Rule::AND_SUBRULES;
-
- const bool anyDensity = allDensities[index] == ResTable_config::DENSITY_ANY;
- sp<Rule> any = new Rule();
- any->op = Rule::EQUALS;
- any->key = Rule::SCREEN_DENSITY;
- any->longArgs.add((int)ResTable_config::DENSITY_ANY);
- any->negate = !anyDensity;
- densityRule->subrules.add(any);
-
- if (!anyDensity) {
+ if (allDensities[index] != ResTable_config::DENSITY_ANY) {
+ sp<Rule> densityRule = new Rule();
+ densityRule->op = Rule::AND_SUBRULES;
+
+ const bool hasAnyDensity = std::find(allDensities.begin(),
+ allDensities.end(), ResTable_config::DENSITY_ANY) != allDensities.end();
+
+ if (hasAnyDensity) {
+ sp<Rule> version = new Rule();
+ version->op = Rule::LESS_THAN;
+ version->key = Rule::SDK_VERSION;
+ version->longArgs.add((long) SDK_LOLLIPOP);
+ densityRule->subrules.add(version);
+ }
+
if (index > 0) {
sp<Rule> gt = new Rule();
gt->op = Rule::GREATER_THAN;
@@ -59,8 +63,14 @@ sp<Rule> RuleGenerator::generateDensity(const Vector<int>& allDensities, size_t
lt->longArgs.add(findMid(allDensities[index], allDensities[index + 1]));
densityRule->subrules.add(lt);
}
+ return densityRule;
+ } else {
+ // SDK_VERSION is handled elsewhere, so we always pick DENSITY_ANY if it's
+ // available.
+ sp<Rule> always = new Rule();
+ always->op = Rule::ALWAYS_TRUE;
+ return always;
}
- return densityRule;
}
sp<Rule> RuleGenerator::generateAbi(const Vector<abi::Variant>& splitAbis, size_t index) {