X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/04f3dbd3b77006acd8e09b5c46f07d7f06f198ca..337efd6a727a249be478c824dbff5e11e98fee4e:/ResourceTable.cpp diff --git a/ResourceTable.cpp b/ResourceTable.cpp index 19b9b01..a2f085a 100644 --- a/ResourceTable.cpp +++ b/ResourceTable.cpp @@ -27,6 +27,20 @@ status_t compileXmlFile(const sp& assets, return compileXmlFile(assets, root, target, table, options); } +status_t compileXmlFile(const sp& assets, + const sp& target, + const sp& outTarget, + ResourceTable* table, + int options) +{ + sp root = XMLNode::parse(target); + if (root == NULL) { + return UNKNOWN_ERROR; + } + + return compileXmlFile(assets, root, outTarget, table, options); +} + status_t compileXmlFile(const sp& assets, const sp& root, const sp& target, @@ -39,6 +53,10 @@ status_t compileXmlFile(const sp& assets, root->removeWhitespace(false, NULL); } + if ((options&XML_COMPILE_UTF8) != 0) { + root->setUTF8(true); + } + bool hasErrors = false; if ((options&XML_COMPILE_ASSIGN_ATTRIBUTE_IDS) != 0) { @@ -378,7 +396,7 @@ static status_t compileAttribute(const sp& in, } attr.createIfNeeded(outTable); if (!attr.hasErrors) { - char buf[10]; + char buf[11]; sprintf(buf, "%d", l10n_required); err = outTable->addBag(attr.sourcePos, myPackage, attr16, attr.ident, String16(""), String16("^l10n"), String16(buf), NULL, NULL); @@ -1587,7 +1605,7 @@ status_t ResourceTable::startBag(const SourcePos& sourcePos, sourcePos.file.striing(), sourcePos.line, String8(type).string()); } #endif - if (overlay && !hasBagOrEntry(package, type, name)) { + if (overlay && !mBundle->getAutoAddOverlay() && !hasBagOrEntry(package, type, name)) { bool canAdd = false; sp p = mPackages.valueFor(package); if (p != NULL) { @@ -2365,7 +2383,7 @@ ResourceTable::validateLocalizations(void) if (configSet.find(region) == configSet.end()) { if (configSet.count(defaultLocale) == 0) { fprintf(stdout, "aapt: warning: " - "*** string '%s' has no default or required localization " + "**** string '%s' has no default or required localization " "for '%s' in %s\n", String8(nameIter->first).string(), config.string(), @@ -2468,6 +2486,12 @@ ResourceFilter::match(const ResTable_config& config) if (!match(AXIS_ORIENTATION, config.orientation)) { return false; } + if (!match(AXIS_UIMODETYPE, (config.uiMode&ResTable_config::MASK_UI_MODE_TYPE))) { + return false; + } + if (!match(AXIS_UIMODENIGHT, (config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT))) { + return false; + } if (!match(AXIS_DENSITY, config.density)) { return false; } @@ -2503,9 +2527,11 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) const size_t N = mOrderedPackages.size(); size_t pi; + bool useUTF8 = !bundle->getWantUTF16() && bundle->isMinSdkAtLeast(SDK_FROYO); + // Iterate through all data, collecting all values (strings, // references, etc). - StringPool valueStrings; + StringPool valueStrings = StringPool(false, useUTF8); for (pi=0; pi p = mOrderedPackages.itemAt(pi); if (p->getTypes().size() == 0) { @@ -2513,8 +2539,8 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) continue; } - StringPool typeStrings; - StringPool keyStrings; + StringPool typeStrings = StringPool(false, useUTF8); + StringPool keyStrings = StringPool(false, useUTF8); const size_t N = p->getOrderedTypes().size(); for (size_t ti=0; ti& dest) ConfigDescription config = t->getUniqueConfigs().itemAt(ci); NOISY(printf("Writing config %d config: imsi:%d/%d lang:%c%c cnt:%c%c " - "orien:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d\n", + "orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d\n", ti+1, config.mcc, config.mnc, config.language[0] ? config.language[0] : '-', @@ -2678,6 +2704,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) config.country[0] ? config.country[0] : '-', config.country[1] ? config.country[1] : '-', config.orientation, + config.uiMode, config.touchscreen, config.density, config.keyboard, @@ -2707,7 +2734,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) tHeader->entriesStart = htodl(typeSize); tHeader->config = config; NOISY(printf("Writing type %d config: imsi:%d/%d lang:%c%c cnt:%c%c " - "orien:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d\n", + "orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d\n", ti+1, tHeader->config.mcc, tHeader->config.mnc, tHeader->config.language[0] ? tHeader->config.language[0] : '-', @@ -2715,6 +2742,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp& dest) tHeader->config.country[0] ? tHeader->config.country[0] : '-', tHeader->config.country[1] ? tHeader->config.country[1] : '-', tHeader->config.orientation, + tHeader->config.uiMode, tHeader->config.touchscreen, tHeader->config.density, tHeader->config.keyboard, @@ -3275,12 +3303,13 @@ sp ResourceTable::Type::getEntry(const String16& entry, const SourcePos& sourcePos, const ResTable_config* config, bool doSetIndex, - bool overlay) + bool overlay, + bool autoAddOverlay) { int pos = -1; sp c = mConfigs.valueFor(entry); if (c == NULL) { - if (overlay == true && mCanAddEntries.indexOf(entry) < 0) { + if (overlay && !autoAddOverlay && mCanAddEntries.indexOf(entry) < 0) { sourcePos.error("Resource at %s appears in overlay but not" " in the base package; use to add.\n", String8(entry).string()); @@ -3592,7 +3621,7 @@ sp ResourceTable::getEntry(const String16& package, if (t == NULL) { return NULL; } - return t->getEntry(name, sourcePos, config, doSetIndex, overlay); + return t->getEntry(name, sourcePos, config, doSetIndex, overlay, mBundle->getAutoAddOverlay()); } sp ResourceTable::getEntry(uint32_t resID,