Cancel the current download if user chooses a different channel.
In my earlier CL, to keep the implementation simple, we disallowed changing
a channel until the previous change completed in its entirety. Given that
the UI is not going to be updated for M27, such a restriction turned out
to be very confusing when playing around with channel changing. So, we
decided to implement a simple form of canceling the download if the
user selected a different channel while we're downloading the bits. This
implementation can easily be extended to support a general form of cancel
in the future, if required.
This CL also adds validation of libchromeos API calls when interpreting
the policy values. It also cleans up some bogus error messages that were
logged earlier when we abort a download.
BUG=chromium:222617
TEST=All scenarios pass on ZGB. Unit Tests pass.
Change-Id: I7cd691fe461d9ce47314299f6e2598944650ee33
Reviewed-on: https://gerrit.chromium.org/gerrit/46095
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/dbus_service.cc b/dbus_service.cc
index b4cc7c8..97aae35 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -7,6 +7,7 @@
#include <string>
#include <base/logging.h>
+#include <policy/device_policy.h>
#include "update_engine/marshal.glibmarshal.h"
#include "update_engine/omaha_request_params.h"
@@ -145,7 +146,17 @@
gchar* track,
GError **error) {
// track == target channel.
- return update_engine_service_set_channel(self, track, false, error);
+ // 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,
@@ -162,18 +173,16 @@
if (!target_channel)
return FALSE;
- if (!self->system_state_->device_policy()) {
+ const policy::DevicePolicy* device_policy =
+ self->system_state_->device_policy();
+ if (!device_policy) {
LOG(INFO) << "Cannot set target channel until device policy/settings are "
"known";
return FALSE;
}
bool delegated = false;
- self->system_state_->device_policy()->GetReleaseChannelDelegated(&delegated);
- if (!delegated) {
- // Note: This message will appear in UE logs with the current UI code
- // because UI hasn't been modified to call this method only if
- // delegated is set to true. chromium-os:219292 tracks this work item.
+ if (!(device_policy->GetReleaseChannelDelegated(&delegated) && delegated)) {
LOG(INFO) << "Cannot set target channel explicitly when channel "
"policy/settings is not delegated";
return FALSE;