summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'parse_xml.cpp')
-rw-r--r--parse_xml.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/parse_xml.cpp b/parse_xml.cpp
index 0094f81..1a0626a 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -25,6 +25,7 @@
25 25
26#include <tinyxml2.h> 26#include <tinyxml2.h>
27 27
28#include "constants.h"
28#include "parse_string.h" 29#include "parse_string.h"
29 30
30namespace android { 31namespace android {
@@ -43,7 +44,7 @@ inline DocType *createDocument() {
43// caller is responsible for deleteDocument() call 44// caller is responsible for deleteDocument() call
44inline DocType *createDocument(const std::string &xml) { 45inline DocType *createDocument(const std::string &xml) {
45 DocType *doc = new tinyxml2::XMLDocument(); 46 DocType *doc = new tinyxml2::XMLDocument();
46 if (doc->Parse(xml.c_str()) == tinyxml2::XML_NO_ERROR) { 47 if (doc->Parse(xml.c_str()) == tinyxml2::XML_SUCCESS) {
47 return doc; 48 return doc;
48 } 49 }
49 delete doc; 50 delete doc;
@@ -745,7 +746,7 @@ const ManifestXmlFileConverter manifestXmlFileConverter{};
745struct HalManifestConverter : public XmlNodeConverter<HalManifest> { 746struct HalManifestConverter : public XmlNodeConverter<HalManifest> {
746 std::string elementName() const override { return "manifest"; } 747 std::string elementName() const override { return "manifest"; }
747 void mutateNode(const HalManifest &m, NodeType *root, DocType *d) const override { 748 void mutateNode(const HalManifest &m, NodeType *root, DocType *d) const override {
748 appendAttr(root, "version", HalManifest::kVersion); 749 appendAttr(root, "version", m.getMetaVersion());
749 appendAttr(root, "type", m.mType); 750 appendAttr(root, "type", m.mType);
750 751
751 appendChildren(root, manifestHalConverter, m.getHals(), d); 752 appendChildren(root, manifestHalConverter, m.getHals(), d);
@@ -758,15 +759,15 @@ struct HalManifestConverter : public XmlNodeConverter<HalManifest> {
758 appendChildren(root, manifestXmlFileConverter, m.getXmlFiles(), d); 759 appendChildren(root, manifestXmlFileConverter, m.getXmlFiles(), d);
759 } 760 }
760 bool buildObject(HalManifest *object, NodeType *root) const override { 761 bool buildObject(HalManifest *object, NodeType *root) const override {
761 Version version;
762 std::vector<ManifestHal> hals; 762 std::vector<ManifestHal> hals;
763 if (!parseAttr(root, "version", &version) || 763 if (!parseAttr(root, "version", &object->mMetaVersion) ||
764 !parseAttr(root, "type", &object->mType) || 764 !parseAttr(root, "type", &object->mType) ||
765 !parseChildren(root, manifestHalConverter, &hals)) { 765 !parseChildren(root, manifestHalConverter, &hals)) {
766 return false; 766 return false;
767 } 767 }
768 if (version != HalManifest::kVersion) { 768 if (!kMetaVersion.minorAtLeast(object->mMetaVersion)) {
769 this->mLastError = "Unrecognized manifest.version"; 769 this->mLastError = "Unrecognized manifest.version " + to_string(object->mMetaVersion) +
770 " (libvintf@" + to_string(kMetaVersion) + ")";
770 return false; 771 return false;
771 } 772 }
772 if (object->mType == SchemaType::DEVICE) { 773 if (object->mType == SchemaType::DEVICE) {
@@ -855,7 +856,7 @@ const MatrixXmlFileConverter matrixXmlFileConverter{};
855struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatrix> { 856struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatrix> {
856 std::string elementName() const override { return "compatibility-matrix"; } 857 std::string elementName() const override { return "compatibility-matrix"; }
857 void mutateNode(const CompatibilityMatrix &m, NodeType *root, DocType *d) const override { 858 void mutateNode(const CompatibilityMatrix &m, NodeType *root, DocType *d) const override {
858 appendAttr(root, "version", CompatibilityMatrix::kVersion); 859 appendAttr(root, "version", m.getMinimumMetaVersion());
859 appendAttr(root, "type", m.mType); 860 appendAttr(root, "type", m.mType);
860 appendChildren(root, matrixHalConverter, iterateValues(m.mHals), d); 861 appendChildren(root, matrixHalConverter, iterateValues(m.mHals), d);
861 if (m.mType == SchemaType::FRAMEWORK) { 862 if (m.mType == SchemaType::FRAMEWORK) {
@@ -908,8 +909,9 @@ struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatri
908 } 909 }
909 } 910 }
910 911
911 if (version != CompatibilityMatrix::kVersion) { 912 if (!kMetaVersion.minorAtLeast(version)) {
912 this->mLastError = "Unrecognized compatibility-matrix.version"; 913 this->mLastError = "Unrecognized compatibility-matrix.version " + to_string(version) +
914 " (libvintf@" + to_string(kMetaVersion) + ")";
913 return false; 915 return false;
914 } 916 }
915 for (auto &&hal : hals) { 917 for (auto &&hal : hals) {