summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2016-11-15 14:57:23 -0600
committerYifan Hong2017-01-18 18:04:39 -0600
commit676447acd00ebf93d1023f79fc02b5cbbb86dda2 (patch)
tree0801cad97f4c86d6e390f4c273bac10b0adecfcd /ManifestHal.cpp
parent745e79f81c15db39e3278e226b35f0959342437a (diff)
downloadplatform-system-libvintf-676447acd00ebf93d1023f79fc02b5cbbb86dda2.tar.gz
platform-system-libvintf-676447acd00ebf93d1023f79fc02b5cbbb86dda2.tar.xz
platform-system-libvintf-676447acd00ebf93d1023f79fc02b5cbbb86dda2.zip
VendorManifest and CompatibilityMatrix from and to XML.
Usage: #include <vintf/VendorManifest.h> #include <vintf/parse_xml.h> VendorManifest vm; // ... std::string xml = gVendorManifestConverter(vm); VendorManifest vm2; bool success = gVendorManifestConverter(&vm2, xml); if (!success) ALOGW("%s", gVendorManifestConverter.lastError()); See Vendor Interface Object and Compatibility Matrix Design document and libvintf_test (test/main.cpp) for details. (Up to commit 4468534) Test: libvintf_test Bug: 32648352 Change-Id: I7e8ee8d2b9e61bf036e77a390712480cbbd452b4
Diffstat (limited to 'ManifestHal.cpp')
-rw-r--r--ManifestHal.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/ManifestHal.cpp b/ManifestHal.cpp
new file mode 100644
index 0000000..f69eb34
--- /dev/null
+++ b/ManifestHal.cpp
@@ -0,0 +1,73 @@
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "ManifestHal.h"
18#include <unordered_set>
19
20namespace android {
21namespace vintf {
22
23bool ManifestHal::isValid() const {
24 std::unordered_set<size_t> existing;
25 for (const auto &v : versions) {
26 if (existing.find(v.majorVer) != existing.end()) {
27 return false;
28 }
29 existing.insert(v.majorVer);
30 }
31 return true;
32}
33
34// static
35ManifestHal ManifestHal::hal(std::string &&name,
36 ImplLevel implLevel,
37 std::string &&impl,
38 Version version,
39 Transport tr) {
40 return ManifestHal{HalFormat::HIDL, std::move(name), {version},
41 {implLevel, std::move(impl)}, tr};
42}
43
44// static
45ManifestHal ManifestHal::hal(std::string &&name,
46 ImplLevel implLevel,
47 std::string &&impl,
48 std::vector<Version> &&versions,
49 Transport tr) {
50 return ManifestHal{HalFormat::HIDL, std::move(name), std::move(versions),
51 {implLevel, std::move(impl)}, tr};
52}
53
54// static
55ManifestHal ManifestHal::nonhal(std::string &&name,
56 std::vector<Version> &&versions) {
57 return ManifestHal{HalFormat::NATIVE, std::move(name), std::move(versions),
58 {ImplLevel::EMPTY, std::string{}}, Transport::EMPTY};
59}
60
61bool ManifestHal::operator==(const ManifestHal &other) const {
62 if (format != other.format)
63 return false;
64 if (name != other.name)
65 return false;
66 if (versions != other.versions)
67 return false;
68 // do not compare impl
69 return true;
70}
71
72} // namespace vintf
73} // namespace android