summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2018-03-13 14:36:38 -0500
committerYifan Hong2018-03-14 19:35:18 -0500
commit2b1efaa1de422f702e8b2ab4b922b8408da188cd (patch)
treee3cdb7f486cbcc9b5053a914e3b783ae57ac2ebe /parse_xml.cpp
parent075b363fb67edc80e688ea5de75fb1fb122509b1 (diff)
downloadplatform-system-libvintf-2b1efaa1de422f702e8b2ab4b922b8408da188cd.tar.gz
platform-system-libvintf-2b1efaa1de422f702e8b2ab4b922b8408da188cd.tar.xz
platform-system-libvintf-2b1efaa1de422f702e8b2ab4b922b8408da188cd.zip
Add <fqname> to manifests.
The format of <fqname> is: <hal> <name>android.hardware.foo</name> <!-- transport, etc. --> <fqname>@1.0::IFoo/default</fqname> </hal> It is possible to mix <fqname> and <version> x <interface> x <instance> ; see tests for details. This allows instances at different versions. For example, it is now allowed to serve @1.0::IFoo/default, @1.1::IFoo/custom simultaneously without serving @1.1::IFoo/default. If override="true" and no <version>x<interface>x<instance> nor <fqname>, the HAL tag is disabled. (Previously, the HAL tag is disabled iff no <version> exists). Bug: 73556059 Test: libvintf_test Test: vintf_object_test Change-Id: I80cb9ccdeec708c2c5530812913b37f8b3cc3ffa
Diffstat (limited to 'parse_xml.cpp')
-rw-r--r--parse_xml.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/parse_xml.cpp b/parse_xml.cpp
index bf8889f..38a09b4 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -230,11 +230,12 @@ struct XmlNodeConverter : public XmlConverter<Object> {
230 } 230 }
231 } 231 }
232 232
233 template<typename T, typename Array> 233 template <typename T, typename Array>
234 inline void appendChildren(NodeType *parent, const XmlNodeConverter<T> &conv, 234 inline void appendChildren(NodeType* parent, const XmlNodeConverter<T>& conv,
235 const Array &array, DocType *d) const { 235 const Array& array, DocType* d,
236 SerializeFlags flags = SerializeFlag::EVERYTHING) const {
236 for (const T &t : array) { 237 for (const T &t : array) {
237 appendChild(parent, conv(t, d)); 238 appendChild(parent, conv.serialize(t, d, flags));
238 } 239 }
239 } 240 }
240 241
@@ -600,9 +601,15 @@ struct MatrixKernelConverter : public XmlNodeConverter<MatrixKernel> {
600 601
601MatrixKernelConverter matrixKernelConverter{}; 602MatrixKernelConverter matrixKernelConverter{};
602 603
604XmlTextConverter<FqInstance> fqInstanceConverter{"fqname"};
605
603struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> { 606struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
604 std::string elementName() const override { return "hal"; } 607 std::string elementName() const override { return "hal"; }
605 void mutateNode(const ManifestHal &hal, NodeType *root, DocType *d) const override { 608 void mutateNode(const ManifestHal& m, NodeType* root, DocType* d) const override {
609 mutateNode(m, root, d, SerializeFlag::EVERYTHING);
610 }
611 void mutateNode(const ManifestHal& hal, NodeType* root, DocType* d,
612 SerializeFlags flags) const override {
606 appendAttr(root, "format", hal.format); 613 appendAttr(root, "format", hal.format);
607 appendTextElement(root, "name", hal.name, d); 614 appendTextElement(root, "name", hal.name, d);
608 appendChild(root, transportArchConverter(hal.transportArch, d)); 615 appendChild(root, transportArchConverter(hal.transportArch, d));
@@ -611,6 +618,15 @@ struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
611 if (hal.isOverride()) { 618 if (hal.isOverride()) {
612 appendAttr(root, "override", hal.isOverride()); 619 appendAttr(root, "override", hal.isOverride());
613 } 620 }
621
622 if (!(flags & SerializeFlag::NO_FQNAME)) {
623 std::set<FqInstance> fqInstances;
624 hal.forEachInstance([&fqInstances](const auto& manifestInstance) {
625 fqInstances.emplace(manifestInstance.getFqInstanceNoPackage());
626 return true;
627 });
628 appendChildren(root, fqInstanceConverter, fqInstances, d);
629 }
614 } 630 }
615 bool buildObject(ManifestHal* object, NodeType* root, std::string* error) const override { 631 bool buildObject(ManifestHal* object, NodeType* root, std::string* error) const override {
616 std::vector<HalInterface> interfaces; 632 std::vector<HalInterface> interfaces;
@@ -666,6 +682,15 @@ struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
666 return false; 682 return false;
667 } 683 }
668#endif 684#endif
685
686 std::set<FqInstance> fqInstances;
687 if (!parseChildren(root, fqInstanceConverter, &fqInstances, error)) {
688 return false;
689 }
690 if (!object->insertInstances(fqInstances, error)) {
691 return false;
692 }
693
669 return true; 694 return true;
670 } 695 }
671 696
@@ -808,7 +833,7 @@ struct HalManifestConverter : public XmlNodeConverter<HalManifest> {
808 appendAttr(root, "type", m.mType); 833 appendAttr(root, "type", m.mType);
809 834
810 if (!(flags & SerializeFlag::NO_HALS)) { 835 if (!(flags & SerializeFlag::NO_HALS)) {
811 appendChildren(root, manifestHalConverter, m.getHals(), d); 836 appendChildren(root, manifestHalConverter, m.getHals(), d, flags);
812 } 837 }
813 if (m.mType == SchemaType::DEVICE) { 838 if (m.mType == SchemaType::DEVICE) {
814 if (!(flags & SerializeFlag::NO_SEPOLICY)) { 839 if (!(flags & SerializeFlag::NO_SEPOLICY)) {