Revert "AAPT: Allow duplicate attribute definitions if identical"

This reverts commit c25283b5e206ceae2aa6eb01877b79c3c1f0adfb.

Change-Id: I2f42a4360fa53c4333494afe0178dcec56d62d8e
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index f979c84..e87c7d4 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -308,13 +308,29 @@
         }
         added = true;
 
-        if (!outTable->makeAttribute(myPackage, ident, sourcePos, type, comment, appendComment)) {
+        String16 attr16("attr");
+        
+        if (outTable->hasBagOrEntry(myPackage, attr16, ident)) {
             sourcePos.error("Attribute \"%s\" has already been defined\n",
                     String8(ident).string());
             hasErrors = true;
             return UNKNOWN_ERROR;
         }
-        return UNKNOWN_ERROR;
+        
+        char numberStr[16];
+        sprintf(numberStr, "%d", type);
+        status_t err = outTable->addBag(sourcePos, myPackage,
+                attr16, ident, String16(""),
+                String16("^type"),
+                String16(numberStr), NULL, NULL);
+        if (err != NO_ERROR) {
+            hasErrors = true;
+            return err;
+        }
+        outTable->appendComment(myPackage, attr16, ident, comment, appendComment);
+        //printf("Attribute %s comment: %s\n", String8(ident).string(),
+        //     String8(comment).string());
+        return err;
     }
 };
 
@@ -2099,50 +2115,6 @@
     return false;
 }
 
-bool ResourceTable::makeAttribute(const String16& package,
-                                  const String16& name,
-                                  const SourcePos& source,
-                                  int32_t format,
-                                  const String16& comment,
-                                  bool shouldAppendComment) {
-    const String16 attr16("attr");
-
-    // First look for this in the included resources...
-    uint32_t rid = mAssets->getIncludedResources()
-            .identifierForName(name.string(), name.size(),
-                               attr16.string(), attr16.size(),
-                               package.string(), package.size());
-    if (rid != 0) {
-        return false;
-    }
-
-    sp<ResourceTable::Entry> entry = getEntry(package, attr16, name, source, false);
-    if (entry == NULL) {
-        return false;
-    }
-
-    if (entry->makeItABag(source) != NO_ERROR) {
-        return false;
-    }
-
-    const String16 formatKey16("^type");
-    const String16 formatValue16(String8::format("%d", format));
-
-    ssize_t idx = entry->getBag().indexOfKey(formatKey16);
-    if (idx >= 0) {
-        // We have already set a format for this attribute, check if they are different.
-        // We allow duplicate attribute definitions so long as they are identical.
-        // This is to ensure interoperation with libraries that define the same generic attribute.
-        if (entry->getBag().valueAt(idx).value != formatValue16) {
-            return false;
-        }
-    } else {
-        entry->addToBag(source, formatKey16, formatValue16);
-    }
-    appendComment(package, attr16, name, comment, shouldAppendComment);
-    return true;
-}
-
 void ResourceTable::canAddEntry(const SourcePos& pos,
         const String16& package, const String16& type, const String16& name)
 {