iface-modem: run after-sim-unlock also when PIN request is not enabled

Whenever we query current unlock required status and we get that we're unlocked,
we'll launch the after-sim-unlock step so that we try to ensure that the SIM is
ready.
This commit is contained in:
Aleksander Morgado
2012-08-28 18:34:07 +02:00
parent 4114eabaa3
commit 1c49e35a8e

View File

@@ -2001,6 +2001,7 @@ struct _UnlockCheckContext {
guint pin_check_timeout_id; guint pin_check_timeout_id;
GSimpleAsyncResult *result; GSimpleAsyncResult *result;
MmGdbusModem *skeleton; MmGdbusModem *skeleton;
MMModemLock lock;
}; };
static UnlockCheckContext * static UnlockCheckContext *
@@ -2045,41 +2046,13 @@ reinitialize_ready (MMBaseModem *self,
} }
} }
static void
modem_after_sim_unlock_ready (MMIfaceModem *self,
GAsyncResult *res)
{
GError *error = NULL;
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->modem_after_sim_unlock_finish (self, res, &error)) {
mm_warn ("After SIM unlock failed setup: '%s'", error->message);
g_error_free (error);
}
/* Go on */
mm_base_modem_initialize (MM_BASE_MODEM (self),
(GAsyncReadyCallback) reinitialize_ready,
NULL);
}
static gboolean static gboolean
restart_initialize_idle (MMIfaceModem *self) restart_initialize_idle (MMIfaceModem *self)
{ {
/* If we were asked to run something after having sent the PIN unlock, /* If no wait needed, just go on */
* do it now. This may be just a timeout or some other command that gives us mm_base_modem_initialize (MM_BASE_MODEM (self),
* the real SIM state */ (GAsyncReadyCallback) reinitialize_ready,
if (MM_IFACE_MODEM_GET_INTERFACE (self)->modem_after_sim_unlock != NULL && NULL);
MM_IFACE_MODEM_GET_INTERFACE (self)->modem_after_sim_unlock_finish != NULL) {
MM_IFACE_MODEM_GET_INTERFACE (self)->modem_after_sim_unlock(
self,
(GAsyncReadyCallback)modem_after_sim_unlock_ready,
NULL);
} else {
/* If no wait needed, just go on */
mm_base_modem_initialize (MM_BASE_MODEM (self),
(GAsyncReadyCallback) reinitialize_ready,
NULL);
}
return FALSE; return FALSE;
} }
@@ -2145,17 +2118,37 @@ unlock_check_again (UnlockCheckContext *ctx)
return FALSE; return FALSE;
} }
static void
modem_after_sim_unlock_ready (MMIfaceModem *self,
GAsyncResult *res,
UnlockCheckContext *ctx)
{
GError *error = NULL;
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->modem_after_sim_unlock_finish (self, res, &error)) {
/* Complete anyway */
mm_warn ("After SIM unlock failed setup: '%s'", error->message);
g_error_free (error);
}
/* Update lock status and modem status if needed */
set_lock_status (self, ctx->skeleton, ctx->lock);
g_simple_async_result_set_op_res_gpointer (ctx->result,
GUINT_TO_POINTER (ctx->lock),
NULL);
g_simple_async_result_complete (ctx->result);
unlock_check_context_free (ctx);
}
static void static void
unlock_check_ready (MMIfaceModem *self, unlock_check_ready (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
UnlockCheckContext *ctx) UnlockCheckContext *ctx)
{ {
GError *error = NULL; GError *error = NULL;
MMModemLock lock;
lock = MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_required_finish (self, ctx->lock = MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_required_finish (self, res, &error);
res,
&error);
if (error) { if (error) {
/* Treat several SIM related, serial and other core errors as critical /* Treat several SIM related, serial and other core errors as critical
* and abort the checks. These will end up moving the modem to a FAILED * and abort the checks. These will end up moving the modem to a FAILED
@@ -2197,14 +2190,33 @@ unlock_check_ready (MMIfaceModem *self,
} }
/* If reached max retries and still reporting error, set UNKNOWN */ /* If reached max retries and still reporting error, set UNKNOWN */
lock = MM_MODEM_LOCK_UNKNOWN; ctx->lock = MM_MODEM_LOCK_UNKNOWN;
}
/* If we get that no lock is required, run the after SIM unlock step
* in order to wait for the SIM to get ready */
if (ctx->lock == MM_MODEM_LOCK_NONE ||
ctx->lock == MM_MODEM_LOCK_SIM_PIN2 ||
ctx->lock == MM_MODEM_LOCK_SIM_PUK2) {
if (MM_IFACE_MODEM_GET_INTERFACE (self)->modem_after_sim_unlock != NULL &&
MM_IFACE_MODEM_GET_INTERFACE (self)->modem_after_sim_unlock_finish != NULL) {
mm_dbg ("SIM is ready, running after SIM unlock step...");
MM_IFACE_MODEM_GET_INTERFACE (self)->modem_after_sim_unlock(
self,
(GAsyncReadyCallback)modem_after_sim_unlock_ready,
ctx);
return;
}
/* If no way to run after SIM unlock step, we're done */
mm_dbg ("SIM is ready, and no need for the after SIM unlock step...");
} }
/* Update lock status and modem status if needed */ /* Update lock status and modem status if needed */
set_lock_status (self, ctx->skeleton, lock); set_lock_status (self, ctx->skeleton, ctx->lock);
g_simple_async_result_set_op_res_gpointer (ctx->result, g_simple_async_result_set_op_res_gpointer (ctx->result,
GUINT_TO_POINTER (lock), GUINT_TO_POINTER (ctx->lock),
NULL); NULL);
g_simple_async_result_complete (ctx->result); g_simple_async_result_complete (ctx->result);
unlock_check_context_free (ctx); unlock_check_context_free (ctx);