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/dbus_service.cc b/dbus_service.cc
index bc84858..cf6bbae 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -154,30 +154,6 @@
   return TRUE;
 }
 
-gboolean update_engine_service_set_track(UpdateEngineService* self,
-                                         gchar* track,
-                                         GError **error) {
-  // track == target channel.
-  // TODO(jaysri): Remove this method once chromium:219292 is fixed.
-  // Since UI won't be ready for now, preserve the existing
-  // behavior for set_track by calling SetTargetChannel directly without the
-  // policy checks instead of calling update_engine_service_set_channel.
-  LOG(INFO) << "Setting destination track to: " << track;
-  if (!self->system_state_->request_params()->SetTargetChannel(track, false)) {
-    *error = NULL;
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-gboolean update_engine_service_get_track(UpdateEngineService* self,
-                                         gchar** track,
-                                         GError **error) {
-  // track == target channel.
-  return update_engine_service_get_channel(self, false, track, error);
-}
-
 gboolean update_engine_service_set_channel(UpdateEngineService* self,
                                            gchar* target_channel,
                                            bool is_powerwash_allowed,
@@ -187,14 +163,21 @@
 
   const policy::DevicePolicy* device_policy =
       self->system_state_->device_policy();
+
+  // The device_policy is loaded in a lazy way before an update check. Load it
+  // now from the libchromeos cache if it wasn't already loaded.
   if (!device_policy) {
-    LOG(INFO) << "Cannot set target channel until device policy/settings are "
-                 "known";
-    return FALSE;
+    chromeos_update_engine::UpdateAttempter* update_attempter =
+        self->system_state_->update_attempter();
+    if (update_attempter) {
+      update_attempter->RefreshDevicePolicy();
+      device_policy = self->system_state_->device_policy();
+    }
   }
 
   bool delegated = false;
-  if (device_policy->GetReleaseChannelDelegated(&delegated) && !delegated) {
+  if (device_policy &&
+      device_policy->GetReleaseChannelDelegated(&delegated) && !delegated) {
     LOG(INFO) << "Cannot set target channel explicitly when channel "
                  "policy/settings is not delegated";
     return FALSE;
@@ -239,7 +222,7 @@
         self->system_state_->update_attempter();
     if (update_attempter) {
       update_attempter->RefreshDevicePolicy();
-      device_policy = self->system_state_->device_policy();;
+      device_policy = self->system_state_->device_policy();
     }
   }