summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2018-03-20 15:06:00 -0500
committerYifan Hong2018-03-22 16:54:15 -0500
commit7e9e04d10d74377a13d36d3f945b1cbc1aaf1a50 (patch)
treeebd240c54df6a79a9460d7ebea539dae2e93392c /ManifestHal.cpp
parent85103c60a46945fbd318d3c1e2d9a0bb5768c948 (diff)
downloadplatform-system-libvintf-7e9e04d10d74377a13d36d3f945b1cbc1aaf1a50.tar.gz
platform-system-libvintf-7e9e04d10d74377a13d36d3f945b1cbc1aaf1a50.tar.xz
platform-system-libvintf-7e9e04d10d74377a13d36d3f945b1cbc1aaf1a50.zip
regex-instance: HalInterface: add regex API and hide public fields
<regex-instance> is added under an <interface> tag, which is represented by an HalInterface object. Add API for looping over all <regex-instance>s / <instance>s under it. With this API, HalInterface can hide its public fields. Bug: 73738616 Test: libvintf_test Test: vintf_object_test Test: vts_treble_vintf_test Change-Id: Ia072dd7e946c28789797db8a46fd968bc7872dca
Diffstat (limited to 'ManifestHal.cpp')
-rw-r--r--ManifestHal.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/ManifestHal.cpp b/ManifestHal.cpp
index c0f4c8e..2d0e246 100644
--- a/ManifestHal.cpp
+++ b/ManifestHal.cpp
@@ -51,15 +51,20 @@ bool ManifestHal::operator==(const ManifestHal &other) const {
51bool ManifestHal::forEachInstance(const std::function<bool(const ManifestInstance&)>& func) const { 51bool ManifestHal::forEachInstance(const std::function<bool(const ManifestInstance&)>& func) const {
52 for (const auto& v : versions) { 52 for (const auto& v : versions) {
53 for (const auto& intf : iterateValues(interfaces)) { 53 for (const auto& intf : iterateValues(interfaces)) {
54 for (const auto& instance : intf.instances) { 54 bool cont = intf.forEachInstance([&](const auto& interface, const auto& instance,
55 bool /* isRegex */) {
55 // TODO(b/73556059): Store ManifestInstance as well to avoid creating temps 56 // TODO(b/73556059): Store ManifestInstance as well to avoid creating temps
56 FqInstance fqInstance; 57 FqInstance fqInstance;
57 if (fqInstance.setTo(getName(), v.majorVer, v.minorVer, intf.name, instance)) { 58 if (fqInstance.setTo(getName(), v.majorVer, v.minorVer, interface, instance)) {
58 if (!func(ManifestInstance(std::move(fqInstance), TransportArch{transportArch}, 59 if (!func(ManifestInstance(std::move(fqInstance), TransportArch{transportArch},
59 format))) { 60 format))) {
60 return false; 61 return false;
61 } 62 }
62 } 63 }
64 return true;
65 });
66 if (!cont) {
67 return false;
63 } 68 }
64 } 69 }
65 } 70 }
@@ -135,5 +140,12 @@ bool ManifestHal::insertInstances(const std::set<FqInstance>& fqInstances, std::
135 return true; 140 return true;
136} 141}
137 142
143void ManifestHal::insertLegacyInstance(const std::string& interface, const std::string& instance) {
144 auto it = interfaces.find(interface);
145 if (it == interfaces.end())
146 it = interfaces.emplace(interface, HalInterface{interface, {}}).first;
147 it->second.insertInstance(instance, false /* isRegex */);
148}
149
138} // namespace vintf 150} // namespace vintf
139} // namespace android 151} // namespace android