update_engine_client: Add -interactive=true|false flag

This makes it easier to test the update_engine codepaths dealing with
non-interactive update attempts.

BUG=chromium:273251
TEST=Manually tested with 'update_engine_client -update -interactive=X' +
    unit tests pass.

Change-Id: Id3894261fd1c0dc2afdf2426484835f487924433
Reviewed-on: https://chromium-review.googlesource.com/168445
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
diff --git a/update_engine_client.cc b/update_engine_client.cc
index 6e3e4f3..e09c0d4 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -20,6 +20,8 @@
 using chromeos_update_engine::kUpdateEngineServiceName;
 using chromeos_update_engine::kUpdateEngineServicePath;
 using chromeos_update_engine::kUpdateEngineServiceInterface;
+using chromeos_update_engine::AttemptUpdateFlags;
+using chromeos_update_engine::kAttemptUpdateFlagNonInteractive;
 using chromeos_update_engine::utils::GetAndFreeGError;
 using std::string;
 
@@ -50,6 +52,7 @@
 DEFINE_string(p2p_update, "",
               "Enables (\"yes\") or disables (\"no\") the peer-to-peer update "
               "sharing.");
+DEFINE_bool(interactive, true, "Mark the update request as interactive.");
 
 namespace {
 
@@ -208,10 +211,14 @@
 
   CHECK(GetProxy(&proxy));
 
-  gboolean rc = update_engine_client_attempt_update(proxy,
-                                                    app_version.c_str(),
-                                                    omaha_url.c_str(),
-                                                    &error);
+  AttemptUpdateFlags flags = static_cast<AttemptUpdateFlags>(
+      FLAGS_interactive ? 0 : kAttemptUpdateFlagNonInteractive);
+  gboolean rc =
+      update_engine_client_attempt_update_with_flags(proxy,
+                                                     app_version.c_str(),
+                                                     omaha_url.c_str(),
+                                                     static_cast<gint>(flags),
+                                                     &error);
   CHECK_EQ(rc, TRUE) << "Error checking for update: "
                      << GetAndFreeGError(&error);
   return true;