Don't scatter during OOBE or user-initiated update checks.

We need to add logic to disable scattering of downloads if we are in OOBE
or if we're doing a manual update check.

Scheduled checks are already disabled during OOBE, but this extra check
will ensure that any scattering policy (there's a pending work item to get
policy during OOBE) during OOBE will have no effect on the update.

Similarly manual (i.e user-initiated) update checks through
update_engine_client or through Chrome UI should not honor scattering.
That way, this can serve as a simple user-friendly workaround in case
there's any bug in scattering logic that bricks the system by any chance.

BUG=chromeos-31563: Don't scatter during OOBE or manual update checks.
TEST=Updated unit tests. Tested all code paths manually on ZGB and Kaen.
Change-Id: Ib631e560c1f620ca53db79ee59dc66efb27ea83c
Reviewed-on: https://gerrit.chromium.org/gerrit/24564
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/utils.h b/utils.h
index cce30ca..fd9782a 100644
--- a/utils.h
+++ b/utils.h
@@ -27,10 +27,6 @@
 // Returns true if this is an official Chrome OS build, false otherwise.
 bool IsOfficialBuild();
 
-// Returns true if the OOBE process has been completed and EULA accepted, false
-// otherwise.
-bool IsOOBEComplete();
-
 // Returns true if the boot mode is normal or if it's unable to determine the
 // boot mode. Returns false if the boot mode is developer.
 bool IsNormalBootMode();
@@ -272,6 +268,25 @@
 
 }  // namespace utils
 
+
+// An interface to get the state of the current system.
+// Carved out separately so it can be mocked for unit tests.
+// Currently it has only one method, but we should start migrating other
+// methods to use this as and when needed to unit test them.
+class SystemState {
+  public:
+    // Returns true if the OOBE process has been completed and EULA accepted.
+    // False otherwise.
+    virtual bool IsOOBEComplete() = 0;
+};
+
+// A real implementation of the SystemStateInterface which is
+// used by the actual product code.
+class RealSystemState : public SystemState {
+  public:
+    virtual bool IsOOBEComplete();
+};
+
 // Class to unmount FS when object goes out of scope
 class ScopedFilesystemUnmounter {
  public: