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.
This commit is contained in:
Pavan Holla
2020-11-23 17:52:17 +00:00
committed by Aleksander Morgado
parent 92c86e2b1b
commit 38f6704fa1
6 changed files with 33 additions and 14 deletions

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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;
gboolean sim_error = FALSE;
if (!mm_base_sim_send_puk_finish (self, res, &error))
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);
}

View File

@@ -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));
}
/*****************************************************************************/

View File

@@ -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);

View File

@@ -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;