diff options
author | Adam Lesinski <adamlesinski@google.com> | 2017-06-01 17:16:44 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2017-06-01 17:16:44 -0700 |
commit | e597d68d33c76c2b830f5497ed4ba74c5193a056 (patch) | |
tree | 699e25d86f8ed610ef1b1b640efb5b86c89d4289 /tools/aapt2/ResourceParser.cpp | |
parent | ceb24e88cbb56aa63c990693a2d6ea35dce029f5 (diff) |
AAPT2: Allow any value type for <item> without format attr
TO bring AAPT2 behavior in-line with AAPT, <item> has a default
format of "any", and only becomes restricted with an explicit format
attribute.
Bug: 62260121
Test: make aapt2_tests
Change-Id: Ife416f520e6c2710bb30e3ba3f2d4463794bfa06
Diffstat (limited to 'tools/aapt2/ResourceParser.cpp')
-rw-r--r-- | tools/aapt2/ResourceParser.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp index 57ae2700127c..32e0fd52acfa 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; } |