Log when reading manifest/matrices.

This is an extremely critical path, so:
- success information is logged, so that we can see exactly when a
  manifest is read (in case it is read incorrectly).
- the error log is doubled, in case it is somehow corrupted or too long
  for logcat, we still want the error code (e.g. even if corrupted by
  another library in the process).

Bug: 151696835
Test: boot and check logs (including error case, after deleting if
  statements)
Change-Id: Ibe50fd6ce3de955482dffb467b729d48b0d9d97b
Merged-In: Ibe50fd6ce3de955482dffb467b729d48b0d9d97b
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 2611a56..4bd684e 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -48,17 +48,21 @@
 #endif
 
 template <typename T, typename F>
-static std::shared_ptr<const T> Get(
-        LockedSharedPtr<T> *ptr,
-        bool skipCache,
-        const F &fetchAllInformation) {
+static std::shared_ptr<const T> Get(const char* id, LockedSharedPtr<T>* ptr, bool skipCache,
+                                    const F& fetchAllInformation) {
     std::unique_lock<std::mutex> _lock(ptr->mutex);
     if (skipCache || !ptr->fetchedOnce) {
+        LOG(INFO) << id << ": Reading VINTF information.";
         ptr->object = std::make_unique<T>();
         std::string error;
         status_t status = fetchAllInformation(ptr->object.get(), &error);
-        if (status != OK) {
-            LOG(WARNING) << status << " VINTF parse error: " << error;
+        if (status == OK) {
+            LOG(INFO) << id << ": Successfully processed VINTF information";
+        } else {
+            // Doubled because a malformed error std::string might cause us to
+            // lose the status.
+            LOG(ERROR) << id << ": status from fetching VINTF information: " << status;
+            LOG(ERROR) << id << ": " << status << " VINTF parse error: " << error;
             ptr->object = nullptr; // frees the old object
         }
         ptr->fetchedOnce = true;
@@ -100,7 +104,7 @@
 }
 
 std::shared_ptr<const HalManifest> VintfObject::getDeviceHalManifest(bool skipCache) {
-    return Get(&mDeviceManifest, skipCache,
+    return Get(__func__, &mDeviceManifest, skipCache,
                std::bind(&VintfObject::fetchDeviceHalManifest, this, _1, _2));
 }
 
@@ -109,7 +113,7 @@
 }
 
 std::shared_ptr<const HalManifest> VintfObject::getFrameworkHalManifest(bool skipCache) {
-    return Get(&mFrameworkManifest, skipCache,
+    return Get(__func__, &mFrameworkManifest, skipCache,
                std::bind(&VintfObject::fetchFrameworkHalManifest, this, _1, _2));
 }
 
@@ -119,7 +123,8 @@
 
 std::shared_ptr<const CompatibilityMatrix> VintfObject::getDeviceCompatibilityMatrix(
     bool skipCache) {
-    return Get(&mDeviceMatrix, skipCache, std::bind(&VintfObject::fetchDeviceMatrix, this, _1, _2));
+    return Get(__func__, &mDeviceMatrix, skipCache,
+               std::bind(&VintfObject::fetchDeviceMatrix, this, _1, _2));
 }
 
 std::shared_ptr<const CompatibilityMatrix> VintfObject::GetFrameworkCompatibilityMatrix(bool skipCache) {
@@ -134,13 +139,13 @@
     std::unique_lock<std::mutex> _lock(mFrameworkCompatibilityMatrixMutex);
 
     auto combined =
-        Get(&mCombinedFrameworkMatrix, skipCache,
+        Get(__func__, &mCombinedFrameworkMatrix, skipCache,
             std::bind(&VintfObject::getCombinedFrameworkMatrix, this, deviceManifest, _1, _2));
     if (combined != nullptr) {
         return combined;
     }
 
-    return Get(&mFrameworkMatrix, skipCache,
+    return Get(__func__, &mFrameworkMatrix, skipCache,
                std::bind(&CompatibilityMatrix::fetchAllInformation, _1, getFileSystem().get(),
                          kSystemLegacyMatrix, _2));
 }