aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Holla <pholla@chromium.org>2020-11-23 17:52:17 +0000
committerAleksander Morgado <aleksander@aleksander.es>2020-11-26 08:53:14 +0000
commit38f6704fa1d6f602be84bcbf016b3386ac82c426 (patch)
treeb124b872fa77b0427c9cf9596a16aa08d69205fc
parent92c86e2b1bcdaab991d89bdd8f670b248c246bae (diff)
base-sim: Reprobe modem if lock status cannot be read after sending puk
If the lock status cannot be read during a puk unblock attempt, reprobe the modem. It is likely that the SIM was permanently blocked if the lock status cannot be read.
-rw-r--r--src/mm-base-modem.c2
-rw-r--r--src/mm-base-modem.h2
-rw-r--r--src/mm-base-sim.c37
-rw-r--r--src/mm-broadband-modem.c2
-rw-r--r--src/mm-device.c1
-rw-r--r--src/mm-iface-modem.c5
6 files changed, 34 insertions, 15 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index cdef6990..e5030dcb 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -1285,7 +1285,7 @@ after_sim_switch_disable_ready (MMBaseModem *self,
}
void
-mm_base_modem_process_sim_switch (MMBaseModem *self)
+mm_base_modem_process_sim_event (MMBaseModem *self)
{
mm_base_modem_set_reprobe (self, TRUE);
mm_base_modem_disable (self, (GAsyncReadyCallback) after_sim_switch_disable_ready, NULL);
diff --git a/src/mm-base-modem.h b/src/mm-base-modem.h
index 7b00b568..24634814 100644
--- a/src/mm-base-modem.h
+++ b/src/mm-base-modem.h
@@ -199,6 +199,6 @@ gboolean mm_base_modem_disable_finish (MMBaseModem *self,
GAsyncResult *res,
GError **error);
-void mm_base_modem_process_sim_switch (MMBaseModem *self);
+void mm_base_modem_process_sim_event (MMBaseModem *self);
#endif /* MM_BASE_MODEM_H */
diff --git a/src/mm-base-sim.c b/src/mm-base-sim.c
index b8570a3c..106a0a95 100644
--- a/src/mm-base-sim.c
+++ b/src/mm-base-sim.c
@@ -584,17 +584,17 @@ update_lock_info_ready (MMIfaceModem *modem,
const GError *saved_error;
/* Device is locked. Now:
+ * - If we got an error during update_lock_info, report it. The sim might have been blocked.
* - If we got an error in the original send-pin action, report it.
- * - If we got an error in the pin-check action, report it.
* - Otherwise, build our own error from the lock code.
*/
- saved_error = g_task_get_task_data (task);
- if (saved_error) {
- g_clear_error (&error);
- error = g_error_copy (saved_error);
- } else if (!error)
- error = error_for_unlock_check (lock);
-
+ if (!error) {
+ saved_error = g_task_get_task_data (task);
+ if (saved_error)
+ error = g_error_copy (saved_error);
+ else
+ error = error_for_unlock_check (lock);
+ }
g_task_return_error (task, error);
} else
g_task_return_boolean (task, TRUE);
@@ -869,12 +869,27 @@ handle_send_puk_ready (MMBaseSim *self,
HandleSendPukContext *ctx)
{
GError *error = NULL;
-
- if (!mm_base_sim_send_puk_finish (self, res, &error))
+ gboolean sim_error = FALSE;
+
+ if (!mm_base_sim_send_puk_finish (self, res, &error)) {
+ sim_error = 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_dbus_method_invocation_take_error (ctx->invocation, error);
- else
+ } else
mm_gdbus_sim_complete_send_puk (MM_GDBUS_SIM (self), ctx->invocation);
+ if (sim_error) {
+ mm_obj_info (self, "Received critical sim error. SIM might be permanently blocked. Reprobing...");
+ mm_base_modem_process_sim_event (self->priv->modem);
+ }
+
handle_send_puk_context_free (ctx);
}
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 5fb72cc9..97c60b68 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -11946,7 +11946,7 @@ mm_broadband_modem_sim_hot_swap_detected (MMBroadbandModem *self)
self->priv->sim_hot_swap_ports_ctx = NULL;
}
- mm_base_modem_process_sim_switch (MM_BASE_MODEM (self));
+ mm_base_modem_process_sim_event (MM_BASE_MODEM (self));
}
/*****************************************************************************/
diff --git a/src/mm-device.c b/src/mm-device.c
index ddd420fe..488ee5e2 100644
--- a/src/mm-device.c
+++ b/src/mm-device.c
@@ -383,6 +383,7 @@ reprobe (MMDevice *self)
{
GError *error = NULL;
+ mm_obj_dbg (self, "Reprobing modem...");
if (!mm_device_create_modem (self, &error)) {
mm_obj_warn (self, "could not recreate modem: %s", error->message);
g_error_free (error);
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index 0ddc0a29..5bb9dd2c 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -1076,7 +1076,7 @@ set_primary_sim_slot_ready (MMIfaceModem *self,
/* Notify about the SIM swap, which will disable and reprobe the device.
* There is no need to update the PrimarySimSlot property, as this value will be
* reloaded automatically during the reprobe. */
- mm_base_modem_process_sim_switch (MM_BASE_MODEM (self));
+ mm_base_modem_process_sim_event (MM_BASE_MODEM (self));
}
mm_gdbus_modem_complete_set_primary_sim_slot (ctx->skeleton, ctx->invocation);
@@ -3314,6 +3314,8 @@ set_lock_status (MMIfaceModem *self,
old_lock = mm_gdbus_modem_get_unlock_required (skeleton);
mm_gdbus_modem_set_unlock_required (skeleton, lock);
+ if (lock == MM_MODEM_LOCK_UNKNOWN)
+ mm_gdbus_modem_set_unlock_retries (skeleton, 0);
/* We don't care about SIM-PIN2/SIM-PUK2 since the device is
* operational without it. */
@@ -3639,6 +3641,7 @@ update_lock_info_context_step (GTask *task)
case UPDATE_LOCK_INFO_CONTEXT_STEP_LAST:
if (ctx->saved_error) {
+ set_lock_status (self, ctx->skeleton, MM_MODEM_LOCK_UNKNOWN);
/* Return saved error */
g_task_return_error (task, ctx->saved_error);
ctx->saved_error = NULL;