Snap for 5685999 from 8a8a356efa93acf20f88dffae7da211aba276513 to qt-release

Change-Id: I5dc6bb6c66c1a88507725e165d9b6ebc480611ca
diff --git a/apexd/apex_database.cpp b/apexd/apex_database.cpp
index 5379365..0a8f137 100644
--- a/apexd/apex_database.cpp
+++ b/apexd/apex_database.cpp
@@ -152,7 +152,7 @@
   inode_map map;
 
   for (const auto& dir : kApexPackageBuiltinDirs) {
-    WalkDir(dir, [&](const fs::directory_entry& entry) {
+    auto status = WalkDir(dir, [&](const fs::directory_entry& entry) {
       const auto& path = entry.path();
       if (isFlattenedApex(path)) {
         auto inode = inodeFor(path);
@@ -161,6 +161,9 @@
         }
       }
     });
+    if (!status.Ok()) {
+      LOG(ERROR) << "Failed to walk " << dir << " : " << status.ErrorMessage();
+    }
   }
 
   return map;
diff --git a/apexd/apex_file.cpp b/apexd/apex_file.cpp
index 80e6052..9f630dd 100644
--- a/apexd/apex_file.cpp
+++ b/apexd/apex_file.cpp
@@ -391,7 +391,7 @@
 
   if (!avb_hashtree_descriptor_validate_and_byteswap(desc,
                                                      verifiedDesc.get())) {
-    StatusOr<std::unique_ptr<AvbHashtreeDescriptor>>::MakeError(
+    return StatusOr<std::unique_ptr<AvbHashtreeDescriptor>>::MakeError(
         "Couldn't validate AvbDescriptor.");
   }
 
diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp
index 355934d..4f5ca52 100644
--- a/apexd/apexd.cpp
+++ b/apexd/apexd.cpp
@@ -1381,7 +1381,11 @@
 
     auto session_failed_fn = [&]() {
       LOG(WARNING) << "Marking session " << sessionId << " as failed.";
-      session.UpdateStateAndCommit(SessionState::ACTIVATION_FAILED);
+      auto st = session.UpdateStateAndCommit(SessionState::ACTIVATION_FAILED);
+      if (!st.Ok()) {
+        LOG(WARNING) << "Failed to mark session " << sessionId
+                     << " as failed : " << st.ErrorMessage();
+      }
     };
     auto scope_guard = android::base::make_scope_guard(session_failed_fn);
 
@@ -1446,7 +1450,11 @@
     // Session was OK, release scopeguard.
     scope_guard.Disable();
 
-    session.UpdateStateAndCommit(SessionState::ACTIVATED);
+    auto st = session.UpdateStateAndCommit(SessionState::ACTIVATED);
+    if (!st.Ok()) {
+      LOG(ERROR) << "Failed to mark " << session
+                 << " as activated : " << st.ErrorMessage();
+    }
   }
 }
 
@@ -1668,7 +1676,12 @@
   }
 
   // Activate built-in APEXes for processes launched before /data is mounted.
-  scanPackagesDirAndActivate(kApexPackageSystemDir);
+  status = scanPackagesDirAndActivate(kApexPackageSystemDir);
+  if (!status.Ok()) {
+    LOG(ERROR) << "Failed to activate APEX files in " << kApexPackageSystemDir
+               << " : " << status.ErrorMessage();
+    return 1;
+  }
   LOG(INFO) << "Bootstrapping done";
   return 0;
 }