AssembleVintf: fix error message for unsupported tags/attrs for additional manifests
The error message used to contain extraneous values like:
<manifest version="1.0" type="device" target-level="1">
<sepolicy>
<version>0.0</version>
</sepolicy>
</manifest>
Fix it so that it becomes:
<manifest target-level="1" />
Test: manual with additional manifest, then
`m device_manifest.xml`
Bug: 78943004
Change-Id: I2d66c4db5a5c2136907ac2dc814262909c73b9e0
diff --git a/parse_xml.cpp b/parse_xml.cpp
index 0aec6b8..ff6ecc2 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -865,15 +865,21 @@
}
void mutateNode(const HalManifest& m, NodeType* root, DocType* d,
SerializeFlags flags) const override {
- appendAttr(root, "version", m.getMetaVersion());
- appendAttr(root, "type", m.mType);
+ if (flags.isMetaVersionEnabled()) {
+ appendAttr(root, "version", m.getMetaVersion());
+ }
+ if (flags.isSchemaTypeEnabled()) {
+ appendAttr(root, "type", m.mType);
+ }
if (flags.isHalsEnabled()) {
appendChildren(root, manifestHalConverter, m.getHals(), d, flags);
}
if (m.mType == SchemaType::DEVICE) {
if (flags.isSepolicyEnabled()) {
- appendChild(root, halManifestSepolicyConverter(m.device.mSepolicyVersion, d));
+ if (m.device.mSepolicyVersion != Version{}) {
+ appendChild(root, halManifestSepolicyConverter(m.device.mSepolicyVersion, d));
+ }
}
if (m.mLevel != Level::UNSPECIFIED) {
this->appendAttr(root, "target-level", m.mLevel);
@@ -1026,8 +1032,12 @@
}
void mutateNode(const CompatibilityMatrix& m, NodeType* root, DocType* d,
SerializeFlags flags) const override {
- appendAttr(root, "version", m.getMinimumMetaVersion());
- appendAttr(root, "type", m.mType);
+ if (flags.isMetaVersionEnabled()) {
+ appendAttr(root, "version", m.getMinimumMetaVersion());
+ }
+ if (flags.isSchemaTypeEnabled()) {
+ appendAttr(root, "type", m.mType);
+ }
if (flags.isHalsEnabled()) {
appendChildren(root, matrixHalConverter, iterateValues(m.mHals), d);