summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2017-10-24 03:04:58 -0500
committerandroid-build-team Robot2017-10-24 03:04:58 -0500
commit4a81202a5cd572b5f9ef676161379d399aae6155 (patch)
tree29f734928152c12625c1be95cabf1705047822c2
parent40e7ac360894887f9aba579bc234a145bf1b9f2c (diff)
parentc458741791174dbcc207ae9b78a7788bdb07977d (diff)
downloadplatform-system-libvintf-4a81202a5cd572b5f9ef676161379d399aae6155.tar.gz
platform-system-libvintf-4a81202a5cd572b5f9ef676161379d399aae6155.tar.xz
platform-system-libvintf-4a81202a5cd572b5f9ef676161379d399aae6155.zip
Snap for 4413317 from c458741791174dbcc207ae9b78a7788bdb07977d to pi-release
Change-Id: I67765f220e4c842b3a7cf569e2011e7f0c28883e
-rw-r--r--VintfObject.cpp20
-rw-r--r--assemble_vintf.cpp10
-rw-r--r--include/vintf/HalGroup.h5
-rw-r--r--test/vintf_object_tests.cpp8
4 files changed, 37 insertions, 6 deletions
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 698bf30..9dea4d9 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -56,10 +56,22 @@ static std::shared_ptr<const T> Get(
56 56
57// static 57// static
58std::shared_ptr<const HalManifest> VintfObject::GetDeviceHalManifest(bool skipCache) { 58std::shared_ptr<const HalManifest> VintfObject::GetDeviceHalManifest(bool skipCache) {
59 static LockedSharedPtr<HalManifest> gDeviceManifest; 59 static LockedSharedPtr<HalManifest> gVendorManifest;
60 return Get(&gDeviceManifest, skipCache, 60 static LockedSharedPtr<HalManifest> gOdmManifest;
61 std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1, 61 static std::mutex gDeviceManifestMutex;
62 "/vendor/manifest.xml")); 62
63 std::unique_lock<std::mutex> _lock(gDeviceManifestMutex);
64
65 auto odm = Get(
66 &gOdmManifest, skipCache,
67 std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1, "/odm/manifest.xml"));
68 if (odm != nullptr) {
69 return odm;
70 }
71
72 return Get(&gVendorManifest, skipCache,
73 std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1,
74 "/vendor/manifest.xml"));
63} 75}
64 76
65// static 77// static
diff --git a/assemble_vintf.cpp b/assemble_vintf.cpp
index 974c7fc..8874f69 100644
--- a/assemble_vintf.cpp
+++ b/assemble_vintf.cpp
@@ -318,7 +318,15 @@ class AssembleVintf {
318 << std::endl; 318 << std::endl;
319 return FAIL_AND_EXIT; 319 return FAIL_AND_EXIT;
320 } 320 }
321 schema.addAll(std::move(additionalSchema)); 321 std::string error;
322 if (!schema.addAll(std::move(additionalSchema), &error)) {
323 std::cerr << "File \"" << mInFilePaths[std::distance(mInFiles.begin(), it)]
324 << "\" cannot be added: conflict on HAL \"" << error
325 << "\" with an existing HAL. See <hal> with the same name "
326 << "in previously parsed files or previously declared in this file."
327 << std::endl;
328 return FAIL_AND_EXIT;
329 }
322 } 330 }
323 return assemble(&schema) ? SUCCESS : FAIL_AND_EXIT; 331 return assemble(&schema) ? SUCCESS : FAIL_AND_EXIT;
324 } 332 }
diff --git a/include/vintf/HalGroup.h b/include/vintf/HalGroup.h
index 9962c29..8ef6f38 100644
--- a/include/vintf/HalGroup.h
+++ b/include/vintf/HalGroup.h
@@ -31,9 +31,12 @@ struct HalGroup {
31 public: 31 public:
32 virtual ~HalGroup() {} 32 virtual ~HalGroup() {}
33 // Move all hals from another HalGroup to this. 33 // Move all hals from another HalGroup to this.
34 bool addAll(HalGroup&& other) { 34 bool addAll(HalGroup&& other, std::string* error = nullptr) {
35 for (auto& pair : other.mHals) { 35 for (auto& pair : other.mHals) {
36 if (!add(std::move(pair.second))) { 36 if (!add(std::move(pair.second))) {
37 if (error) {
38 *error = pair.first;
39 }
37 return false; 40 return false;
38 } 41 }
39 } 42 }
diff --git a/test/vintf_object_tests.cpp b/test/vintf_object_tests.cpp
index aa11b6f..b206158 100644
--- a/test/vintf_object_tests.cpp
+++ b/test/vintf_object_tests.cpp
@@ -169,6 +169,8 @@ void setupMockFetcher(const std::string& vendorManifestXml, const std::string& s
169 const std::string& systemManifestXml, const std::string& vendorMatrixXml) { 169 const std::string& systemManifestXml, const std::string& vendorMatrixXml) {
170 MockFileFetcher* fetcher = static_cast<MockFileFetcher*>(gFetcher); 170 MockFileFetcher* fetcher = static_cast<MockFileFetcher*>(gFetcher);
171 171
172 ON_CALL(*fetcher, fetch(StrEq("/odm/manifest.xml"), _))
173 .WillByDefault(Return(::android::NAME_NOT_FOUND));
172 ON_CALL(*fetcher, fetch(StrEq("/vendor/manifest.xml"), _)) 174 ON_CALL(*fetcher, fetch(StrEq("/vendor/manifest.xml"), _))
173 .WillByDefault(Invoke([vendorManifestXml](const std::string& path, std::string& fetched) { 175 .WillByDefault(Invoke([vendorManifestXml](const std::string& path, std::string& fetched) {
174 (void)path; 176 (void)path;
@@ -221,6 +223,7 @@ TEST_F(VintfObjectCompatibleTest, TestDeviceCompatibility) {
221 std::string error; 223 std::string error;
222 std::vector<std::string> packageInfo; 224 std::vector<std::string> packageInfo;
223 225
226 EXPECT_CALL(fetcher(), fetch(StrEq("/odm/manifest.xml"), _));
224 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _)); 227 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _));
225 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _)); 228 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _));
226 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _)); 229 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _));
@@ -260,6 +263,7 @@ TEST_F(VintfObjectCompatibleTest, TestInputVsDeviceSuccess) {
260 std::string error; 263 std::string error;
261 std::vector<std::string> packageInfo = {systemMatrixXml1}; 264 std::vector<std::string> packageInfo = {systemMatrixXml1};
262 265
266 EXPECT_CALL(fetcher(), fetch(StrEq("/odm/manifest.xml"), _));
263 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _)); 267 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _));
264 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _)); 268 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _));
265 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _)); 269 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _));
@@ -321,6 +325,7 @@ TEST_F(VintfObjectCompatibleTest, TestFrameworkOnlyOta) {
321 std::string error; 325 std::string error;
322 std::vector<std::string> packageInfo = {systemMatrixXml1, systemManifestXml1}; 326 std::vector<std::string> packageInfo = {systemMatrixXml1, systemManifestXml1};
323 327
328 EXPECT_CALL(fetcher(), fetch(StrEq("/odm/manifest.xml"), _));
324 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _)); 329 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _));
325 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _)).Times(0); 330 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _)).Times(0);
326 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _)); 331 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _));
@@ -359,6 +364,7 @@ TEST_F(VintfObjectCompatibleTest, TestFullOta) {
359 std::vector<std::string> packageInfo = {systemMatrixXml1, systemManifestXml1, 364 std::vector<std::string> packageInfo = {systemMatrixXml1, systemManifestXml1,
360 vendorMatrixXml1, vendorManifestXml1}; 365 vendorMatrixXml1, vendorManifestXml1};
361 366
367 EXPECT_CALL(fetcher(), fetch(StrEq("/odm/manifest.xml"), _)).Times(0);
362 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _)).Times(0); 368 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _)).Times(0);
363 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _)).Times(0); 369 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _)).Times(0);
364 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _)).Times(0); 370 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _)).Times(0);
@@ -412,6 +418,7 @@ TEST_F(VintfObjectIncompatibleTest, TestDeviceCompatibility) {
412 std::string error; 418 std::string error;
413 std::vector<std::string> packageInfo; 419 std::vector<std::string> packageInfo;
414 420
421 EXPECT_CALL(fetcher(), fetch(StrEq("/odm/manifest.xml"), _));
415 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _)); 422 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _));
416 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _)); 423 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _));
417 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _)); 424 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _));
@@ -427,6 +434,7 @@ TEST_F(VintfObjectIncompatibleTest, TestInputVsDeviceSuccess) {
427 std::string error; 434 std::string error;
428 std::vector<std::string> packageInfo = {systemMatrixXml1}; 435 std::vector<std::string> packageInfo = {systemMatrixXml1};
429 436
437 EXPECT_CALL(fetcher(), fetch(StrEq("/odm/manifest.xml"), _));
430 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _)); 438 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/manifest.xml"), _));
431 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _)); 439 EXPECT_CALL(fetcher(), fetch(StrEq("/system/manifest.xml"), _));
432 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _)); 440 EXPECT_CALL(fetcher(), fetch(StrEq("/vendor/compatibility_matrix.xml"), _));