Skip to content

Commit 914f7e6

Browse files
author
Eric Fischer
committed
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
1 parent 006e6ef commit 914f7e6

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

tools/aapt/ResourceTable.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ status_t parseAndAddEntry(Bundle* bundle,
695695
if (isInProductList(product, String16(bundleProduct))) {
696696
;
697697
} else if (strcmp16(String16("default").string(), product.string()) == 0 &&
698-
!outTable->hasBagOrEntry(myPackage, curType, ident)) {
698+
!outTable->hasBagOrEntry(myPackage, curType, ident, config)) {
699699
;
700700
} else {
701701
return NO_ERROR;
@@ -1823,6 +1823,37 @@ bool ResourceTable::hasBagOrEntry(const String16& package,
18231823
return false;
18241824
}
18251825

1826+
bool ResourceTable::hasBagOrEntry(const String16& package,
1827+
const String16& type,
1828+
const String16& name,
1829+
const ResTable_config& config) const
1830+
{
1831+
// First look for this in the included resources...
1832+
uint32_t rid = mAssets->getIncludedResources()
1833+
.identifierForName(name.string(), name.size(),
1834+
type.string(), type.size(),
1835+
package.string(), package.size());
1836+
if (rid != 0) {
1837+
return true;
1838+
}
1839+
1840+
sp<Package> p = mPackages.valueFor(package);
1841+
if (p != NULL) {
1842+
sp<Type> t = p->getTypes().valueFor(type);
1843+
if (t != NULL) {
1844+
sp<ConfigList> c = t->getConfigs().valueFor(name);
1845+
if (c != NULL) {
1846+
sp<Entry> e = c->getEntries().valueFor(config);
1847+
if (e != NULL) {
1848+
return true;
1849+
}
1850+
}
1851+
}
1852+
}
1853+
1854+
return false;
1855+
}
1856+
18261857
bool ResourceTable::hasBagOrEntry(const String16& ref,
18271858
const String16* defType,
18281859
const String16* defPackage)

tools/aapt/ResourceTable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ class ResourceTable : public ResTable::Accessor
124124
const String16& type,
125125
const String16& name) const;
126126

127+
bool hasBagOrEntry(const String16& package,
128+
const String16& type,
129+
const String16& name,
130+
const ResTable_config& config) const;
131+
127132
bool hasBagOrEntry(const String16& ref,
128133
const String16* defType = NULL,
129134
const String16* defPackage = NULL);

0 commit comments

Comments
 (0)