Enhanced channel changing behavior
This CL adds a new DBUS API to UpdateEngine called SetTargetChannel to
change the current channel of the device with an option to indicate
whether to do eventually or immediately.
The API will be called with the option to do it immediately in a
subsequent CL in Chrome UI. For now the old API (set_track) has been
wired up to call the new API to produce the old behavior (i.e. change
eventually). The old API will be removed after Chrome UI code stops
using it.
It's the UI's responsibility to ask the user for confirmation for the
powerwash that may happen in some cases and call the API with the
appropriate value whether or not the powerwash should happen.
For now, we're restricting the changing of channels to only those
devices that are on canary-channel or running test builds. This
restriction will be lifted off once the UI work is ready to give
warning to the users about the powerwash that may happen when they move
to a more stable channel.
We also enforce ReleaseChannelDelegated and ReleaseChannel policies
correctly now as follows:
* If ReleaseChannelDelegated is false, SetTargetChannel will fail as we
need to honor (only) the ReleaseChannel value in this case.
* If ReleaseChannelDelegated is true, we'll allow the SetTargetChannel
call to specify. In this case, we'll ignore the value of ReleaseChannel,
if any.
BUG=chromium-os:39095
TEST=Tested on ZGB by going from canary to dev-channel with and without
powerwash.
TEST=Existing unit tests have been updated and they pass.
TEST=New unit tests have been added.
Change-Id: Ifbf806a06e1c30d2f318e94d73735d1812049abd
Reviewed-on: https://gerrit.chromium.org/gerrit/44619
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.h b/dbus_service.h
index 56e4ef3..71e7997 100644
--- a/dbus_service.h
+++ b/dbus_service.h
@@ -34,7 +34,7 @@
struct UpdateEngineService {
GObject parent_instance;
- chromeos_update_engine::UpdateAttempter* update_attempter_;
+ chromeos_update_engine::SystemState* system_state_;
};
struct UpdateEngineServiceClass {
@@ -62,16 +62,40 @@
int64_t* new_size,
GError **error);
+gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self,
+ GError **error);
+
+// TODO(jaysri): Deprecate set_track and get_track once Chrome is modified to
+// use set_channel and get_channel.
+gboolean update_engine_service_set_track(UpdateEngineService* self,
+ gchar* track,
+ GError **error);
+
gboolean update_engine_service_get_track(UpdateEngineService* self,
gchar** track,
GError **error);
-gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self,
- GError **error);
+// Changes the current channel of the device to the target channel. If the
+// target channel is a less stable channel than the current channel, then the
+// channel change happens immediately (at the next update check). If the
+// target channel is a more stable channel, then if is_powerwash_allowed is set
+// to true, then also the change happens immediately but with a powerwash if
+// required. Otherwise, the change takes effect eventually (when the version on
+// the target channel goes above the version number of what the device
+// currently has).
+gboolean update_engine_service_set_channel(UpdateEngineService* self,
+ gchar* target_channel,
+ bool is_powerwash_allowed,
+ GError **error);
-gboolean update_engine_service_set_track(UpdateEngineService* self,
- gchar* track,
- GError **error);
+// If get_current_channel is set to true, populates |channel| with the name of
+// the channel that the device is currently on. Otherwise, it populates it with
+// the name of the channel the device is supposed to be (in case of a pending
+// channel change).
+gboolean update_engine_service_get_channel(UpdateEngineService* self,
+ bool get_current_channel,
+ gchar** channel,
+ GError **error);
gboolean update_engine_service_emit_status_update(
UpdateEngineService* self,