AAPT2: Handle inflating compiled attributes.

* Added the resource ID pulled from the XML parser into the compiled
attribattribue. This allows binary attributes such as the version code
and min SDK values to be available whern flattening the XmlResource back
into an APK file.

* Only add a compiled value if the attribute value was not a string.
This allows string values like the package name and version name to be
flattened back into an APK file.

Before making this change, aapt would segfault when dumping the manifest
and dumping badging would be missing values. After making this change,
the manifest and badging are dumping correctly.

Test: ran unit tests
Test: manually ran optimize against an APK
Change-Id: I885bb06557b032b9f702e8065d637d359c2b519b
diff --git a/tools/aapt2/xml/XmlDom.cpp b/tools/aapt2/xml/XmlDom.cpp
index 19de3af..32ec7bc 100644
--- a/tools/aapt2/xml/XmlDom.cpp
+++ b/tools/aapt2/xml/XmlDom.cpp
@@ -236,16 +236,22 @@
         attr.name = util::Utf16ToUtf8(StringPiece16(str16, len));
       }
 
+      uint32_t res_id = parser->getAttributeNameResID(i);
+      if (res_id > 0) {
+        attr.compiled_attribute = AaptAttribute(::aapt::Attribute(), {res_id});
+      }
+
       str16 = parser->getAttributeStringValue(i, &len);
       if (str16) {
         attr.value = util::Utf16ToUtf8(StringPiece16(str16, len));
+      } else {
+        android::Res_value res_value;
+        if (parser->getAttributeValue(i, &res_value) > 0) {
+          attr.compiled_value = ResourceUtils::ParseBinaryResValue(
+              ResourceType::kAnim, {}, parser->getStrings(), res_value, out_pool);
+        }
       }
 
-      android::Res_value res_value;
-      if (parser->getAttributeValue(i, &res_value) > 0) {
-        attr.compiled_value = ResourceUtils::ParseBinaryResValue(
-            ResourceType::kAnim, {}, parser->getStrings(), res_value, out_pool);
-      }
 
       el->attributes.push_back(std::move(attr));
     }