summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CompatibilityMatrix.cpp7
-rw-r--r--HalManifest.cpp17
-rw-r--r--VintfObject.cpp10
-rw-r--r--include/vintf/parse_string.h14
-rw-r--r--main.cpp15
-rw-r--r--parse_string.cpp37
6 files changed, 70 insertions, 30 deletions
diff --git a/CompatibilityMatrix.cpp b/CompatibilityMatrix.cpp
index 7bdc3a9..deb1fa1 100644
--- a/CompatibilityMatrix.cpp
+++ b/CompatibilityMatrix.cpp
@@ -16,13 +16,12 @@
16 16
17#include "CompatibilityMatrix.h" 17#include "CompatibilityMatrix.h"
18 18
19#include <iostream>
19#include <utility> 20#include <utility>
20 21
21#include "parse_string.h" 22#include "parse_string.h"
22#include "utils.h"
23
24#include <iostream>
25#include "parse_xml.h" 23#include "parse_xml.h"
24#include "utils.h"
26 25
27namespace android { 26namespace android {
28namespace vintf { 27namespace vintf {
@@ -129,7 +128,7 @@ bool CompatibilityMatrix::addAllHalsAsOptional(CompatibilityMatrix* other, std::
129 128
130 if (!existingHal->optional && !existingHal->containsInstances(halToAdd)) { 129 if (!existingHal->optional && !existingHal->containsInstances(halToAdd)) {
131 if (error != nullptr) { 130 if (error != nullptr) {
132 *error = "HAL " + name + "@" + to_string(vr.minVer()) + " is a required " + 131 *error = "HAL " + toFQNameString(name, vr.minVer()) + " is a required " +
133 "HAL, but fully qualified instance names don't match (at FCM " 132 "HAL, but fully qualified instance names don't match (at FCM "
134 "Version " + 133 "Version " +
135 std::to_string(level()) + " and " + std::to_string(other->level()) + 134 std::to_string(level()) + " and " + std::to_string(other->level()) +
diff --git a/HalManifest.cpp b/HalManifest.cpp
index 540edee..6f05cab 100644
--- a/HalManifest.cpp
+++ b/HalManifest.cpp
@@ -125,7 +125,7 @@ std::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 for (const auto &hal : getHals()) {
127 for (const auto &version : hal.versions) { 127 for (const auto &version : hal.versions) {
128 names.insert(hal.name + "@" + to_string(version)); 128 names.insert(toFQNameString(hal.name, version));
129 } 129 }
130 } 130 }
131 return names; 131 return names;
@@ -149,21 +149,22 @@ Transport HalManifest::getTransport(const std::string &package, const Version &v
149 } 149 }
150 auto it = hal->interfaces.find(interfaceName); 150 auto it = hal->interfaces.find(interfaceName);
151 if (it == hal->interfaces.end()) { 151 if (it == hal->interfaces.end()) {
152 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType) << "): Cannot find interface '" 152 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType)
153 << interfaceName << "' in " << package << "@" << to_string(v); 153 << "): Cannot find interface '" << interfaceName << "' in "
154 << toFQNameString(package, v);
154 continue; 155 continue;
155 } 156 }
156 const auto &instances = it->second.instances; 157 const auto &instances = it->second.instances;
157 if (instances.find(instanceName) == instances.end()) { 158 if (instances.find(instanceName) == instances.end()) {
158 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType) << "): Cannot find instance '" 159 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType)
159 << instanceName << "' in " 160 << "): Cannot find instance '" << instanceName << "' in "
160 << package << "@" << to_string(v) << "::" << interfaceName; 161 << toFQNameString(package, v, interfaceName);
161 continue; 162 continue;
162 } 163 }
163 return hal->transportArch.transport; 164 return hal->transportArch.transport;
164 } 165 }
165 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType) << "): Cannot get transport for " 166 LOG(DEBUG) << "HalManifest::getTransport(" << to_string(mType) << "): Cannot get transport for "
166 << package << "@" << v << "::" << interfaceName << "/" << instanceName; 167 << toFQNameString(package, v, interfaceName, instanceName);
167 return Transport::EMPTY; 168 return Transport::EMPTY;
168 169
169} 170}
@@ -270,7 +271,7 @@ static std::vector<std::string> toLines(const Instances& allInstances) {
270 for (const auto& ifacePair : pair.second) { 271 for (const auto& ifacePair : pair.second) {
271 const auto& interface = ifacePair.first; 272 const auto& interface = ifacePair.first;
272 for (const auto& instance : ifacePair.second) { 273 for (const auto& instance : ifacePair.second) {
273 lines.push_back("@" + to_string(version) + "::" + interface + "/" + instance); 274 lines.push_back(toFQNameString(version, interface, instance));
274 } 275 }
275 } 276 }
276 } 277 }
diff --git a/VintfObject.cpp b/VintfObject.cpp
index e89ca56..c66011b 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -597,7 +597,7 @@ bool VintfObject::isInstanceDeprecated(const std::string& package, Version versi
597 targetMatrix.getHalWithMajorVersion(package, version.majorVer); 597 targetMatrix.getHalWithMajorVersion(package, version.majorVer);
598 if (targetMatrixHal == nullptr || targetMatrixRange == nullptr) { 598 if (targetMatrixHal == nullptr || targetMatrixRange == nullptr) {
599 if (error) { 599 if (error) {
600 *error = package + "@" + to_string(servedVersion) + 600 *error = toFQNameString(package, servedVersion) +
601 "is deprecated in compatibility matrix at FCM Version " + 601 "is deprecated in compatibility matrix at FCM Version " +
602 to_string(targetMatrix.level()) + "; it should not be served."; 602 to_string(targetMatrix.level()) + "; it should not be served.";
603 } 603 }
@@ -607,9 +607,9 @@ bool VintfObject::isInstanceDeprecated(const std::string& package, Version versi
607 const auto& targetMatrixInstances = targetMatrixHal->getInstances(interface); 607 const auto& targetMatrixInstances = targetMatrixHal->getInstances(interface);
608 if (targetMatrixInstances.find(instance) == targetMatrixInstances.end()) { 608 if (targetMatrixInstances.find(instance) == targetMatrixInstances.end()) {
609 if (error) { 609 if (error) {
610 *error += package + "@" + to_string(servedVersion) + "::" + interface + "/" + 610 *error += toFQNameString(package, servedVersion, interface, instance) +
611 instance + " is deprecated at FCM version " + 611 " is deprecated at FCM version " + to_string(targetMatrix.level()) +
612 to_string(targetMatrix.level()) + "; it should be not be served.\n"; 612 "; it should be not be served.\n";
613 } 613 }
614 return true; 614 return true;
615 } 615 }
@@ -621,7 +621,7 @@ bool VintfObject::isInstanceDeprecated(const std::string& package, Version versi
621 621
622 if (!targetVersionServed) { 622 if (!targetVersionServed) {
623 if (error) { 623 if (error) {
624 *error += package + "@" + to_string(servedVersion) + " is deprecated; " + 624 *error += toFQNameString(package, servedVersion) + " is deprecated; " +
625 "require at least " + to_string(targetMatrixRange->minVer()) + "\n"; 625 "require at least " + to_string(targetMatrixRange->minVer()) + "\n";
626 } 626 }
627 return true; 627 return true;
diff --git a/include/vintf/parse_string.h b/include/vintf/parse_string.h
index 7ae45f8..8820639 100644
--- a/include/vintf/parse_string.h
+++ b/include/vintf/parse_string.h
@@ -105,6 +105,20 @@ std::string dump(const RuntimeInfo& ki, bool verbose = true);
105 105
106std::vector<std::string> expandInstances(const MatrixHal& req); 106std::vector<std::string> expandInstances(const MatrixHal& req);
107 107
108std::string toFQNameString(const std::string& package, const Version& version,
109 const std::string& intf = "", const std::string& instance = "");
110
111std::string toFQNameString(const Version& version, const std::string& intf,
112 const std::string& instance);
113
114// android.hardware.foo@1.0-1::IFoo/default.
115// Note that the format is extended to support a range of versions.
116std::string toFQNameString(const std::string& package, const VersionRange& range,
117 const std::string& interface, const std::string& instance);
118
119std::string toFQNameString(const VersionRange& range, const std::string& interface,
120 const std::string& instance);
121
108} // namespace vintf 122} // namespace vintf
109} // namespace android 123} // namespace android
110 124
diff --git a/main.cpp b/main.cpp
index 111b797..c4119c9 100644
--- a/main.cpp
+++ b/main.cpp
@@ -151,15 +151,6 @@ void usage(char* me, const std::vector<Option>& options) {
151 } 151 }
152} 152}
153 153
154// android.hardware.foo@1.0-1::IFoo/default.
155// Note that the format is extended to support a range of versions.
156std::string fqInstanceName(const std::string& package, const VersionRange& range,
157 const std::string& interface, const std::string& instance) {
158 std::stringstream ss;
159 ss << package << "@" << range << "::" << interface << "/" << instance;
160 return ss.str();
161}
162
163struct TableRow { 154struct TableRow {
164 // Whether the HAL version is in device manifest, framework manifest, device compatibility 155 // Whether the HAL version is in device manifest, framework manifest, device compatibility
165 // matrix, framework compatibility matrix, respectively. 156 // matrix, framework compatibility matrix, respectively.
@@ -199,7 +190,7 @@ void insert(const HalManifest* manifest, Table* table, const RowMutator& mutate)
199 if (manifest == nullptr) return; 190 if (manifest == nullptr) return;
200 manifest->forEachInstance([&](const auto& package, const auto& version, const auto& interface, 191 manifest->forEachInstance([&](const auto& package, const auto& version, const auto& interface,
201 const auto& instance, bool* /* stop */) { 192 const auto& instance, bool* /* stop */) {
202 std::string key = fqInstanceName(package, VersionRange{version.majorVer, version.minorVer}, 193 std::string key = toFQNameString(package, VersionRange{version.majorVer, version.minorVer},
203 interface, instance); 194 interface, instance);
204 mutate(&(*table)[key]); 195 mutate(&(*table)[key]);
205 }); 196 });
@@ -211,7 +202,7 @@ void insert(const CompatibilityMatrix* matrix, Table* table, const RowMutator& m
211 const auto& instance, bool optional, bool* /* stop */) { 202 const auto& instance, bool optional, bool* /* stop */) {
212 bool missed = false; 203 bool missed = false;
213 for (auto minorVer = range.minMinor; minorVer <= range.maxMinor; ++minorVer) { 204 for (auto minorVer = range.minMinor; minorVer <= range.maxMinor; ++minorVer) {
214 std::string key = fqInstanceName(package, VersionRange{range.majorVer, minorVer}, 205 std::string key = toFQNameString(package, VersionRange{range.majorVer, minorVer},
215 interface, instance); 206 interface, instance);
216 auto it = table->find(key); 207 auto it = table->find(key);
217 if (it == table->end()) { 208 if (it == table->end()) {
@@ -222,7 +213,7 @@ void insert(const CompatibilityMatrix* matrix, Table* table, const RowMutator& m
222 } 213 }
223 } 214 }
224 if (missed) { 215 if (missed) {
225 std::string key = fqInstanceName(package, range, interface, instance); 216 std::string key = toFQNameString(package, range, interface, instance);
226 mutate(&(*table)[key]); 217 mutate(&(*table)[key]);
227 } 218 }
228 }); 219 });
diff --git a/parse_string.cpp b/parse_string.cpp
index beca23b..2aa3c1b 100644
--- a/parse_string.cpp
+++ b/parse_string.cpp
@@ -401,7 +401,7 @@ static std::string expandInstances(const MatrixHal& req, const VersionRange& vr)
401 for (const auto& interface : iterateValues(req.interfaces)) { 401 for (const auto& interface : iterateValues(req.interfaces)) {
402 for (const auto& instance : interface.instances) { 402 for (const auto& instance : interface.instances) {
403 if (!first) s += " AND "; 403 if (!first) s += " AND ";
404 s += "@" + to_string(vr) + "::" + interface.name + "/" + instance; 404 s += toFQNameString(vr, interface.name, instance);
405 first = false; 405 first = false;
406 } 406 }
407 } 407 }
@@ -470,5 +470,40 @@ std::string dump(const RuntimeInfo& ki, bool verbose) {
470 return oss.str(); 470 return oss.str();
471} 471}
472 472
473std::string toFQNameString(const std::string& package, const std::string& version,
474 const std::string& interface, const std::string& instance) {
475 std::stringstream ss;
476 ss << package << "@" << version;
477 if (!interface.empty()) {
478 ss << "::" << interface;
479 if (!instance.empty()) {
480 ss << "/" << instance;
481 }
482 }
483 return ss.str();
484}
485
486std::string toFQNameString(const std::string& package, const Version& version,
487 const std::string& interface, const std::string& instance) {
488 return toFQNameString(package, to_string(version), interface, instance);
489}
490
491std::string toFQNameString(const Version& version, const std::string& interface,
492 const std::string& instance) {
493 return toFQNameString("", version, interface, instance);
494}
495
496// android.hardware.foo@1.0-1::IFoo/default.
497// Note that the format is extended to support a range of versions.
498std::string toFQNameString(const std::string& package, const VersionRange& range,
499 const std::string& interface, const std::string& instance) {
500 return toFQNameString(package, to_string(range), interface, instance);
501}
502
503std::string toFQNameString(const VersionRange& range, const std::string& interface,
504 const std::string& instance) {
505 return toFQNameString("", range, interface, instance);
506}
507
473} // namespace vintf 508} // namespace vintf
474} // namespace android 509} // namespace android