summaryrefslogtreecommitdiffstats
path: root/tools/aapt/AaptConfig.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/aapt/AaptConfig.cpp')
-rw-r--r--tools/aapt/AaptConfig.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/tools/aapt/AaptConfig.cpp b/tools/aapt/AaptConfig.cpp
index 32a0cd3..ede9e99 100644
--- a/tools/aapt/AaptConfig.cpp
+++ b/tools/aapt/AaptConfig.cpp
@@ -21,6 +21,7 @@
#include "AaptAssets.h"
#include "AaptUtil.h"
#include "ResourceFilter.h"
+#include "SdkConstants.h"
using android::String8;
using android::Vector;
@@ -240,7 +241,9 @@ void applyVersionForCompatibility(ConfigDescription* config) {
}
uint16_t minSdk = 0;
- if (config->smallestScreenWidthDp != ResTable_config::SCREENWIDTH_ANY
+ if (config->density == ResTable_config::DENSITY_ANY) {
+ minSdk = SDK_LOLLIPOP;
+ } else if (config->smallestScreenWidthDp != ResTable_config::SCREENWIDTH_ANY
|| config->screenWidthDp != ResTable_config::SCREENWIDTH_ANY
|| config->screenHeightDp != ResTable_config::SCREENHEIGHT_ANY) {
minSdk = SDK_HONEYCOMB_MR2;
@@ -255,8 +258,6 @@ void applyVersionForCompatibility(ConfigDescription* config) {
!= ResTable_config::SCREENLONG_ANY
|| config->density != ResTable_config::DENSITY_DEFAULT) {
minSdk = SDK_DONUT;
- } else if ((config->density == ResTable_config::DENSITY_ANY)) {
- minSdk = SDK_L;
}
if (minSdk > config->sdkVersion) {
@@ -794,4 +795,23 @@ bool isSameExcept(const ResTable_config& a, const ResTable_config& b, int axisMa
return a.diff(b) == axisMask;
}
+bool isDensityOnly(const ResTable_config& config) {
+ if (config.density == ResTable_config::DENSITY_DEFAULT) {
+ return false;
+ }
+
+ if (config.density == ResTable_config::DENSITY_ANY) {
+ if (config.sdkVersion != SDK_LOLLIPOP) {
+ // Someone modified the sdkVersion from the default, this is not safe to assume.
+ return false;
+ }
+ } else if (config.sdkVersion != SDK_DONUT) {
+ return false;
+ }
+
+ const uint32_t mask = ResTable_config::CONFIG_DENSITY | ResTable_config::CONFIG_VERSION;
+ const ConfigDescription nullConfig;
+ return (nullConfig.diff(config) & ~mask) == 0;
+}
+
} // namespace AaptConfig