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/update_check_scheduler.h b/update_check_scheduler.h
index cd3ad87..16f831e 100644
--- a/update_check_scheduler.h
+++ b/update_check_scheduler.h
@@ -42,7 +42,8 @@
   static const int kTimeoutMaxBackoffInterval;
 
   UpdateCheckScheduler(UpdateAttempter* update_attempter,
-                       GpioHandler* gpio_handler);
+                       GpioHandler* gpio_handler,
+                       SystemState* system_state);
   virtual ~UpdateCheckScheduler();
 
   // Initiates the periodic update checks, if necessary.
@@ -65,7 +66,6 @@
   FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzTest);
   FRIEND_TEST(UpdateCheckSchedulerTest, GTimeoutAddSecondsTest);
   FRIEND_TEST(UpdateCheckSchedulerTest, IsBootDeviceRemovableTest);
-  FRIEND_TEST(UpdateCheckSchedulerTest, IsOOBECompleteTest);
   FRIEND_TEST(UpdateCheckSchedulerTest, IsOfficialBuildTest);
   FRIEND_TEST(UpdateCheckSchedulerTest, RunBootDeviceRemovableTest);
   FRIEND_TEST(UpdateCheckSchedulerTest, RunNonOfficialBuildTest);
@@ -87,7 +87,6 @@
 
   // Wrappers for utils functions so that they can be mocked in tests.
   virtual bool IsBootDeviceRemovable();
-  virtual bool IsOOBEComplete();
   virtual bool IsOfficialBuild();
 
   // Returns true if an update check can be scheduled. An update check should
@@ -135,6 +134,9 @@
   // GPIO handler object.
   GpioHandler* gpio_handler_;
 
+  // The external state of the system outside the update_engine process.
+  SystemState* system_state_;
+
   DISALLOW_COPY_AND_ASSIGN(UpdateCheckScheduler);
 };