aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-04-09 11:09:45 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-04-10 08:24:52 +0000
commit4758e49d879c47a92cd76156f0f7ec7739ceb39f (patch)
tree980801d18c1e29ff4c3e8dd68d4da51669835b15
parentff97a776315d9e61f793c7312edce1f7e833f04a (diff)
broadband-modem-qmi: request operator reload explicitly
If the modem switches from one roaming operator to a different roaming operator, the actual operator MCCMNC/description will change even if the registration state keeps on being the same (roaming). Detect that, and trigger operator info reloading explicitly.
-rw-r--r--src/mm-broadband-modem-qmi.c59
1 files changed, 40 insertions, 19 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 0349be6d..599ebd68 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -2604,6 +2604,7 @@ common_process_serving_system_3gpp (MMBroadbandModemQmi *self,
MMModemAccessTechnology mm_access_technologies;
MMModem3gppRegistrationState mm_cs_registration_state;
MMModem3gppRegistrationState mm_ps_registration_state;
+ gboolean operator_updated = FALSE;
if (response_output)
qmi_message_nas_get_serving_system_output_get_serving_system (
@@ -2649,6 +2650,8 @@ common_process_serving_system_3gpp (MMBroadbandModemQmi *self,
MMModem3gppRegistrationState reg_state_3gpp;
mm_obj_dbg (self, "no 3GPP info given...");
+ if (self->priv->current_operator_id || self->priv->current_operator_description)
+ operator_updated = TRUE;
g_free (self->priv->current_operator_id);
self->priv->current_operator_id = NULL;
g_free (self->priv->current_operator_description);
@@ -2663,6 +2666,10 @@ common_process_serving_system_3gpp (MMBroadbandModemQmi *self,
mm_iface_modem_3gpp_update_ps_registration_state (MM_IFACE_MODEM_3GPP (self), reg_state_3gpp);
mm_iface_modem_3gpp_update_access_technologies (MM_IFACE_MODEM_3GPP (self), MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN);
mm_iface_modem_3gpp_update_location (MM_IFACE_MODEM_3GPP (self), 0, 0, 0);
+ /* request to reload operator info explicitly, so that the new
+ * operator name and code is propagated to the DBus interface */
+ if (operator_updated)
+ mm_iface_modem_3gpp_reload_current_registration_info (MM_IFACE_MODEM_3GPP (self), NULL, NULL);
return;
}
@@ -2702,23 +2709,28 @@ common_process_serving_system_3gpp (MMBroadbandModemQmi *self,
&mnc,
&description,
NULL))) {
+ gchar *new_operator_id;
+
/* When we don't have information about leading PCS digit, guess best */
- g_free (self->priv->current_operator_id);
if (mnc >= 100)
- self->priv->current_operator_id =
- g_strdup_printf ("%.3" G_GUINT16_FORMAT "%.3" G_GUINT16_FORMAT,
- mcc,
- mnc);
+ new_operator_id = g_strdup_printf ("%.3" G_GUINT16_FORMAT "%.3" G_GUINT16_FORMAT, mcc, mnc);
else
- self->priv->current_operator_id =
- g_strdup_printf ("%.3" G_GUINT16_FORMAT "%.2" G_GUINT16_FORMAT,
- mcc,
- mnc);
-
- g_clear_pointer (&self->priv->current_operator_description, g_free);
- /* Some Telit modems apparently sometimes report non-UTF8 characters */
- if (g_utf8_validate (description, -1, NULL))
- self->priv->current_operator_description = g_strdup (description);
+ new_operator_id = g_strdup_printf ("%.3" G_GUINT16_FORMAT "%.2" G_GUINT16_FORMAT, mcc, mnc);
+
+ if (!self->priv->current_operator_id || !g_str_equal (self->priv->current_operator_id, new_operator_id)) {
+ operator_updated = TRUE;
+ g_free (self->priv->current_operator_id);
+ self->priv->current_operator_id = new_operator_id;
+ } else
+ g_free (new_operator_id);
+
+ if (!self->priv->current_operator_description || !g_str_equal (self->priv->current_operator_description, description)) {
+ operator_updated = TRUE;
+ g_clear_pointer (&self->priv->current_operator_description, g_free);
+ /* Some Telit modems apparently sometimes report non-UTF8 characters */
+ if (g_utf8_validate (description, -1, NULL))
+ self->priv->current_operator_description = g_strdup (description);
+ }
}
/* If MNC comes with PCS digit, we must make sure the additional
@@ -2738,11 +2750,15 @@ common_process_serving_system_3gpp (MMBroadbandModemQmi *self,
&has_pcs_digit,
NULL))) &&
has_pcs_digit) {
- g_free (self->priv->current_operator_id);
- self->priv->current_operator_id =
- g_strdup_printf ("%.3" G_GUINT16_FORMAT "%.3" G_GUINT16_FORMAT,
- mcc,
- mnc);
+ gchar *new_operator_id;
+
+ new_operator_id = g_strdup_printf ("%.3" G_GUINT16_FORMAT "%.3" G_GUINT16_FORMAT, mcc, mnc);
+ if (!self->priv->current_operator_id || !g_str_equal (self->priv->current_operator_id, new_operator_id)) {
+ operator_updated = TRUE;
+ g_free (self->priv->current_operator_id);
+ self->priv->current_operator_id = new_operator_id;
+ } else
+ g_free (new_operator_id);
}
/* Report new registration states */
@@ -2768,6 +2784,11 @@ common_process_serving_system_3gpp (MMBroadbandModemQmi *self,
if (cid && (lac || tac))
mm_iface_modem_3gpp_update_location (MM_IFACE_MODEM_3GPP (self), lac, tac, cid);
+ /* request to reload operator info explicitly, so that the new
+ * operator name and code is propagated to the DBus interface */
+ if (operator_updated)
+ mm_iface_modem_3gpp_reload_current_registration_info (MM_IFACE_MODEM_3GPP (self), NULL, NULL);
+
/* Note: don't update access technologies with the ones retrieved here; they
* are not really the 'current' access technologies */
}