summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2017-08-15 19:14:52 -0500
committerYifan Hong2017-08-16 15:50:18 -0500
commitcef6437c31623647ec2200d46272f7ac5485aeb1 (patch)
treec6659d8ed65768783c44a2ad34a2dec1ff1c6a00 /parse_xml.cpp
parenta1bb1935a7e413ef66c046e09b7211b5ac4591bd (diff)
downloadplatform-system-libvintf-cef6437c31623647ec2200d46272f7ac5485aeb1.tar.gz
platform-system-libvintf-cef6437c31623647ec2200d46272f7ac5485aeb1.tar.xz
platform-system-libvintf-cef6437c31623647ec2200d46272f7ac5485aeb1.zip
Add hardcoded version checks for netutils-wrapper
Each version bump of netutils-wrapper lose some functionality, and hence only the major version is bumped. Also, vendor code should only depend on a single version of netutils-wrapper. Hardcode this requirement in host-side libvintf to check compatibility when framework manifest and device compatibility matrix is built. Test: host libvintf_test Test: target libvintf_test Test: host vintf_object_test Test: target vintf_object_test Test: m system_manifest.xml compatibility_matrix.xml Test: boots Bug: 64447338 Change-Id: I75c28f3e021d16860e4577c3ecfaec2bd89d8a3d
Diffstat (limited to 'parse_xml.cpp')
-rw-r--r--parse_xml.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/parse_xml.cpp b/parse_xml.cpp
index 518faec..5239275 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -507,8 +507,44 @@ struct MatrixHalConverter : public XmlNodeConverter<MatrixHal> {
507 return false; 507 return false;
508 } 508 }
509 } 509 }
510// Do not check for target-side libvintf to avoid restricting ability for upgrade accidentally.
511#ifdef LIBVINTF_HOST
512 if (!checkAdditionalRestrictionsOnHal(*object)) {
513 return false;
514 }
515#endif
516 return true;
517 }
518
519#ifdef LIBVINTF_HOST
520 private:
521 bool checkAdditionalRestrictionsOnHal(const MatrixHal& hal) const {
522 if (hal.getName() == "netutils-wrapper") {
523 if (hal.versionRanges.size() != 1) {
524 this->mLastError =
525 "netutils-wrapper HAL must specify exactly one version x.0, "
526 "but multiple <version> element is specified.";
527 return false;
528 }
529 const VersionRange& v = hal.versionRanges.at(0);
530 if (!v.isSingleVersion()) {
531 this->mLastError =
532 "netutils-wrapper HAL must specify exactly one version x.0, "
533 "but a range is provided. Perhaps you mean '" +
534 to_string(Version{v.majorVer, 0}) + "'?";
535 return false;
536 }
537 if (v.minMinor != 0) {
538 this->mLastError =
539 "netutils-wrapper HAL must specify exactly one version x.0, "
540 "but minor version is not 0. Perhaps you mean '" +
541 to_string(Version{v.majorVer, 0}) + "'?";
542 return false;
543 }
544 }
510 return true; 545 return true;
511 } 546 }
547#endif
512}; 548};
513 549
514const MatrixHalConverter matrixHalConverter{}; 550const MatrixHalConverter matrixHalConverter{};
@@ -589,8 +625,32 @@ struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
589 this->mLastError = "'" + object->name + "' is not a valid Manifest HAL."; 625 this->mLastError = "'" + object->name + "' is not a valid Manifest HAL.";
590 return false; 626 return false;
591 } 627 }
628// Do not check for target-side libvintf to avoid restricting upgrade accidentally.
629#ifdef LIBVINTF_HOST
630 if (!checkAdditionalRestrictionsOnHal(*object)) {
631 return false;
632 }
633#endif
634 return true;
635 }
636
637#ifdef LIBVINTF_HOST
638 private:
639 bool checkAdditionalRestrictionsOnHal(const ManifestHal& hal) const {
640 if (hal.getName() == "netutils-wrapper") {
641 for (const Version& v : hal.versions) {
642 if (v.minorVer != 0) {
643 this->mLastError =
644 "netutils-wrapper HAL must specify exactly one version x.0, "
645 "but minor version is not 0. Perhaps you mean '" +
646 to_string(Version{v.majorVer, 0}) + "'?";
647 return false;
648 }
649 }
650 }
592 return true; 651 return true;
593 } 652 }
653#endif
594}; 654};
595 655
596// Convert ManifestHal from and to XML. Returned object is guaranteed to have 656// Convert ManifestHal from and to XML. Returned object is guaranteed to have