diff options
author | Eric Fischer <enf@google.com> | 2011-09-27 16:09:41 -0700 |
---|---|---|
committer | Eric Fischer <enf@google.com> | 2011-09-27 16:09:41 -0700 |
commit | 914f7e683a01f15f8830810c49eaecc31bc554a6 (patch) | |
tree | 702278393601f3f27b0ec0213246c8ea3bf70d09 | |
parent | 006e6ef2e6349f5b3f9ef27c81750f007f56c69a (diff) |
Don't lose product variant strings that also vary between locales.
Localized strings with product variants were not being included in the APK,
apparently because the check to ensure that a different variation of the
string had not already been included in the APK was matching the version
of it from the default, untranslated configuration.
Now check to make sure that the string not only exists but also exists in
the correct configuration.
Bug 5372711
Change-Id: I52975570b75e0f11827dc6bcf1cb4a987d0541aa
-rw-r--r-- | tools/aapt/ResourceTable.cpp | 33 | ||||
-rw-r--r-- | tools/aapt/ResourceTable.h | 5 |
2 files changed, 37 insertions, 1 deletions
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 81b924af8d7e..99f74c6c10f1 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -695,7 +695,7 @@ status_t parseAndAddEntry(Bundle* bundle, if (isInProductList(product, String16(bundleProduct))) { ; } else if (strcmp16(String16("default").string(), product.string()) == 0 && - !outTable->hasBagOrEntry(myPackage, curType, ident)) { + !outTable->hasBagOrEntry(myPackage, curType, ident, config)) { ; } else { return NO_ERROR; @@ -1823,6 +1823,37 @@ bool ResourceTable::hasBagOrEntry(const String16& package, return false; } +bool ResourceTable::hasBagOrEntry(const String16& package, + const String16& type, + const String16& name, + const ResTable_config& config) const +{ + // First look for this in the included resources... + uint32_t rid = mAssets->getIncludedResources() + .identifierForName(name.string(), name.size(), + type.string(), type.size(), + package.string(), package.size()); + if (rid != 0) { + return true; + } + + sp<Package> p = mPackages.valueFor(package); + if (p != NULL) { + sp<Type> t = p->getTypes().valueFor(type); + if (t != NULL) { + sp<ConfigList> c = t->getConfigs().valueFor(name); + if (c != NULL) { + sp<Entry> e = c->getEntries().valueFor(config); + if (e != NULL) { + return true; + } + } + } + } + + return false; +} + bool ResourceTable::hasBagOrEntry(const String16& ref, const String16* defType, const String16* defPackage) diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h index 734c541f9b61..80f2192da4f6 100644 --- a/tools/aapt/ResourceTable.h +++ b/tools/aapt/ResourceTable.h @@ -124,6 +124,11 @@ public: const String16& type, const String16& name) const; + bool hasBagOrEntry(const String16& package, + const String16& type, + const String16& name, + const ResTable_config& config) const; + bool hasBagOrEntry(const String16& ref, const String16* defType = NULL, const String16* defPackage = NULL); |