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:

committed by
Aleksander Morgado

parent
92c86e2b1b
commit
38f6704fa1
@@ -1285,7 +1285,7 @@ after_sim_switch_disable_ready (MMBaseModem *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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_set_reprobe (self, TRUE);
|
||||||
mm_base_modem_disable (self, (GAsyncReadyCallback) after_sim_switch_disable_ready, NULL);
|
mm_base_modem_disable (self, (GAsyncReadyCallback) after_sim_switch_disable_ready, NULL);
|
||||||
|
@@ -199,6 +199,6 @@ gboolean mm_base_modem_disable_finish (MMBaseModem *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
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 */
|
#endif /* MM_BASE_MODEM_H */
|
||||||
|
@@ -584,17 +584,17 @@ update_lock_info_ready (MMIfaceModem *modem,
|
|||||||
const GError *saved_error;
|
const GError *saved_error;
|
||||||
|
|
||||||
/* Device is locked. Now:
|
/* 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 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.
|
* - Otherwise, build our own error from the lock code.
|
||||||
*/
|
*/
|
||||||
saved_error = g_task_get_task_data (task);
|
if (!error) {
|
||||||
if (saved_error) {
|
saved_error = g_task_get_task_data (task);
|
||||||
g_clear_error (&error);
|
if (saved_error)
|
||||||
error = g_error_copy (saved_error);
|
error = g_error_copy (saved_error);
|
||||||
} else if (!error)
|
else
|
||||||
error = error_for_unlock_check (lock);
|
error = error_for_unlock_check (lock);
|
||||||
|
}
|
||||||
g_task_return_error (task, error);
|
g_task_return_error (task, error);
|
||||||
} else
|
} else
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
@@ -869,12 +869,27 @@ handle_send_puk_ready (MMBaseSim *self,
|
|||||||
HandleSendPukContext *ctx)
|
HandleSendPukContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
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);
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
else
|
} else
|
||||||
mm_gdbus_sim_complete_send_puk (MM_GDBUS_SIM (self), ctx->invocation);
|
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);
|
handle_send_puk_context_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11946,7 +11946,7 @@ mm_broadband_modem_sim_hot_swap_detected (MMBroadbandModem *self)
|
|||||||
self->priv->sim_hot_swap_ports_ctx = NULL;
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@@ -383,6 +383,7 @@ reprobe (MMDevice *self)
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
mm_obj_dbg (self, "Reprobing modem...");
|
||||||
if (!mm_device_create_modem (self, &error)) {
|
if (!mm_device_create_modem (self, &error)) {
|
||||||
mm_obj_warn (self, "could not recreate modem: %s", error->message);
|
mm_obj_warn (self, "could not recreate modem: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
@@ -1076,7 +1076,7 @@ set_primary_sim_slot_ready (MMIfaceModem *self,
|
|||||||
/* Notify about the SIM swap, which will disable and reprobe the device.
|
/* 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
|
* There is no need to update the PrimarySimSlot property, as this value will be
|
||||||
* reloaded automatically during the reprobe. */
|
* 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);
|
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);
|
old_lock = mm_gdbus_modem_get_unlock_required (skeleton);
|
||||||
mm_gdbus_modem_set_unlock_required (skeleton, lock);
|
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
|
/* We don't care about SIM-PIN2/SIM-PUK2 since the device is
|
||||||
* operational without it. */
|
* operational without it. */
|
||||||
@@ -3639,6 +3641,7 @@ update_lock_info_context_step (GTask *task)
|
|||||||
|
|
||||||
case UPDATE_LOCK_INFO_CONTEXT_STEP_LAST:
|
case UPDATE_LOCK_INFO_CONTEXT_STEP_LAST:
|
||||||
if (ctx->saved_error) {
|
if (ctx->saved_error) {
|
||||||
|
set_lock_status (self, ctx->skeleton, MM_MODEM_LOCK_UNKNOWN);
|
||||||
/* Return saved error */
|
/* Return saved error */
|
||||||
g_task_return_error (task, ctx->saved_error);
|
g_task_return_error (task, ctx->saved_error);
|
||||||
ctx->saved_error = NULL;
|
ctx->saved_error = NULL;
|
||||||
|
Reference in New Issue
Block a user