summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2018-03-21 02:23:35 -0500
committerandroid-build-team Robot2018-03-21 02:23:35 -0500
commit106ff9b2fb1fdc39190c995312f9341efd5f0cb9 (patch)
tree14e74f0e470e73aa417783c52eeed9060527d5b4
parent8d5f214fac328f720d703d010b28bc8bc5d625f7 (diff)
parent957093ba8b0e5cd8e3e09cec8389015de86962e2 (diff)
downloadplatform-system-libvintf-106ff9b2fb1fdc39190c995312f9341efd5f0cb9.tar.gz
platform-system-libvintf-106ff9b2fb1fdc39190c995312f9341efd5f0cb9.tar.xz
platform-system-libvintf-106ff9b2fb1fdc39190c995312f9341efd5f0cb9.zip
Snap for 4667902 from 957093ba8b0e5cd8e3e09cec8389015de86962e2 to pi-release
Change-Id: I2655482a31b8279508b9d6c1f1923d50d6b4fcc4
-rw-r--r--HalManifest.cpp78
-rw-r--r--ManifestHal.cpp6
-rw-r--r--ManifestInstance.cpp20
-rw-r--r--include/vintf/HalManifest.h7
-rw-r--r--include/vintf/ManifestInstance.h7
-rw-r--r--include/vintf/VintfObject.h2
-rw-r--r--test/LibVintfTest.cpp3
7 files changed, 47 insertions, 76 deletions
diff --git a/HalManifest.cpp b/HalManifest.cpp
index aee4462..a884b1f 100644
--- a/HalManifest.cpp
+++ b/HalManifest.cpp
@@ -123,58 +123,27 @@ std::set<std::string> HalManifest::getHalNames() const {
123 123
124std::set<std::string> HalManifest::getHalNamesAndVersions() const { 124std::set<std::string> HalManifest::getHalNamesAndVersions() const {
125 std::set<std::string> names{}; 125 std::set<std::string> names{};
126 for (const auto &hal : getHals()) { 126 forEachInstance([&names](const ManifestInstance& e) {
127 for (const auto &version : hal.versions) { 127 names.insert(toFQNameString(e.interface(), e.version()));
128 names.insert(toFQNameString(hal.name, version)); 128 return true;
129 } 129 });
130 }
131 return names; 130 return names;
132} 131}
133 132
134Transport HalManifest::getTransport(const std::string &package, const Version &v, 133Transport HalManifest::getTransport(const std::string &package, const Version &v,
135 const std::string &interfaceName, const std::string &instanceName) const { 134 const std::string &interfaceName, const std::string &instanceName) const {
136 135 Transport transport{Transport::EMPTY};
137 for (const ManifestHal *hal : getHals(package)) { 136 forEachInstanceOfInterface(package, v, interfaceName, [&](const auto& e) {
138 bool found = false; 137 if (e.instance() == instanceName) {
139 for (auto& ver : hal->versions) { 138 transport = e.transport();
140 if (ver.majorVer == v.majorVer && ver.minorVer >= v.minorVer) {
141 found = true;
142 break;
143 }
144 }
145 if (!found) {
146 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType) << "): Cannot find "
147 << to_string(v) << " in supported versions of " << package;
148 continue;
149 } 139 }
150 auto it = hal->interfaces.find(interfaceName); 140 return transport == Transport::EMPTY; // if not found, continue
151 if (it == hal->interfaces.end()) { 141 });
152 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType) 142 if (transport == Transport::EMPTY) {
153 << "): Cannot find interface '" << interfaceName << "' in " 143 LOG(DEBUG) << "HalManifest::getTransport(" << mType << "): Cannot find "
154 << toFQNameString(package, v); 144 << toFQNameString(package, v, interfaceName, instanceName);
155 continue;
156 }
157 const auto &instances = it->second.instances;
158 if (instances.find(instanceName) == instances.end()) {
159 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType)
160 << "): Cannot find instance '" << instanceName << "' in "
161 << toFQNameString(package, v, interfaceName);
162 continue;
163 }
164 return hal->transportArch.transport;
165 } 145 }
166 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType) << "): Cannot get transport for " 146 return transport;
167 << toFQNameString(package, v, interfaceName, instanceName);
168 return Transport::EMPTY;
169
170}
171
172std::set<Version> HalManifest::getSupportedVersions(const std::string &name) const {
173 std::set<Version> ret;
174 for (const ManifestHal *hal : getHals(name)) {
175 ret.insert(hal->versions.begin(), hal->versions.end());
176 }
177 return ret;
178} 147}
179 148
180bool HalManifest::forEachInstanceOfVersion( 149bool HalManifest::forEachInstanceOfVersion(
@@ -370,18 +339,15 @@ bool HalManifest::checkCompatibility(const CompatibilityMatrix &mat, std::string
370CompatibilityMatrix HalManifest::generateCompatibleMatrix() const { 339CompatibilityMatrix HalManifest::generateCompatibleMatrix() const {
371 CompatibilityMatrix matrix; 340 CompatibilityMatrix matrix;
372 341
373 for (const ManifestHal &manifestHal : getHals()) { 342 forEachInstance([&matrix](const ManifestInstance& e) {
374 MatrixHal matrixHal{ 343 matrix.add(MatrixHal{
375 .format = manifestHal.format, 344 .format = e.format(),
376 .name = manifestHal.name, 345 .name = e.package(),
377 .optional = true, 346 .optional = true,
378 .interfaces = manifestHal.interfaces 347 .versionRanges = {VersionRange{e.version().majorVer, e.version().minorVer}},
379 }; 348 .interfaces = {{e.interface(), HalInterface{e.interface(), {e.instance()}}}}});
380 for (const Version &manifestVersion : manifestHal.versions) { 349 return true;
381 matrixHal.versionRanges.push_back({manifestVersion.majorVer, manifestVersion.minorVer}); 350 });
382 }
383 matrix.add(std::move(matrixHal));
384 }
385 if (mType == SchemaType::FRAMEWORK) { 351 if (mType == SchemaType::FRAMEWORK) {
386 matrix.mType = SchemaType::DEVICE; 352 matrix.mType = SchemaType::DEVICE;
387 // VNDK does not need to be added for compatibility 353 // VNDK does not need to be added for compatibility
diff --git a/ManifestHal.cpp b/ManifestHal.cpp
index 1576c80..c0f4c8e 100644
--- a/ManifestHal.cpp
+++ b/ManifestHal.cpp
@@ -55,8 +55,8 @@ bool ManifestHal::forEachInstance(const std::function<bool(const ManifestInstanc
55 // TODO(b/73556059): Store ManifestInstance as well to avoid creating temps 55 // TODO(b/73556059): Store ManifestInstance as well to avoid creating temps
56 FqInstance fqInstance; 56 FqInstance fqInstance;
57 if (fqInstance.setTo(getName(), v.majorVer, v.minorVer, intf.name, instance)) { 57 if (fqInstance.setTo(getName(), v.majorVer, v.minorVer, intf.name, instance)) {
58 if (!func(ManifestInstance(std::move(fqInstance), 58 if (!func(ManifestInstance(std::move(fqInstance), TransportArch{transportArch},
59 TransportArch{transportArch}))) { 59 format))) {
60 return false; 60 return false;
61 } 61 }
62 } 62 }
@@ -129,7 +129,7 @@ bool ManifestHal::insertInstances(const std::set<FqInstance>& fqInstances, std::
129 } 129 }
130 return false; 130 return false;
131 } 131 }
132 mAdditionalInstances.emplace(std::move(withPackage), this->transportArch); 132 mAdditionalInstances.emplace(std::move(withPackage), this->transportArch, this->format);
133 } 133 }
134 134
135 return true; 135 return true;
diff --git a/ManifestInstance.cpp b/ManifestInstance.cpp
index 7a216eb..8bcf531 100644
--- a/ManifestInstance.cpp
+++ b/ManifestInstance.cpp
@@ -36,10 +36,11 @@ ManifestInstance& ManifestInstance::operator=(const ManifestInstance&) = default
36 36
37ManifestInstance& ManifestInstance::operator=(ManifestInstance&&) = default; 37ManifestInstance& ManifestInstance::operator=(ManifestInstance&&) = default;
38 38
39ManifestInstance::ManifestInstance(FqInstance&& fqInstance, TransportArch&& ta) 39ManifestInstance::ManifestInstance(FqInstance&& fqInstance, TransportArch&& ta, HalFormat fmt)
40 : mFqInstance(std::move(fqInstance)), mTransportArch(std::move(ta)) {} 40 : mFqInstance(std::move(fqInstance)), mTransportArch(std::move(ta)), mHalFormat(fmt) {}
41ManifestInstance::ManifestInstance(const FqInstance& fqInstance, const TransportArch& ta) 41ManifestInstance::ManifestInstance(const FqInstance& fqInstance, const TransportArch& ta,
42 : mFqInstance(fqInstance), mTransportArch(ta) {} 42 HalFormat fmt)
43 : mFqInstance(fqInstance), mTransportArch(ta), mHalFormat(fmt) {}
43 44
44const std::string& ManifestInstance::package() const { 45const std::string& ManifestInstance::package() const {
45 return mFqInstance.getPackage(); 46 return mFqInstance.getPackage();
@@ -65,17 +66,24 @@ Arch ManifestInstance::arch() const {
65 return mTransportArch.arch; 66 return mTransportArch.arch;
66} 67}
67 68
69HalFormat ManifestInstance::format() const {
70 return mHalFormat;
71}
72
68const FqInstance& ManifestInstance::getFqInstance() const { 73const FqInstance& ManifestInstance::getFqInstance() const {
69 return mFqInstance; 74 return mFqInstance;
70} 75}
71 76
72bool ManifestInstance::operator==(const ManifestInstance& other) const { 77bool ManifestInstance::operator==(const ManifestInstance& other) const {
73 return mFqInstance == other.mFqInstance && mTransportArch == other.mTransportArch; 78 return mFqInstance == other.mFqInstance && mTransportArch == other.mTransportArch &&
79 mHalFormat == other.mHalFormat;
74} 80}
75bool ManifestInstance::operator<(const ManifestInstance& other) const { 81bool ManifestInstance::operator<(const ManifestInstance& other) const {
76 if (mFqInstance < other.mFqInstance) return true; 82 if (mFqInstance < other.mFqInstance) return true;
77 if (other.mFqInstance < mFqInstance) return false; 83 if (other.mFqInstance < mFqInstance) return false;
78 return mTransportArch < other.mTransportArch; 84 if (mTransportArch < other.mTransportArch) return true;
85 if (other.mTransportArch < mTransportArch) return false;
86 return mHalFormat < other.mHalFormat;
79} 87}
80 88
81FqInstance ManifestInstance::getFqInstanceNoPackage() const { 89FqInstance ManifestInstance::getFqInstanceNoPackage() const {
diff --git a/include/vintf/HalManifest.h b/include/vintf/HalManifest.h
index 0e77142..a5d01c8 100644
--- a/include/vintf/HalManifest.h
+++ b/include/vintf/HalManifest.h
@@ -63,13 +63,6 @@ struct HalManifest : public HalGroup<ManifestHal>, public XmlFileGroup<ManifestX
63 Transport getTransport(const std::string &name, const Version &v, 63 Transport getTransport(const std::string &name, const Version &v,
64 const std::string &interfaceName, const std::string &instanceName) const; 64 const std::string &interfaceName, const std::string &instanceName) const;
65 65
66 // Given a component name (e.g. "android.hardware.camera"),
67 // return a list of version numbers that are supported by the hardware.
68 // If the component is not found, empty list is returned.
69 // If multiple matches, return a concatenation of version entries
70 // (dupes removed)
71 std::set<Version> getSupportedVersions(const std::string &name) const;
72
73 // Check compatibility against a compatibility matrix. Considered compatible if 66 // Check compatibility against a compatibility matrix. Considered compatible if
74 // - framework manifest vs. device compat-mat 67 // - framework manifest vs. device compat-mat
75 // - checkIncompatibility for HALs returns only optional HALs 68 // - checkIncompatibility for HALs returns only optional HALs
diff --git a/include/vintf/ManifestInstance.h b/include/vintf/ManifestInstance.h
index 61abbf1..4eefd65 100644
--- a/include/vintf/ManifestInstance.h
+++ b/include/vintf/ManifestInstance.h
@@ -21,6 +21,7 @@
21 21
22#include <hidl-util/FqInstance.h> 22#include <hidl-util/FqInstance.h>
23 23
24#include "HalFormat.h"
24#include "TransportArch.h" 25#include "TransportArch.h"
25#include "Version.h" 26#include "Version.h"
26 27
@@ -36,14 +37,15 @@ class ManifestInstance {
36 ManifestInstance& operator=(ManifestInstance&&); 37 ManifestInstance& operator=(ManifestInstance&&);
37 38
38 using VersionType = Version; 39 using VersionType = Version;
39 ManifestInstance(FqInstance&& fqInstance, TransportArch&& ta); 40 ManifestInstance(FqInstance&& fqInstance, TransportArch&& ta, HalFormat fmt);
40 ManifestInstance(const FqInstance& fqInstance, const TransportArch& ta); 41 ManifestInstance(const FqInstance& fqInstance, const TransportArch& ta, HalFormat fmt);
41 const std::string& package() const; 42 const std::string& package() const;
42 Version version() const; 43 Version version() const;
43 const std::string& interface() const; 44 const std::string& interface() const;
44 const std::string& instance() const; 45 const std::string& instance() const;
45 Transport transport() const; 46 Transport transport() const;
46 Arch arch() const; 47 Arch arch() const;
48 HalFormat format() const;
47 49
48 bool operator==(const ManifestInstance& other) const; 50 bool operator==(const ManifestInstance& other) const;
49 bool operator<(const ManifestInstance& other) const; 51 bool operator<(const ManifestInstance& other) const;
@@ -57,6 +59,7 @@ class ManifestInstance {
57 private: 59 private:
58 FqInstance mFqInstance; 60 FqInstance mFqInstance;
59 TransportArch mTransportArch; 61 TransportArch mTransportArch;
62 HalFormat mHalFormat;
60}; 63};
61 64
62} // namespace vintf 65} // namespace vintf
diff --git a/include/vintf/VintfObject.h b/include/vintf/VintfObject.h
index 2e260ab..cfa4072 100644
--- a/include/vintf/VintfObject.h
+++ b/include/vintf/VintfObject.h
@@ -33,11 +33,9 @@ namespace vintf {
33 * VintfObject 33 * VintfObject
34 * + GetDeviceHalManfiest 34 * + GetDeviceHalManfiest
35 * | + getTransport 35 * | + getTransport
36 * | + getSupportedVersions
37 * | + checkCompatibility 36 * | + checkCompatibility
38 * + GetFrameworkHalManifest 37 * + GetFrameworkHalManifest
39 * | + getTransport 38 * | + getTransport
40 * | + getSupportedVersions
41 * | + checkCompatibility 39 * | + checkCompatibility
42 * + GetRuntimeInfo 40 * + GetRuntimeInfo
43 * + checkCompatibility 41 * + checkCompatibility
diff --git a/test/LibVintfTest.cpp b/test/LibVintfTest.cpp
index 8c42d77..7bdadcc 100644
--- a/test/LibVintfTest.cpp
+++ b/test/LibVintfTest.cpp
@@ -3165,6 +3165,9 @@ TEST_F(LibVintfTest, FqNameValid) {
3165 "</manifest>\n"; 3165 "</manifest>\n";
3166 ASSERT_TRUE(gHalManifestConverter(&manifest, xml, &error)) << error; 3166 ASSERT_TRUE(gHalManifestConverter(&manifest, xml, &error)) << error;
3167 EXPECT_TRUE(manifest.checkCompatibility(cm, &error)) << error; 3167 EXPECT_TRUE(manifest.checkCompatibility(cm, &error)) << error;
3168
3169 EXPECT_EQ(Transport::HWBINDER,
3170 manifest.getTransport("android.hardware.foo", {1, 1}, "IFoo", "custom"));
3168 } 3171 }
3169 3172
3170 { 3173 {