From 5fef14176a54b9a213837d3fbc7f120766231497 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 24 Sep 2019 14:36:30 +0200 Subject: [PATCH] broadband-modem: ignore SIM-related errors in voice support check --- src/mm-broadband-modem.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index d1ffa0b9..3e0efb33 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -7323,6 +7323,20 @@ modem_voice_check_support_finish (MMIfaceModemVoice *self, return g_task_propagate_boolean (G_TASK (res), error); } +static void +ignore_sim_related_errors (GError **error) +{ + g_assert (error && *error); + 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_PIN) || + g_error_matches (*error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_PUK) || + 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_BUSY) || + g_error_matches (*error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG)) { + g_clear_error (error); + } +} + static void clcc_format_check_ready (MMBroadbandModem *self, GAsyncResult *res, @@ -7350,9 +7364,15 @@ ath_format_check_ready (MMBroadbandModem *self, mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); if (error) { - g_task_return_error (task, error); - g_object_unref (task); - return; + /* Ignore some errors that the module may return when there is no SIM inserted or + * if the SIM is PIN-locked. We do need the voice interface exposed even in those + * cases, in order to support emergency calls */ + ignore_sim_related_errors (&error); + if (error) { + g_task_return_error (task, error); + g_object_unref (task); + return; + } } /* Also check if +CLCC is supported */