summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2017-08-07 16:40:19 -0500
committerYifan Hong2017-08-07 17:19:35 -0500
commit41ca2a824cb5ecf101091bc2212812985c3f0034 (patch)
tree69a749c644ea0b6de7bb72aaad5055729c1c4404 /parse_xml.cpp
parent7b6f8c93d08a7b62b1fa8f5fb75a7df5635e64d3 (diff)
downloadplatform-system-libvintf-41ca2a824cb5ecf101091bc2212812985c3f0034.tar.gz
platform-system-libvintf-41ca2a824cb5ecf101091bc2212812985c3f0034.tar.xz
platform-system-libvintf-41ca2a824cb5ecf101091bc2212812985c3f0034.zip
Native HALs don't require <transport>.
This is stated in go/android-treble-vintf-object but the code was not well tested. Fortunately, native HALs are not used (until now), so we need to conform to the documentation here. Test: libvintf_test Bug: 64447338 Change-Id: I00d96137d4052d9da50f696ef665a73d09d818a7 Merged-In: I00d96137d4052d9da50f696ef665a73d09d818a7
Diffstat (limited to 'parse_xml.cpp')
-rw-r--r--parse_xml.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/parse_xml.cpp b/parse_xml.cpp
index f12df00..518faec 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -16,10 +16,16 @@
16 16
17// Convert objects from and to xml. 17// Convert objects from and to xml.
18 18
19#define LOG_TAG "libvintf"
20#include <android-base/logging.h>
21
22#include "parse_xml.h"
23
24#include <type_traits>
25
19#include <tinyxml2.h> 26#include <tinyxml2.h>
20 27
21#include "parse_string.h" 28#include "parse_string.h"
22#include "parse_xml.h"
23 29
24namespace android { 30namespace android {
25namespace vintf { 31namespace vintf {
@@ -539,11 +545,35 @@ struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
539 std::vector<HalInterface> interfaces; 545 std::vector<HalInterface> interfaces;
540 if (!parseOptionalAttr(root, "format", HalFormat::HIDL, &object->format) || 546 if (!parseOptionalAttr(root, "format", HalFormat::HIDL, &object->format) ||
541 !parseTextElement(root, "name", &object->name) || 547 !parseTextElement(root, "name", &object->name) ||
542 !parseChild(root, transportArchConverter, &object->transportArch) || 548 !parseOptionalChild(root, transportArchConverter, {}, &object->transportArch) ||
543 !parseChildren(root, versionConverter, &object->versions) || 549 !parseChildren(root, versionConverter, &object->versions) ||
544 !parseChildren(root, halInterfaceConverter, &interfaces)) { 550 !parseChildren(root, halInterfaceConverter, &interfaces)) {
545 return false; 551 return false;
546 } 552 }
553
554 switch (object->format) {
555 case HalFormat::HIDL: {
556 if (object->transportArch.empty()) {
557 this->mLastError =
558 "HIDL HAL '" + object->name + "' should have <transport> defined.";
559 return false;
560 }
561 } break;
562 case HalFormat::NATIVE: {
563 if (!object->transportArch.empty()) {
564 this->mLastError =
565 "Native HAL '" + object->name + "' should not have <transport> defined.";
566 return false;
567 }
568 } break;
569 default: {
570 LOG(FATAL) << "Unhandled HalFormat "
571 << static_cast<typename std::underlying_type<HalFormat>::type>(
572 object->format);
573 } break;
574 }
575 if (!object->transportArch.isValid()) return false;
576
547 object->interfaces.clear(); 577 object->interfaces.clear();
548 for (auto &&interface : interfaces) { 578 for (auto &&interface : interfaces) {
549 auto res = object->interfaces.emplace(interface.name, 579 auto res = object->interfaces.emplace(interface.name,