Load odm manifest.xml and fallback to vendor.

Eventually, we may pursue properly overlayed manifests.
However, adding this fallback mechanism so that the ODM image
can specify a more specific image than the vendor image can.

Bug: 65032103
Test: vendor manifest still loaded properly
Test: vintf_object_test + libvintf_test
Change-Id: Iccb1f5937755f78c9e50565aeb19e0a580e7e577
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 HalManifest> VintfObject::GetDeviceHalManifest(bool skipCache) {
-    static LockedSharedPtr<HalManifest> gDeviceManifest;
-    return Get(&gDeviceManifest, skipCache,
-            std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1,
-                "/vendor/manifest.xml"));
+    static LockedSharedPtr<HalManifest> gVendorManifest;
+    static LockedSharedPtr<HalManifest> gOdmManifest;
+    static std::mutex gDeviceManifestMutex;
+
+    std::unique_lock<std::mutex> _lock(gDeviceManifestMutex);
+
+    auto odm = Get(
+        &gOdmManifest, skipCache,
+        std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1, "/odm/manifest.xml"));
+    if (odm != nullptr) {
+        return odm;
+    }
+
+    return Get(&gVendorManifest, skipCache,
+               std::bind(&HalManifest::fetchAllInformation, std::placeholders::_1,
+                         "/vendor/manifest.xml"));
 }
 
 // static