AAPT2: Fix issue where generated XML would be tagged with UNKNOWN type
CompiledFiles with UNKNOWN type are copied through, leading to protobuf
outputs in the final APK.
Test: make aapt2_tests
Change-Id: Ia0c464caa3951ff27436d1d50c2a8555bc89302b
diff --git a/tools/aapt2/compile/InlineXmlFormatParser.cpp b/tools/aapt2/compile/InlineXmlFormatParser.cpp
index a179260..99b4c31 100644
--- a/tools/aapt2/compile/InlineXmlFormatParser.cpp
+++ b/tools/aapt2/compile/InlineXmlFormatParser.cpp
@@ -118,10 +118,11 @@
size_t name_suffix_counter = 0;
for (const InlineDeclaration& decl : visitor.GetInlineDeclarations()) {
- auto new_doc = util::make_unique<xml::XmlResource>();
- new_doc->file.config = doc->file.config;
- new_doc->file.source = doc->file.source.WithLine(decl.el->line_number);
- new_doc->file.name = doc->file.name;
+ // Create a new XmlResource with the same ResourceFile as the base XmlResource.
+ auto new_doc = util::make_unique<xml::XmlResource>(doc->file);
+
+ // Attach the line number.
+ new_doc->file.source.line = decl.el->line_number;
// Modify the new entry name. We need to suffix the entry with a number to
// avoid local collisions, then mangle it with the empty package, such that it won't show up