aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-11-27 15:24:40 +0100
committerAleksander Morgado <aleksander@aleksander.es>2017-01-16 11:24:12 +0100
commitf8ce041c7f1a5565c307bb680c099f07a1facb34 (patch)
tree571a4b8cdd66c20005568e39d4a7c3fe4b4cf09b
parent075991a454497ed9f8182d4b8fdb67c0d1dbfeb5 (diff)
downloadexternal_libqmi-f8ce041c7f1a5565c307bb680c099f07a1facb34.zip
external_libqmi-f8ce041c7f1a5565c307bb680c099f07a1facb34.tar.gz
external_libqmi-f8ce041c7f1a5565c307bb680c099f07a1facb34.tar.bz2
qmi-firmware-update: implement offline and reset
-rw-r--r--src/qmi-firmware-update/qfu-updater.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/qmi-firmware-update/qfu-updater.c b/src/qmi-firmware-update/qfu-updater.c
index 31c2094..f507f18 100644
--- a/src/qmi-firmware-update/qfu-updater.c
+++ b/src/qmi-firmware-update/qfu-updater.c
@@ -55,6 +55,8 @@ typedef enum {
RUN_CONTEXT_STEP_QMI_DEVICE_OPEN,
RUN_CONTEXT_STEP_QMI_CLIENT,
RUN_CONTEXT_STEP_FIRMWARE_PREFERENCE,
+ RUN_CONTEXT_STEP_OFFLINE,
+ RUN_CONTEXT_STEP_RESET,
RUN_CONTEXT_STEP_CLEANUP_QMI_DEVICE,
RUN_CONTEXT_STEP_CLEANUP_IMAGE,
RUN_CONTEXT_STEP_LAST
@@ -199,6 +201,80 @@ run_context_step_cleanup_qmi_device (GTask *task)
}
static void
+reset_or_offline_ready (QmiClientDms *client,
+ GAsyncResult *res,
+ GTask *task)
+{
+ QmiMessageDmsSetOperatingModeOutput *output;
+ GError *error = NULL;
+ RunContext *ctx;
+
+ ctx = (RunContext *) g_task_get_task_data (task);
+
+ output = qmi_client_dms_set_operating_mode_finish (client, res, &error);
+ if (!output) {
+ g_prefix_error (&error, "QMI operation failed: couldn't set operating mode: ");
+ g_task_return_error (task, error);
+ g_object_unref (task);
+ return;
+ }
+
+ if (!qmi_message_dms_set_operating_mode_output_get_result (output, &error)) {
+ g_prefix_error (&error, "couldn't set operating mode: ");
+ g_task_return_error (task, error);
+ g_object_unref (task);
+ qmi_message_dms_set_operating_mode_output_unref (output);
+ return;
+ }
+
+ g_debug ("[qfu-updater] operating mode set successfully...");
+
+ /* Go on */
+ run_context_step_next (task, ctx->step + 1);
+}
+
+static void
+run_context_step_reset (GTask *task)
+{
+ RunContext *ctx;
+ QmiMessageDmsSetOperatingModeInput *input;
+
+ ctx = (RunContext *) g_task_get_task_data (task);
+
+ g_debug ("[qfu-updater] setting operating mode 'reset'...");
+ input = qmi_message_dms_set_operating_mode_input_new ();
+ qmi_message_dms_set_operating_mode_input_set_mode (input, QMI_DMS_OPERATING_MODE_RESET, NULL);
+ qmi_client_dms_set_operating_mode (ctx->qmi_client,
+ input,
+ 10,
+ g_task_get_cancellable (task),
+ (GAsyncReadyCallback) reset_or_offline_ready,
+ task);
+ qmi_message_dms_set_operating_mode_input_unref (input);
+}
+
+
+static void
+run_context_step_offline (GTask *task)
+{
+ RunContext *ctx;
+ QmiMessageDmsSetOperatingModeInput *input;
+
+ ctx = (RunContext *) g_task_get_task_data (task);
+
+ g_debug ("[qfu-updater] setting operating mode 'offline'...");
+ input = qmi_message_dms_set_operating_mode_input_new ();
+ qmi_message_dms_set_operating_mode_input_set_mode (input, QMI_DMS_OPERATING_MODE_OFFLINE, NULL);
+ qmi_client_dms_set_operating_mode (ctx->qmi_client,
+ input,
+ 10,
+ g_task_get_cancellable (task),
+ (GAsyncReadyCallback) reset_or_offline_ready,
+ task);
+ qmi_message_dms_set_operating_mode_input_unref (input);
+}
+
+static void
set_firmware_preference_ready (QmiClientDms *client,
GAsyncResult *res,
GTask *task)
@@ -507,6 +583,8 @@ static const RunContextStepFunc run_context_step_func[] = {
[RUN_CONTEXT_STEP_QMI_DEVICE_OPEN] = run_context_step_qmi_device_open,
[RUN_CONTEXT_STEP_QMI_CLIENT] = run_context_step_qmi_client,
[RUN_CONTEXT_STEP_FIRMWARE_PREFERENCE] = run_context_step_firmware_preference,
+ [RUN_CONTEXT_STEP_OFFLINE] = run_context_step_offline,
+ [RUN_CONTEXT_STEP_RESET] = run_context_step_reset,
[RUN_CONTEXT_STEP_CLEANUP_QMI_DEVICE] = run_context_step_cleanup_qmi_device,
[RUN_CONTEXT_STEP_CLEANUP_IMAGE] = run_context_step_cleanup_image,
};