aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Palmas <dnlplm@gmail.com>2021-10-18 16:01:39 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-11-09 08:34:01 +0000
commite5f08b776661eac1f3e151eb8fdf53edf190fca6 (patch)
treefc07bf9b19b5bbf82218565b6dbbedfe000b637a
parentba84f978557fdea8d3b7b8059fb22539daca9ded (diff)
broadband-modem-qmi: prefer system info indication if available
Prefer system info indication if available and fall back to serving system indication if the former is not supported.
-rw-r--r--src/mm-broadband-modem-qmi.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 2239bb14..52c80a6e 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -117,9 +117,7 @@ struct _MMBroadbandModemQmiPrivate {
gboolean unsolicited_registration_events_enabled;
gboolean unsolicited_registration_events_setup;
guint serving_system_indication_id;
-#if defined WITH_NEWEST_QMI_COMMANDS
guint system_info_indication_id;
-#endif /* WITH_NEWEST_QMI_COMMANDS */
guint network_reject_indication_id;
/* CDMA activation helpers */
@@ -3622,6 +3620,7 @@ modem_3gpp_run_registration_checks (MMIfaceModem3gpp *self,
typedef struct {
QmiClientNas *client;
gboolean enable; /* TRUE for enabling, FALSE for disabling */
+ gboolean system_info_checked;
} UnsolicitedRegistrationEventsContext;
static void
@@ -3660,6 +3659,9 @@ modem_3gpp_enable_disable_unsolicited_registration_events_finish (MMIfaceModem3g
}
static void
+common_enable_disable_unsolicited_registration_events_serving_system (GTask *task);
+
+static void
ri_serving_system_or_system_info_ready (QmiClientNas *client,
GAsyncResult *res,
GTask *task)
@@ -3674,24 +3676,28 @@ ri_serving_system_or_system_info_ready (QmiClientNas *client,
output = qmi_client_nas_register_indications_finish (client, res, &error);
if (!output || !qmi_message_nas_register_indications_output_get_result (output, &error)) {
- mm_obj_dbg (self, "couldn't register indications: '%s'", error->message);
- if (ctx->enable) {
-#if defined WITH_NEWEST_QMI_COMMANDS
- mm_obj_dbg (self, "assuming system info indications are always enabled");
-#else
- mm_obj_dbg (self, "assuming serving system indications are always enabled");
-#endif
+ if (!ctx->system_info_checked) {
+ mm_obj_dbg (self, "couldn't register system info indication: '%s', falling-back to serving system", error->message);
+ ctx->system_info_checked = TRUE;
+ common_enable_disable_unsolicited_registration_events_serving_system (task);
+ g_clear_error (&error);
+ return;
}
+
+
+ if (ctx->enable)
+ mm_obj_dbg (self, "couldn't register serving system indications: '%s', assuming always enabled", error->message);
}
+ if (!ctx->system_info_checked)
+ ctx->system_info_checked = TRUE;
+
/* Just ignore errors for now */
self->priv->unsolicited_registration_events_enabled = ctx->enable;
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
-#if !defined WITH_NEWEST_QMI_COMMANDS
-
static void
common_enable_disable_unsolicited_registration_events_serving_system (GTask *task)
{
@@ -3711,8 +3717,6 @@ common_enable_disable_unsolicited_registration_events_serving_system (GTask *tas
task);
}
-#else /* WITH_NEWEST_QMI_COMMANDS */
-
static void
common_enable_disable_unsolicited_registration_events_system_info (GTask *task)
{
@@ -3722,6 +3726,11 @@ common_enable_disable_unsolicited_registration_events_system_info (GTask *task)
ctx = g_task_get_task_data (task);
input = qmi_message_nas_register_indications_input_new ();
qmi_message_nas_register_indications_input_set_system_info (input, ctx->enable, NULL);
+ /* When enabling, serving system events are turned-off, since some modems have them
+ * active by default. They will be turned-on again if setting system info events fails
+ */
+ if (ctx->enable)
+ qmi_message_nas_register_indications_input_set_serving_system_events (input, FALSE, NULL);
qmi_message_nas_register_indications_input_set_network_reject_information (input, ctx->enable, FALSE, NULL);
qmi_client_nas_register_indications (
ctx->client,
@@ -3732,8 +3741,6 @@ common_enable_disable_unsolicited_registration_events_system_info (GTask *task)
task);
}
-#endif /* WITH_NEWEST_QMI_COMMANDS */
-
static void
modem_3gpp_disable_unsolicited_registration_events (MMIfaceModem3gpp *self,
gboolean cs_supported,
@@ -3756,11 +3763,7 @@ modem_3gpp_disable_unsolicited_registration_events (MMIfaceModem3gpp *self,
callback,
user_data);
-#if defined WITH_NEWEST_QMI_COMMANDS
common_enable_disable_unsolicited_registration_events_system_info (task);
-#else
- common_enable_disable_unsolicited_registration_events_serving_system (task);
-#endif /* WITH_NEWEST_QMI_COMMANDS */
}
static void
@@ -3785,11 +3788,7 @@ modem_3gpp_enable_unsolicited_registration_events (MMIfaceModem3gpp *self,
callback,
user_data);
-#if defined WITH_NEWEST_QMI_COMMANDS
common_enable_disable_unsolicited_registration_events_system_info (task);
-#else
- common_enable_disable_unsolicited_registration_events_serving_system (task);
-#endif /* WITH_NEWEST_QMI_COMMANDS */
}
/*****************************************************************************/
@@ -4745,7 +4744,6 @@ common_setup_cleanup_unsolicited_registration_events_finish (MMBroadbandModemQmi
return g_task_propagate_boolean (G_TASK (res), error);
}
-#if defined WITH_NEWEST_QMI_COMMANDS
static void
system_info_indication_cb (QmiClientNas *client,
QmiIndicationNasSystemInfoOutput *output,
@@ -4755,8 +4753,6 @@ system_info_indication_cb (QmiClientNas *client,
common_process_system_info_3gpp (self, NULL, output);
}
-#else /* WITH_NEWEST_QMI_COMMANDS */
-
static void
serving_system_indication_cb (QmiClientNas *client,
QmiIndicationNasServingSystemOutput *output,
@@ -4768,8 +4764,6 @@ serving_system_indication_cb (QmiClientNas *client,
common_process_serving_system_cdma (self, NULL, output);
}
-#endif
-
/* network reject indications enabled in both with/without newest QMI commands */
static void
network_reject_indication_cb (QmiClientNas *client,
@@ -4825,7 +4819,6 @@ common_setup_cleanup_unsolicited_registration_events (MMBroadbandModemQmi *self,
/* Store new state */
self->priv->unsolicited_registration_events_setup = enable;
-#if defined WITH_NEWEST_QMI_COMMANDS
/* Connect/Disconnect "System Info" indications */
if (enable) {
g_assert (self->priv->system_info_indication_id == 0);
@@ -4839,7 +4832,6 @@ common_setup_cleanup_unsolicited_registration_events (MMBroadbandModemQmi *self,
g_signal_handler_disconnect (client, self->priv->system_info_indication_id);
self->priv->system_info_indication_id = 0;
}
-#else
/* Connect/Disconnect "Serving System" indications */
if (enable) {
g_assert (self->priv->serving_system_indication_id == 0);
@@ -4853,7 +4845,6 @@ common_setup_cleanup_unsolicited_registration_events (MMBroadbandModemQmi *self,
g_signal_handler_disconnect (client, self->priv->serving_system_indication_id);
self->priv->serving_system_indication_id = 0;
}
-#endif /* WITH_NEWEST_QMI_COMMANDS */
/* Connect/Disconnect "Network Reject" indications */
if (enable) {