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/omaha_request_params.cc b/omaha_request_params.cc
index 7cef85a..7a3087c 100644
--- a/omaha_request_params.cc
+++ b/omaha_request_params.cc
@@ -30,17 +30,19 @@
 
 namespace chromeos_update_engine {
 
-const char* const OmahaRequestParams::kAppId(
-    "{87efface-864d-49a5-9bb3-4b050a7c227a}");
-const char* const OmahaRequestParams::kOsPlatform("Chrome OS");
-const char* const OmahaRequestParams::kOsVersion("Indy");
-const char* const kProductionOmahaUrl(
-    "https://tools.google.com/service/update2");
+const char kProductionOmahaUrl[] =
+    "https://tools.google.com/service/update2";
+const char kAUTestOmahaUrl[] =
+    "https://omaha.sandbox.google.com/service/update2";
 
-const char* const OmahaRequestParams::kUpdateChannelKey(
-    "CHROMEOS_RELEASE_TRACK");
-const char* const OmahaRequestParams::kIsPowerwashAllowedKey(
-    "CHROMEOS_IS_POWERWASH_ALLOWED");
+const char OmahaRequestParams::kAppId[] =
+    "{87efface-864d-49a5-9bb3-4b050a7c227a}";
+const char OmahaRequestParams::kOsPlatform[] = "Chrome OS";
+const char OmahaRequestParams::kOsVersion[] = "Indy";
+const char OmahaRequestParams::kUpdateChannelKey[] = "CHROMEOS_RELEASE_TRACK";
+const char OmahaRequestParams::kIsPowerwashAllowedKey[] =
+    "CHROMEOS_IS_POWERWASH_ALLOWED";
+const char OmahaRequestParams::kAutoUpdateServerKey[] = "CHROMEOS_AUSERVER";
 
 const char* kChannelsByStability[] = {
     // This list has to be sorted from least stable to most stable channel.
@@ -103,8 +105,8 @@
   }
 
   if (in_update_url.empty())
-    update_url_ = GetLsbValue("CHROMEOS_AUSERVER", kProductionOmahaUrl, nullptr,
-                              stateful_override);
+    update_url_ = GetLsbValue(kAutoUpdateServerKey, kProductionOmahaUrl,
+                              nullptr, stateful_override);
   else
     update_url_ = in_update_url;
 
@@ -113,6 +115,12 @@
   return true;
 }
 
+bool OmahaRequestParams::IsUpdateUrlOfficial() const {
+  return (update_url_ == kAUTestOmahaUrl ||
+          update_url_ == GetLsbValue(kAutoUpdateServerKey, kProductionOmahaUrl,
+                                     nullptr, !ShouldLockDown()));
+}
+
 bool OmahaRequestParams::CollectECFWVersions() const {
   return {
       StartsWithASCII(hwid_, string("SAMS ALEX"), true) ||