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_attempter.h b/update_attempter.h
index b38367d..deb0ff2 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -62,7 +62,8 @@
   UpdateAttempter(PrefsInterface* prefs,
                   MetricsLibraryInterface* metrics_lib,
                   DbusGlibInterface* dbus_iface,
-                  GpioHandler* gpio_handler);
+                  GpioHandler* gpio_handler,
+                  SystemState* system_state);
   virtual ~UpdateAttempter();
 
   // Checks for update and, if a newer version is available, attempts to update
@@ -71,12 +72,15 @@
   // update will likely respect Chrome's proxy setting. For security reasons, we
   // may still not honor them.  Interactive should be true if this was called
   // from the user (ie dbus).  |is_test| will lead to using an alternative test
-  // server URL, if |omaha_url| is empty.
+  // server URL, if |omaha_url| is empty. |is_user_initiated| will be true
+  // only if the update is being kicked off through dbus and will be false for
+  // other types of kick off such as scheduled updates.
   virtual void Update(const std::string& app_version,
                       const std::string& omaha_url,
                       bool obey_proxies,
                       bool interactive,
-                      bool is_test);
+                      bool is_test,
+                      bool is_user_initiated);
 
   // ActionProcessorDelegate methods:
   void ProcessingDone(const ActionProcessor* processor, ActionExitCode code);
@@ -232,7 +236,8 @@
                              const std::string& omaha_url,
                              bool obey_proxies,
                              bool interactive,
-                             bool is_test);
+                             bool is_test,
+                             bool is_user_initiated);
 
   // Helper method of Update() to construct the sequence of actions to
   // be performed for an update check. Please refer to
@@ -340,6 +345,10 @@
   // False otherwise.
   bool init_waiting_period_from_prefs_;
 
+  // External state of the system outside the update_engine process
+  // carved out separately to mock out easily in unit tests.
+  SystemState* system_state_;
+
   DISALLOW_COPY_AND_ASSIGN(UpdateAttempter);
 };