]> git.saurik.com Git - android/aapt.git/blobdiff - ResourceTable.cpp
AI 144413: am: CL 144342 Fix bag (string-array,etc) behavior with overlays.
[android/aapt.git] / ResourceTable.cpp
index 877763dd4777d6decfff8b912798c0effde8a21c..6e522a2c74c80a71b367e1f9a594e2897b1bf8b4 100644 (file)
@@ -644,6 +644,7 @@ status_t compileResourceFile(Bundle* bundle,
     const String16 bool16("bool");
     const String16 integer16("integer");
     const String16 dimen16("dimen");
+    const String16 fraction16("fraction");
     const String16 style16("style");
     const String16 plurals16("plurals");
     const String16 array16("array");
@@ -1022,6 +1023,10 @@ status_t compileResourceFile(Bundle* bundle,
                 curTag = &dimen16;
                 curType = dimen16;
                 curFormat = ResTable_map::TYPE_REFERENCE|ResTable_map::TYPE_DIMENSION;
+            } else if (strcmp16(block.getElementName(&len), fraction16.string()) == 0) {
+                curTag = &fraction16;
+                curType = fraction16;
+                curFormat = ResTable_map::TYPE_REFERENCE|ResTable_map::TYPE_FRACTION;
             } else if (strcmp16(block.getElementName(&len), bag16.string()) == 0) {
                 curTag = &bag16;
                 curIsBag = true;
@@ -1104,7 +1109,8 @@ status_t compileResourceFile(Bundle* bundle,
 
                 if (!localHasErrors) {
                     err = outTable->startBag(SourcePos(in->getPrintableSource(), block.getLineNumber()),
-                                             myPackage, curType, ident, parentIdent, &curParams);
+                                             myPackage, curType, ident, parentIdent, &curParams, 
+                                             overwrite);
                     if (err != NO_ERROR) {
                         hasErrors = localHasErrors = true;
                     }
@@ -1404,6 +1410,8 @@ status_t ResourceTable::startBag(const SourcePos& sourcePos,
                                  const ResTable_config* params,
                                  bool replace, bool isId)
 {
+    status_t result = NO_ERROR;
+
     // Check for adding entries in other packages...  for now we do
     // nothing.  We need to do the right thing here to support skinning.
     uint32_t rid = mAssets->getIncludedResources()
@@ -1437,8 +1445,12 @@ status_t ResourceTable::startBag(const SourcePos& sourcePos,
         }
         e->setParent(bagParent);
     }
-    
-    return e->makeItABag(sourcePos);
+
+    if ((result = e->makeItABag(sourcePos)) != NO_ERROR) {
+        return result;
+    }
+    return e->emptyBag(sourcePos);
 }
 
 status_t ResourceTable::addBag(const SourcePos& sourcePos,
@@ -2165,15 +2177,14 @@ ResourceTable::validateLocalizations(void)
                         // consider that string to have fulfilled the localization requirement.
                         String8 region(config.string(), 2);
                         if (configSet.find(region) == configSet.end()) {
-                            // TODO: force an error if there is no default to fall back to
                             if (configSet.count(defaultLocale) == 0) {
-                                fprintf(stdout, "aapt: warning: "
+                                fprintf(stdout, "aapt: error: "
                                         "*** string '%s' has no default or required localization "
                                         "for '%s' in %s\n",
                                         String8(nameIter->first).string(),
                                         config.string(),
                                         mBundle->getResourceSourceDirs()[0]);
-                                //err = UNKNOWN_ERROR;
+                                err = UNKNOWN_ERROR;
                             }
                         }
                     }
@@ -2794,6 +2805,17 @@ status_t ResourceTable::Entry::addToBag(const SourcePos& sourcePos,
     return NO_ERROR;
 }
 
+status_t ResourceTable::Entry::emptyBag(const SourcePos& sourcePos)
+{
+    status_t err = makeItABag(sourcePos);
+    if (err != NO_ERROR) {
+        return err;
+    }
+
+    mBag.clear();
+    return NO_ERROR;
+}
+
 status_t ResourceTable::Entry::generateAttributes(ResourceTable* table,
                                                   const String16& package)
 {