Send an UMA metric when failed to boot into the new partition.

When a payload is successfully applied, the /other/ partition
is marked as valid and a reboot is needed, the reboot into this
new partition can fail due to several reasons. If than happens,
the firmware can rollback to the previous partition.

When this happens, this fix sends a new UMA metric with the
attempt number of this failing payload.

In order to test this functionality we need to fake the
utils::BootDevice() to emulate a reboot into the same or
a different partition. To achieve this, this function is
moved to a new "HardwareInterface" that can be faked
using the FakeHardware class that can hold similar hardware
related functions. Implementations and unittest were
refactored as needed.

BUG=chromium:243572
TEST=unittests

Change-Id: I1a4242df0bd61e2718ab881ead603b1d3705b877
Reviewed-on: https://gerrit.chromium.org/gerrit/61815
Commit-Queue: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/system_state.h b/system_state.h
index 56d38a6..08092f1 100644
--- a/system_state.h
+++ b/system_state.h
@@ -19,6 +19,7 @@
 // the required classes.
 class ClockInterface;
 class ConnectionManager;
+class HardwareInterface;
 class PrefsInterface;
 class PayloadStateInterface;
 class GpioHandler;
@@ -54,6 +55,9 @@
   // Gets the connection manager object.
   virtual ConnectionManager* connection_manager() = 0;
 
+  // Gets the hardware interface object.
+  virtual HardwareInterface* hardware() = 0;
+
   // Gets the Metrics Library interface for reporting UMA stats.
   virtual MetricsLibraryInterface* metrics_lib() = 0;