base-sim: Reprobe modem if puk lock is discovered after sending pin1
Enabling/Disabling/Changing/Sending the PIN1 lock is usually limited to 3 retries. If these attempts are exhausted, the modem is puk_locked. We reprobe the modem to get rid of any unwanted interfaces and move to a locked state.
This commit is contained in:

committed by
Aleksander Morgado

parent
38f6704fa1
commit
1f0c04644d
@@ -87,6 +87,21 @@ mm_base_sim_export (MMBaseSim *self)
|
|||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Reprobe when a puk lock is discovered after pin1_retries are exhausted */
|
||||||
|
|
||||||
|
static void
|
||||||
|
reprobe_if_puk_discovered (MMBaseSim *self,
|
||||||
|
GError *error)
|
||||||
|
{
|
||||||
|
if (g_error_matches (error,
|
||||||
|
MM_MOBILE_EQUIPMENT_ERROR,
|
||||||
|
MM_MOBILE_EQUIPMENT_ERROR_SIM_PUK)) {
|
||||||
|
mm_obj_dbg (self, "Discovered PUK lock, discarding old modem...");
|
||||||
|
mm_base_modem_process_sim_event (self->priv->modem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* CHANGE PIN (Generic implementation) */
|
/* CHANGE PIN (Generic implementation) */
|
||||||
|
|
||||||
@@ -171,8 +186,9 @@ after_change_update_lock_info_ready (MMIfaceModem *modem,
|
|||||||
mm_iface_modem_update_lock_info_finish (modem, res, NULL);
|
mm_iface_modem_update_lock_info_finish (modem, res, NULL);
|
||||||
|
|
||||||
if (ctx->save_error) {
|
if (ctx->save_error) {
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, ctx->save_error);
|
g_dbus_method_invocation_return_gerror (ctx->invocation, ctx->save_error);
|
||||||
ctx->save_error = NULL;
|
reprobe_if_puk_discovered (ctx->self, ctx->save_error);
|
||||||
|
g_clear_error (&ctx->save_error);
|
||||||
} else {
|
} else {
|
||||||
mm_gdbus_sim_complete_change_pin (MM_GDBUS_SIM (ctx->self), ctx->invocation);
|
mm_gdbus_sim_complete_change_pin (MM_GDBUS_SIM (ctx->self), ctx->invocation);
|
||||||
}
|
}
|
||||||
@@ -349,8 +365,9 @@ after_enable_update_lock_info_ready (MMIfaceModem *modem,
|
|||||||
mm_iface_modem_update_lock_info_finish (modem, res, NULL);
|
mm_iface_modem_update_lock_info_finish (modem, res, NULL);
|
||||||
|
|
||||||
if (ctx->save_error) {
|
if (ctx->save_error) {
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, ctx->save_error);
|
g_dbus_method_invocation_return_gerror (ctx->invocation, ctx->save_error);
|
||||||
ctx->save_error = NULL;
|
reprobe_if_puk_discovered (ctx->self, ctx->save_error);
|
||||||
|
g_clear_error (&ctx->save_error);
|
||||||
} else {
|
} else {
|
||||||
/* Signal about the new lock state */
|
/* Signal about the new lock state */
|
||||||
g_signal_emit (ctx->self, signals[SIGNAL_PIN_LOCK_ENABLED], 0, ctx->enabled);
|
g_signal_emit (ctx->self, signals[SIGNAL_PIN_LOCK_ENABLED], 0, ctx->enabled);
|
||||||
@@ -786,9 +803,11 @@ handle_send_pin_ready (MMBaseSim *self,
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_base_sim_send_pin_finish (self, res, &error))
|
if (!mm_base_sim_send_pin_finish (self, res, &error)) {
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
g_dbus_method_invocation_return_gerror (ctx->invocation, error);
|
||||||
else
|
reprobe_if_puk_discovered (self, error);
|
||||||
|
g_clear_error (&error);
|
||||||
|
} else
|
||||||
mm_gdbus_sim_complete_send_pin (MM_GDBUS_SIM (self), ctx->invocation);
|
mm_gdbus_sim_complete_send_pin (MM_GDBUS_SIM (self), ctx->invocation);
|
||||||
|
|
||||||
handle_send_pin_context_free (ctx);
|
handle_send_pin_context_free (ctx);
|
||||||
|
Reference in New Issue
Block a user