broadband-modem: if locked, don't try to initialize remaining interfaces

Whenever we get unlocked, the modem initialization sequence will be run again.
This commit is contained in:
Aleksander Morgado
2012-02-01 18:12:44 +01:00
parent 47a9903901
commit cd5e9c27a3
3 changed files with 35 additions and 6 deletions

View File

@@ -151,8 +151,18 @@ initialize_ready (MMBaseModem *self,
GError *error = NULL;
if (!MM_BASE_MODEM_GET_CLASS (self)->initialize_finish (self, res, &error)) {
mm_warn ("couldn't initialize the modem: '%s'", error->message);
mm_base_modem_set_valid (self, FALSE);
/* Wrong state is returned when modem is found locked */
if (g_error_matches (error,
MM_CORE_ERROR,
MM_CORE_ERROR_WRONG_STATE)) {
mm_dbg ("Couldn't finish initialization in the current state: '%s'",
error->message);
mm_base_modem_set_valid (self, TRUE);
} else {
mm_warn ("couldn't initialize the modem: '%s'", error->message);
mm_base_modem_set_valid (self, FALSE);
}
g_error_free (error);
return;
}

View File

@@ -5377,6 +5377,7 @@ enable (MMBaseModem *self,
typedef enum {
INITIALIZE_STEP_FIRST,
INITIALIZE_STEP_IFACE_MODEM,
INITIALIZE_STEP_ABORT_IF_LOCKED,
INITIALIZE_STEP_IFACE_3GPP,
INITIALIZE_STEP_IFACE_3GPP_USSD,
INITIALIZE_STEP_IFACE_CDMA,
@@ -5504,6 +5505,22 @@ initialize_step (InitializeContext *ctx)
ctx);
return;
case INITIALIZE_STEP_ABORT_IF_LOCKED:
/* If we find ourselves in a LOCKED state, we shouldn't keep on
* the initialization sequence. Instead, we will re-initialize once
* we are unlocked. */
if (ctx->self->priv->modem_state == MM_MODEM_STATE_LOCKED) {
g_simple_async_result_set_error (ctx->result,
MM_CORE_ERROR,
MM_CORE_ERROR_WRONG_STATE,
"Modem is currently locked, "
"cannot fully initialize");
initialize_context_complete_and_free (ctx);
return;
}
/* Fall down to next step */
ctx->step++;
case INITIALIZE_STEP_IFACE_3GPP:
if (mm_iface_modem_is_3gpp (MM_IFACE_MODEM (ctx->self))) {
/* Initialize the 3GPP interface */

View File

@@ -1640,10 +1640,12 @@ unlock_check_context_free (UnlockCheckContext *ctx)
static gboolean
restart_initialize_idle (MMIfaceModem *self)
{
mm_iface_modem_initialize (self,
mm_base_modem_get_port_primary (MM_BASE_MODEM (self)),
NULL,
NULL);
MM_BASE_MODEM_GET_CLASS (self)->initialize (
MM_BASE_MODEM (self),
mm_base_modem_get_port_primary (MM_BASE_MODEM (self)),
NULL,
NULL,
NULL);
return FALSE;
}