diff options
Diffstat (limited to 'tools/aapt/ResourceTable.cpp')
-rw-r--r-- | tools/aapt/ResourceTable.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 4587a4b..bdc6586 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -6,9 +6,11 @@ #include "ResourceTable.h" +#include "AaptUtil.h" #include "XMLNode.h" #include "ResourceFilter.h" #include "ResourceIdCache.h" +#include "SdkConstants.h" #include <androidfw/ResourceTypes.h> #include <utils/ByteOrder.h> @@ -399,7 +401,7 @@ static status_t compileAttribute(const sp<AaptFile>& in, ssize_t l10nIdx = block.indexOfAttribute(NULL, "localization"); if (l10nIdx >= 0) { - const uint16_t* str = block.getAttributeStringValue(l10nIdx, &len); + const char16_t* str = block.getAttributeStringValue(l10nIdx, &len); bool error; uint32_t l10n_required = parse_flags(str, len, l10nRequiredFlags, &error); if (error) { @@ -1325,7 +1327,7 @@ status_t compileResourceFile(Bundle* bundle, size_t n = block.getAttributeCount(); for (size_t i = 0; i < n; i++) { size_t length; - const uint16_t* attr = block.getAttributeName(i, &length); + const char16_t* attr = block.getAttributeName(i, &length); if (strcmp16(attr, name16.string()) == 0) { name.setTo(block.getAttributeStringValue(i, &length)); } else if (strcmp16(attr, translatable16.string()) == 0) { @@ -1441,14 +1443,14 @@ status_t compileResourceFile(Bundle* bundle, // translatable. for (size_t i = 0; i < n; i++) { size_t length; - const uint16_t* attr = block.getAttributeName(i, &length); + const char16_t* attr = block.getAttributeName(i, &length); if (strcmp16(attr, formatted16.string()) == 0) { - const uint16_t* value = block.getAttributeStringValue(i, &length); + const char16_t* value = block.getAttributeStringValue(i, &length); if (strcmp16(value, false16.string()) == 0) { curIsFormatted = false; } } else if (strcmp16(attr, translatable16.string()) == 0) { - const uint16_t* value = block.getAttributeStringValue(i, &length); + const char16_t* value = block.getAttributeStringValue(i, &length); if (strcmp16(value, false16.string()) == 0) { isTranslatable = false; } @@ -4222,7 +4224,7 @@ static bool isMinSdkVersionLOrAbove(const Bundle* bundle) { } const int minSdk = atoi(bundle->getMinSdkVersion()); - if (minSdk >= SDK_L) { + if (minSdk >= SDK_LOLLIPOP) { return true; } } @@ -4313,7 +4315,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle) { } const ConfigDescription& config = entries.keyAt(ei); - if (config.sdkVersion >= SDK_L) { + if (config.sdkVersion >= SDK_LOLLIPOP) { // We don't need to do anything if the resource is // already qualified for version 21 or higher. continue; @@ -4335,9 +4337,9 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle) { } // Duplicate the entry under the same configuration - // but with sdkVersion == SDK_L. + // but with sdkVersion == SDK_LOLLIPOP. ConfigDescription newConfig(config); - newConfig.sdkVersion = SDK_L; + newConfig.sdkVersion = SDK_LOLLIPOP; entriesToAdd.add(key_value_pair_t<ConfigDescription, sp<Entry> >( newConfig, new Entry(*e))); @@ -4360,7 +4362,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle) { if (bundle->getVerbose()) { entriesToAdd[i].value->getPos() .printf("using v%d attributes; synthesizing resource %s:%s/%s for configuration %s.", - SDK_L, + SDK_LOLLIPOP, String8(p->getName()).string(), String8(t->getName()).string(), String8(entriesToAdd[i].value->getName()).string(), @@ -4387,7 +4389,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle, return NO_ERROR; } - if (target->getResourceType() == "" || target->getGroupEntry().toParams().sdkVersion >= SDK_L) { + if (target->getResourceType() == "" || target->getGroupEntry().toParams().sdkVersion >= SDK_LOLLIPOP) { // Skip resources that have no type (AndroidManifest.xml) or are already version qualified with v21 // or higher. return NO_ERROR; @@ -4423,7 +4425,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle, } ConfigDescription newConfig(target->getGroupEntry().toParams()); - newConfig.sdkVersion = SDK_L; + newConfig.sdkVersion = SDK_LOLLIPOP; // Look to see if we already have an overriding v21 configuration. sp<ConfigList> cl = getConfigList(String16(mAssets->getPackage()), @@ -4445,7 +4447,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle, if (bundle->getVerbose()) { SourcePos(target->getSourceFile(), -1).printf( "using v%d attributes; synthesizing resource %s:%s/%s for configuration %s.", - SDK_L, + SDK_LOLLIPOP, mAssets->getPackage().string(), newFile->getResourceType().string(), String8(resourceName).string(), @@ -4486,3 +4488,34 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle, return NO_ERROR; } + +void ResourceTable::getDensityVaryingResources(KeyedVector<Symbol, Vector<SymbolDefinition> >& resources) { + const ConfigDescription nullConfig; + + const size_t packageCount = mOrderedPackages.size(); + for (size_t p = 0; p < packageCount; p++) { + const Vector<sp<Type> >& types = mOrderedPackages[p]->getOrderedTypes(); + const size_t typeCount = types.size(); + for (size_t t = 0; t < typeCount; t++) { + const Vector<sp<ConfigList> >& configs = types[t]->getOrderedConfigs(); + const size_t configCount = configs.size(); + for (size_t c = 0; c < configCount; c++) { + const DefaultKeyedVector<ConfigDescription, sp<Entry> >& configEntries = configs[c]->getEntries(); + const size_t configEntryCount = configEntries.size(); + for (size_t ce = 0; ce < configEntryCount; ce++) { + const ConfigDescription& config = configEntries.keyAt(ce); + if (AaptConfig::isDensityOnly(config)) { + // This configuration only varies with regards to density. + const Symbol symbol(mOrderedPackages[p]->getName(), + types[t]->getName(), + configs[c]->getName(), + getResId(mOrderedPackages[p], types[t], configs[c]->getEntryIndex())); + + const sp<Entry>& entry = configEntries.valueAt(ce); + AaptUtil::appendValue(resources, symbol, SymbolDefinition(symbol, config, entry->getPos())); + } + } + } + } + } +} |