update_engine: Report VPD write failure to UMA

Currently we see many first actives to come from non-FSI images. But we have not
been able to figure out why. This CL, reports a new error
kFirstActiveOmahaPingSentPersistenceError when writing the first active omaha
flag into VPD fails. This allows us to see if that is the actual cause of the
problem.

CL:1062659 adds the enum value on the Chrome side.

BUG=chromium:833980
TEST=unittests
TEST=precq

Change-Id: I65e233c5f895489ba905494fb20d7b00d0c4af10
Reviewed-on: https://chromium-review.googlesource.com/1062662
Commit-Ready: ChromeOS CL Exonerator Bot <[email protected]>
Tested-by: Amin Hassani <[email protected]>
Reviewed-by: Amin Hassani <[email protected]>
Reviewed-by: Ben Chan <[email protected]>
diff --git a/common/error_code.h b/common/error_code.h
index c301155..a7fee2a 100644
--- a/common/error_code.h
+++ b/common/error_code.h
@@ -78,6 +78,7 @@
   kUpdatedButNotActive = 52,
   kNoUpdate = 53,
   kRollbackNotPossible = 54,
+  kFirstActiveOmahaPingSentPersistenceError = 55,
 
   // VERY IMPORTANT! When adding new error codes:
   //
diff --git a/common/error_code_utils.cc b/common/error_code_utils.cc
index a0e75f0..2a2a0a3 100644
--- a/common/error_code_utils.cc
+++ b/common/error_code_utils.cc
@@ -152,6 +152,8 @@
       return "ErrorCode::kNoUpdate";
     case ErrorCode::kRollbackNotPossible:
       return "ErrorCode::kRollbackNotPossible";
+    case ErrorCode::kFirstActiveOmahaPingSentPersistenceError:
+      return "ErrorCode::kFirstActiveOmahaPingSentPersistenceError";
       // Don't add a default case to let the compiler warn about newly added
       // error codes which should be added here.
   }
diff --git a/common/fake_hardware.h b/common/fake_hardware.h
index d699fb7..d68b0f8 100644
--- a/common/fake_hardware.h
+++ b/common/fake_hardware.h
@@ -110,8 +110,9 @@
     return first_active_omaha_ping_sent_;
   }
 
-  void SetFirstActiveOmahaPingSent() override {
+  bool SetFirstActiveOmahaPingSent() override {
     first_active_omaha_ping_sent_ = true;
+    return true;
   }
 
   // Setters
diff --git a/common/hardware_interface.h b/common/hardware_interface.h
index 4d7c162..239e7c8 100644
--- a/common/hardware_interface.h
+++ b/common/hardware_interface.h
@@ -110,9 +110,9 @@
   // |SetFirstActiveOmahaPingSent()|.
   virtual bool GetFirstActiveOmahaPingSent() const = 0;
 
-  // Persist the fact that first active ping was sent to omaha. It bails out if
-  // it fails.
-  virtual void SetFirstActiveOmahaPingSent() = 0;
+  // Persist the fact that first active ping was sent to omaha and returns false
+  // if failed to persist it.
+  virtual bool SetFirstActiveOmahaPingSent() = 0;
 };
 
 }  // namespace chromeos_update_engine