diff options
author | Yifan Hong | 2018-01-23 17:29:27 -0600 |
---|---|---|
committer | Yifan Hong | 2018-01-23 18:48:32 -0600 |
commit | 244970c81abe1fe28cb8ab2f1992b646bd07fce3 (patch) | |
tree | ea96fbf6366d5d475d8024ca078f490e36c5e8cb | |
parent | cbc3823cc32aa07dd06b8320c24c92664929a788 (diff) | |
download | platform-system-libvintf-244970c81abe1fe28cb8ab2f1992b646bd07fce3.tar.gz platform-system-libvintf-244970c81abe1fe28cb8ab2f1992b646bd07fce3.tar.xz platform-system-libvintf-244970c81abe1fe28cb8ab2f1992b646bd07fce3.zip |
CompatibilityMatrix: do not write <sepolicy> and <avb> if empty
They are parsed as optional tags, so it is okay to not write
them when they contain no values.
Test: libvintf_test
Change-Id: I5da7830e3838b25def874dd4ef01b20b900bac5f
-rw-r--r-- | parse_xml.cpp | 8 | ||||
-rw-r--r-- | test/LibVintfTest.cpp | 8 |
2 files changed, 7 insertions, 9 deletions
diff --git a/parse_xml.cpp b/parse_xml.cpp index 74ba880..5900f27 100644 --- a/parse_xml.cpp +++ b/parse_xml.cpp | |||
@@ -954,10 +954,14 @@ struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatri | |||
954 | appendChildren(root, matrixKernelConverter, m.framework.mKernels, d); | 954 | appendChildren(root, matrixKernelConverter, m.framework.mKernels, d); |
955 | } | 955 | } |
956 | if (!(flags & SerializeFlag::NO_SEPOLICY)) { | 956 | if (!(flags & SerializeFlag::NO_SEPOLICY)) { |
957 | appendChild(root, sepolicyConverter(m.framework.mSepolicy, d)); | 957 | if (!(m.framework.mSepolicy == Sepolicy{})) { |
958 | appendChild(root, sepolicyConverter(m.framework.mSepolicy, d)); | ||
959 | } | ||
958 | } | 960 | } |
959 | if (!(flags & SerializeFlag::NO_AVB)) { | 961 | if (!(flags & SerializeFlag::NO_AVB)) { |
960 | appendChild(root, avbConverter(m.framework.mAvbMetaVersion, d)); | 962 | if (!(m.framework.mAvbMetaVersion == Version{})) { |
963 | appendChild(root, avbConverter(m.framework.mAvbMetaVersion, d)); | ||
964 | } | ||
961 | } | 965 | } |
962 | } else if (m.mType == SchemaType::DEVICE) { | 966 | } else if (m.mType == SchemaType::DEVICE) { |
963 | if (!(flags & SerializeFlag::NO_VNDK)) { | 967 | if (!(flags & SerializeFlag::NO_VNDK)) { |
diff --git a/test/LibVintfTest.cpp b/test/LibVintfTest.cpp index d705243..e7a609a 100644 --- a/test/LibVintfTest.cpp +++ b/test/LibVintfTest.cpp | |||
@@ -1355,15 +1355,9 @@ TEST_F(LibVintfTest, HalManifestConverterXmlFile) { | |||
1355 | TEST_F(LibVintfTest, CompatibilityMatrixConverterXmlFile) { | 1355 | TEST_F(LibVintfTest, CompatibilityMatrixConverterXmlFile) { |
1356 | CompatibilityMatrix cm; | 1356 | CompatibilityMatrix cm; |
1357 | addXmlFile(cm, "media_profile", {1, 0}); | 1357 | addXmlFile(cm, "media_profile", {1, 0}); |
1358 | std::string xml = gCompatibilityMatrixConverter(cm); | 1358 | std::string xml = gCompatibilityMatrixConverter(cm, SerializeFlag::XMLFILES_ONLY); |
1359 | EXPECT_EQ(xml, | 1359 | EXPECT_EQ(xml, |
1360 | "<compatibility-matrix version=\"1.0\" type=\"framework\">\n" | 1360 | "<compatibility-matrix version=\"1.0\" type=\"framework\">\n" |
1361 | " <sepolicy>\n" | ||
1362 | " <kernel-sepolicy-version>0</kernel-sepolicy-version>\n" | ||
1363 | " </sepolicy>\n" | ||
1364 | " <avb>\n" | ||
1365 | " <vbmeta-version>0.0</vbmeta-version>\n" | ||
1366 | " </avb>\n" | ||
1367 | " <xmlfile format=\"dtd\" optional=\"true\">\n" | 1361 | " <xmlfile format=\"dtd\" optional=\"true\">\n" |
1368 | " <name>media_profile</name>\n" | 1362 | " <name>media_profile</name>\n" |
1369 | " <version>1.0</version>\n" | 1363 | " <version>1.0</version>\n" |