return UPDATE_CONTROL_ERROR_NONE;
}
-API int update_control_do_update(void)
+static void do_update_cb(GObject *source_object, GAsyncResult *res, gpointer user_data)
{
- CHECK_FEATURE_SUPPORTED(DEVICE_UPDATE_FEATURE);
- _I("update_control_do_update called");
-
- gint status = 0;
- GError *error = NULL;
-
if (proxy == NULL) {
_E("Not initialized");
- return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
+ return;
}
- org_tizen_update_manager_call_install_sync(proxy, &status, NULL, &error);
+ gint status = 0;
+ GError *error = NULL;
+
+ org_tizen_update_manager_call_install_finish(proxy, &status, res, &error);
if (error != NULL) {
_E("Failed to method call <install> to dbus : %s", error->message);
- return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
+ g_error_free(error);
+ return;
}
_I("Success to method call <install> to dbus");
if (status < 0) {
_E("Failed to do update : %d", status);
- return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
+ return;
}
+ // NB: We shouldn't really end up here, since the target should be rebooted by now.
_I("Success to do update : %d", status);
+}
+
+API int update_control_do_update(void)
+{
+ CHECK_FEATURE_SUPPORTED(DEVICE_UPDATE_FEATURE);
+ _I("update_control_do_update called");
+
+ if (proxy == NULL) {
+ _E("Not initialized");
+ return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
+ }
+
+ // TODO: Take the fact that this is now async into account in docs.
+ // TODO: Consider making this asynchronous server-side instead.
+ org_tizen_update_manager_call_install(proxy, NULL, do_update_cb, NULL);
+ _I("Started update");
return UPDATE_CONTROL_ERROR_NONE;
}