summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceParser.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-06-02 02:35:07 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-02 02:35:07 +0000
commit3c860ed41d2f1cb2b756558b186f6304d6e9b674 (patch)
treeb35097c53b9da9dec5c6ea30a2ad9b4d68d4b96e /tools/aapt2/ResourceParser.cpp
parent74ff0748ce6db59e01ca78aaf3877f46b95dfbc9 (diff)
parent1ac325e4d5d0e03271b4c67b56117d39bcdcfaeb (diff)
Merge "AAPT2: Allow any value type for <item> without format attr" into oc-dev
am: 1ac325e4d5 Change-Id: I1b1180f2b33a077b2c46a8466c58d83ed618576e
Diffstat (limited to 'tools/aapt2/ResourceParser.cpp')
-rw-r--r--tools/aapt2/ResourceParser.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index bc133781df6a..084325a44d93 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -415,6 +415,10 @@ bool ResourceParser::ParseResource(xml::XmlPullParser* parser,
if (resource_type == "item") {
can_be_bag = false;
+ // The default format for <item> is any. If a format attribute is present, that one will
+ // override the default.
+ resource_format = android::ResTable_map::TYPE_ANY;
+
// Items have their type encoded in the type attribute.
if (Maybe<StringPiece> maybe_type = xml::FindNonEmptyAttribute(parser, "type")) {
resource_type = maybe_type.value().to_string();
@@ -481,8 +485,8 @@ bool ResourceParser::ParseResource(xml::XmlPullParser* parser,
out_resource->name.type = item_iter->second.type;
out_resource->name.entry = maybe_name.value().to_string();
- // Only use the implicit format for this type if it wasn't overridden.
- if (!resource_format) {
+ // Only use the implied format of the type when there is no explicit format.
+ if (resource_format == 0u) {
resource_format = item_iter->second.format;
}