AU: Provide a D-Bus API for changing the update track.
The method is SetTrack(string). It doesn't do anything right now but hopefully
this CL will enable work on libcros.
BUG=8104
TEST=unit tests; tested on device through update_engine_client.
Change-Id: I6941fe3d04165d85c4612e3a01939d02c02014f9
Review URL: http://codereview.chromium.org/4094001
diff --git a/dbus_service.cc b/dbus_service.cc
index 08b953d..447a900 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -107,6 +107,15 @@
return TRUE;
}
+gboolean update_engine_service_set_track(UpdateEngineService* self,
+ gchar* track,
+ GError **error) {
+ if (track) {
+ LOG(INFO) << "TODO: Setting track to: " << track;
+ }
+ return TRUE;
+}
+
gboolean update_engine_service_emit_status_update(
UpdateEngineService* self,
gint64 last_checked_time,
diff --git a/dbus_service.h b/dbus_service.h
index 8c92995..b802fae 100644
--- a/dbus_service.h
+++ b/dbus_service.h
@@ -62,6 +62,10 @@
gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self,
GError **error);
+gboolean update_engine_service_set_track(UpdateEngineService* self,
+ gchar* track,
+ GError **error);
+
gboolean update_engine_service_emit_status_update(
UpdateEngineService* self,
gint64 last_checked_time,
diff --git a/update_engine.xml b/update_engine.xml
index 88e6871..73bc92e 100644
--- a/update_engine.xml
+++ b/update_engine.xml
@@ -20,6 +20,9 @@
</method>
<method name="RebootIfNeeded">
</method>
+ <method name="SetTrack">
+ <arg type="s" name="track" />
+ </method>
<signal name="StatusUpdate">
<arg type="x" name="last_checked_time" />
<arg type="d" name="progress" />
diff --git a/update_engine_client.cc b/update_engine_client.cc
index 7bbc62f..a662242 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -27,6 +27,7 @@
DEFINE_string(omaha_url, "", "The URL of the Omaha update server.");
DEFINE_bool(reboot, false, "Initiate a reboot if needed.");
DEFINE_bool(status, false, "Print the status to stdout.");
+DEFINE_string(track, "", "Permanently change the update track.");
DEFINE_bool(update, false, "Forces an update and waits for its completion. "
"Exit status is 0 if the update succeeded, and 1 otherwise.");
DEFINE_bool(watch_for_updates, false,
@@ -176,6 +177,21 @@
return true;
}
+void SetTrack(const string& track) {
+ DBusGProxy* proxy;
+ GError* error = NULL;
+
+ CHECK(GetProxy(&proxy));
+
+ gboolean rc =
+ org_chromium_UpdateEngineInterface_set_track(proxy,
+ track.c_str(),
+ &error);
+ CHECK_EQ(rc, true) << "Error setting the track: "
+ << GetGErrorMessage(error);
+ LOG(INFO) << "TODO: Track permanently set to: " << track;
+}
+
static gboolean CompleteUpdateSource(gpointer data) {
string current_op;
if (!GetStatus(¤t_op) || current_op == "UPDATE_STATUS_IDLE") {
@@ -218,6 +234,11 @@
return 0;
}
+ // First, update the track if requested.
+ if (!FLAGS_track.empty()) {
+ SetTrack(FLAGS_track);
+ }
+
// Initiate an update check, if necessary.
if (FLAGS_check_for_update ||
FLAGS_update ||
@@ -256,6 +277,6 @@
return 0;
}
- LOG(INFO) << "No flags specified. Exiting.";
+ LOG(INFO) << "Done.";
return 0;
}