diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-12-18 14:39:20 +0100 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2020-01-06 20:17:08 +0000 |
commit | 4862e42c86505cc607989bd30c2ce25390786321 (patch) | |
tree | dbf4792aabf9a441b4f78b1988c63d23391ea9ff /src | |
parent | 19618b4f51703b774c54a9ddb17187554294259d (diff) |
iface-modem-3gpp: fix manual re-registration to the same operator
We should not assume that a manual registration request to a given
operator is successful if the modem is already registered in that
operator, because if the registration was due to an automatic process,
we cannot make sure the modem won't roam to a different network.
We should only assume that a manual registration is not needed to be
relaunched if the modem is already registered in the requested network
AND if the registration process was manual (i.e. we asked the modem to
lock into a given network).
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-iface-modem-3gpp.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index c440af71..8e859d57 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -385,11 +385,12 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self, GAsyncReadyCallback callback, gpointer user_data) { - RegisterInNetworkContext *ctx; - const gchar *current_operator_code; - GError *error = NULL; - GTask *task; - Private *priv; + RegisterInNetworkContext *ctx; + const gchar *current_operator_code; + GError *error = NULL; + GTask *task; + Private *priv; + MMModem3gppRegistrationState reg_state; priv = get_private (self); @@ -428,14 +429,16 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self, } current_operator_code = mm_gdbus_modem3gpp_get_operator_code (ctx->skeleton); + reg_state = mm_gdbus_modem3gpp_get_registration_state (ctx->skeleton); /* Manual registration requested? */ if (ctx->operator_id) { - /* If already registered with the requested operator, we're done */ - if (current_operator_code && - g_str_equal (current_operator_code, ctx->operator_id)) { - priv->manual_registration = TRUE; - mm_dbg ("Already registered in selected network '%s'...", + /* If already registered manually with the requested operator, we're done */ + if ((g_strcmp0 (current_operator_code, ctx->operator_id) == 0) && + REG_STATE_IS_REGISTERED (reg_state) && + priv->manual_registration) { + mm_dbg ("Already registered manually in selected network '%s'," + " manual registration not launched...", current_operator_code); g_task_return_boolean (task, TRUE); g_object_unref (task); @@ -448,15 +451,11 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self, } /* Automatic registration requested? */ else { - MMModem3gppRegistrationState reg_state; - - reg_state = mm_gdbus_modem3gpp_get_registration_state (ctx->skeleton); - /* If the modem is already registered and the last time it was asked * automatic registration, we're done */ if ((current_operator_code || REG_STATE_IS_REGISTERED (reg_state)) && !priv->manual_registration) { - mm_dbg ("Already registered in network '%s'," + mm_dbg ("Already registered automatically in network '%s'," " automatic registration not launched...", current_operator_code); g_task_return_boolean (task, TRUE); |