update_engine: Allow `cros flash` on base images.

A goal of the upcoming debugd dev tools (crbug.com/403170), is to
enable a path to modify a base image such that a developer could run
`cros flash` on it.

Currently update_engine disallows custom omaha URLs and forces a hash
check for base builds, which breaks `cros flash`. This CL relaxes the
restriction slightly to allow use on a base build as long as the system
is in dev mode and the debugd dev tools are also enabled (dev tools are
currently enabled only in dev mode when there is no owner).

The check is done in update_attempter.cc, which only allows an unofficial
Omaha URL if these conditions hold true (unofficial meaning not the main
AU server or the AU test server). The other main change is
AreHashChecksMandatory() in omaha_response_handler_action.cc, which now
allows skipping hash checks for unofficial Omaha URLs.

BUG=chromium:428053
TEST=Ran unit tests, `cros flash` on base images in various states.
CQ-DEPEND=CL:227431

Change-Id: I8583ce6aa70feac8fe74b7a3992e8a4e761833c3
Reviewed-on: https://chromium-review.googlesource.com/228293
Reviewed-by: Alex Deymo <deymo@chromium.org>
Trybot-Ready: David Pursell <dpursell@chromium.org>
Commit-Queue: David Pursell <dpursell@chromium.org>
Tested-by: David Pursell <dpursell@chromium.org>
diff --git a/dbus_service.cc b/dbus_service.cc
index ba99586..a7ec259 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -65,15 +65,6 @@
   return etype;
 }
 
-static const char kAUTestURLRequest[] = "autest";
-// By default autest bypasses scattering. If we want to test scattering,
-// we should use autest-scheduled. The Url used is same in both cases, but
-// different params are passed to CheckForUpdate method.
-static const char kScheduledAUTestURLRequest[] = "autest-scheduled";
-
-static const char kAUTestURL[] =
-    "https://omaha.sandbox.google.com/service/update2";
-
 G_DEFINE_TYPE(UpdateEngineService, update_engine_service, G_TYPE_OBJECT)
 
 static void update_engine_service_finalize(GObject* object) {
@@ -140,41 +131,21 @@
     gchar* omaha_url,
     gint flags_as_int,
     GError **error) {
-  string update_app_version;
-  string update_omaha_url;
+  string app_version_string, omaha_url_string;
   AttemptUpdateFlags flags = static_cast<AttemptUpdateFlags>(flags_as_int);
-  bool interactive = true;
+  bool interactive = !(flags & kAttemptUpdateFlagNonInteractive);
 
-  // Only non-official (e.g., dev and test) builds can override the current
-  // version and update server URL over D-Bus. However, pointing to the
-  // hardcoded test update server URL is always allowed.
-  if (!self->system_state_->hardware()->IsOfficialBuild()) {
-    if (app_version) {
-      update_app_version = app_version;
-    }
-    if (omaha_url) {
-      update_omaha_url = omaha_url;
-    }
-  }
-  if (omaha_url) {
-    if (strcmp(omaha_url, kScheduledAUTestURLRequest) == 0) {
-      update_omaha_url = kAUTestURL;
-      // pretend that it's not user-initiated even though it is,
-      // so as to test scattering logic, etc. which get kicked off
-      // only in scheduled update checks.
-      interactive = false;
-    } else if (strcmp(omaha_url, kAUTestURLRequest) == 0) {
-      update_omaha_url = kAUTestURL;
-    }
-  }
-  if (flags & kAttemptUpdateFlagNonInteractive)
-    interactive = false;
-  LOG(INFO) << "Attempt update: app_version=\"" << update_app_version << "\" "
-            << "omaha_url=\"" << update_omaha_url << "\" "
+  if (app_version)
+    app_version_string = app_version;
+  if (omaha_url)
+    omaha_url_string = omaha_url;
+
+  LOG(INFO) << "Attempt update: app_version=\"" << app_version_string << "\" "
+            << "omaha_url=\"" << omaha_url_string << "\" "
             << "flags=0x" << std::hex << flags << " "
             << "interactive=" << (interactive? "yes" : "no");
-  self->system_state_->update_attempter()->CheckForUpdate(update_app_version,
-                                                          update_omaha_url,
+  self->system_state_->update_attempter()->CheckForUpdate(app_version_string,
+                                                          omaha_url_string,
                                                           interactive);
   return TRUE;
 }