From 88077cbbe83a8d6beaed92a3277cab3ba0e429d3 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 15 Dec 2011 20:21:57 +0100 Subject: iface-modem: treat several SIM related errors as fatal If the SIM is not inserted or the modem reports SIM failures, just abort the initialization process. We don't want to export modems which cannot be used. I know at least of one modem (wavecom) which supports SIM insertion while connected, but being such a corner case, probably not worth supporting it. --- src/mm-iface-modem.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 4176af3b..5fca0660 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -806,6 +806,23 @@ unlock_check_ready (MMIfaceModem *self, res, &error); if (error) { + /* Treat several SIM related errors as critical and abort the checks + * TODO: do this only after the retries? */ + if (g_error_matches (error, + MM_MOBILE_EQUIPMENT_ERROR, + MM_MOBILE_EQUIPMENT_ERROR_SIM_NOT_INSERTED) || + g_error_matches (error, + MM_MOBILE_EQUIPMENT_ERROR, + MM_MOBILE_EQUIPMENT_ERROR_SIM_FAILURE) || + g_error_matches (error, + MM_MOBILE_EQUIPMENT_ERROR, + MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG)) { + g_simple_async_result_take_error (ctx->result, error); + g_simple_async_result_complete (ctx->result); + unlock_check_context_free (ctx); + return; + } + /* Retry up to 3 times */ if (mm_gdbus_modem_get_unlock_required (ctx->skeleton) != MM_MODEM_LOCK_NONE && ++ctx->pin_check_tries < 3) { @@ -1663,8 +1680,11 @@ load_unlock_required_ready (MMIfaceModem *self, /* NOTE: we already propagated the lock state, no need to do it again */ mm_iface_modem_unlock_check_finish (self, res, &error); if (error) { + /* FATAL */ mm_warn ("couldn't load unlock required status: '%s'", error->message); - g_error_free (error); + g_simple_async_result_take_error (ctx->result, error); + initialization_context_complete_and_free (ctx); + return; } /* Go on to next step */ -- cgit v1.2.3-70-g09d2