Remove all mentions of Set/Get Track and hard-coding of canary-channel.

This CL removes the deprecated functionality of Set/Get Track previously
used to change channels. Now that the UI is using Set/Get Channel we no
longer need these methods. I've also gone ahead and fixed the long standing
bug of needed to do an update check before testing channel change.

I've also added the testing of allow powerwash functionality to update_engine
client to better test this feature.

BUG=chromium:221850
TEST=unittests + update_engine_client with channel change and allowing
powerwash and not allowing powerwash. Confirmed the versions were as expected (
when going more stable we send version 0.0.0.0 when we allow powerwash vs the
actual version when not).

Change-Id: I87297f7e7e103bb25e62f2d896e155e758030ead
Reviewed-on: https://gerrit.chromium.org/gerrit/63674
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/update_engine_client.cc b/update_engine_client.cc
index 3455a52..e959534 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -33,7 +33,8 @@
 DEFINE_bool(reset_status, false, "Sets the status in update_engine to idle.");
 DEFINE_bool(rollback, false, "Perform a rollback to the previous partition.");
 DEFINE_bool(show_channel, false, "Show the current and target channels.");
-DEFINE_bool(powerwash, true, "When performing a rollback, do a powerwash.");
+DEFINE_bool(powerwash, true, "When performing rollback or channel change, "
+    "do a powerwash or allow it respectively.");
 DEFINE_bool(status, false, "Print the status to stdout.");
 DEFINE_bool(update, false, "Forces an update and waits for its completion. "
             "Exit status is 0 if the update succeeded, and 1 otherwise.");
@@ -230,7 +231,7 @@
   return true;
 }
 
-void SetTargetChannel(const string& target_channel) {
+void SetTargetChannel(const string& target_channel, bool allow_powerwash) {
   DBusGProxy* proxy;
   GError* error = NULL;
 
@@ -239,7 +240,7 @@
   gboolean rc =
       org_chromium_UpdateEngineInterface_set_channel(proxy,
                                                      target_channel.c_str(),
-                                                     true, // OK to Powerwash
+                                                     allow_powerwash,
                                                      &error);
   CHECK_EQ(rc, true) << "Error setting the channel: "
                      << GetAndFreeGError(&error);
@@ -372,9 +373,14 @@
               << (allowed ? "ENABLED" : "DISABLED");
   }
 
+  if (!FLAGS_powerwash && !FLAGS_rollback && FLAGS_channel.empty()) {
+    LOG(FATAL) << "powerwash flag only makes sense rollback or channel change";
+    return 1;
+  }
+
   // First, update the target channel if requested.
   if (!FLAGS_channel.empty())
-    SetTargetChannel(FLAGS_channel);
+    SetTargetChannel(FLAGS_channel, FLAGS_powerwash);
 
   // Show the current and target channels if requested.
   if (FLAGS_show_channel) {
@@ -389,11 +395,6 @@
   bool do_update_request = FLAGS_check_for_update | FLAGS_update |
       !FLAGS_app_version.empty() | !FLAGS_omaha_url.empty();
 
-  if (!FLAGS_powerwash && !FLAGS_rollback) {
-    LOG(FATAL) << "Skipping powerwash only works with rollback";
-    return 1;
-  }
-
   if (do_update_request && FLAGS_rollback) {
     LOG(FATAL) << "Update should not be requested with rollback!";
     return 1;