update_engine: Block force update + install when not idle

Currently |CheckForUpdate()| and |CheckForInstall()| sets the values of
|is_install_| to false and true respectively. The change of the value
|is_install_| at the initial entry to these functions will cause the
checks and actions taken within |ProcessingDone()| to behave as it's not
intended to. This unwanted behavior occurs because |ProcessingDone()|
depends on |UpdateAttempter|'s member variable |is_install_|. Until
|ProcessingDone()| is called, the |is_install_| value needs to remain
the same.

BUG=chromium:982929
TEST=FEATURES="test" emerge-$BOARD update_engine

Change-Id: Iddb55f1b46e66b9bc94b63e10e9f393f3cb89e1c
diff --git a/update_attempter.cc b/update_attempter.cc
index cf588e5..9573c43 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -830,19 +830,17 @@
 bool UpdateAttempter::CheckForUpdate(const string& app_version,
                                      const string& omaha_url,
                                      UpdateAttemptFlags flags) {
-  dlc_module_ids_.clear();
-  is_install_ = false;
-  bool interactive = !(flags & UpdateAttemptFlags::kFlagNonInteractive);
-
-  if (interactive && status_ != UpdateStatus::IDLE) {
-    // An update check is either in-progress, or an update has completed and the
-    // system is in UPDATED_NEED_REBOOT.  Either way, don't do an interactive
-    // update at this time.
-    LOG(INFO) << "Refusing to do an interactive update with an update already "
-                 "in progress";
+  if (status_ != UpdateStatus::IDLE) {
+    LOG(INFO) << "Refusing to do an update as there is an "
+              << (is_install_ ? "install" : "update")
+              << " already in progress.";
     return false;
   }
 
+  bool interactive = !(flags & UpdateAttemptFlags::kFlagNonInteractive);
+  dlc_module_ids_.clear();
+  is_install_ = false;
+
   LOG(INFO) << "Forced update check requested.";
   forced_app_version_.clear();
   forced_omaha_url_.clear();
@@ -888,6 +886,13 @@
 
 bool UpdateAttempter::CheckForInstall(const vector<string>& dlc_module_ids,
                                       const string& omaha_url) {
+  if (status_ != UpdateStatus::IDLE) {
+    LOG(INFO) << "Refusing to do an install as there is an "
+              << (is_install_ ? "install" : "update")
+              << " already in progress.";
+    return false;
+  }
+
   dlc_module_ids_ = dlc_module_ids;
   is_install_ = true;
   forced_omaha_url_.clear();