From e8553f53376a33504dd18c4d7bb6d6f309973e0a Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 18 Feb 2011 11:24:08 -0600 Subject: [PATCH] sim: Check for SIM lockout condition When a user tries to lock/unlock/change a PIN and enters it wrongly several times, it is possible to lock themselves out. In this case we should drop to a pre-sim state, wait for the user to enter the PUK and re-init the sim. --- src/sim.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/sim.c b/src/sim.c index 58b4fee6..c39269df 100644 --- a/src/sim.c +++ b/src/sim.c @@ -624,7 +624,7 @@ static void sim_unlock_cb(const struct ofono_error *error, void *data) DBusMessage *reply = __ofono_error_failed(sim->pending); __ofono_dbus_pending_reply(&sim->pending, reply); - sim_pin_retries_check(sim); + sim_pin_check(sim); return; } @@ -640,7 +640,7 @@ static void sim_lock_cb(const struct ofono_error *error, void *data) DBusMessage *reply = __ofono_error_failed(sim->pending); __ofono_dbus_pending_reply(&sim->pending, reply); - sim_pin_retries_check(sim); + sim_pin_check(sim); return; } @@ -711,7 +711,7 @@ static void sim_change_pin_cb(const struct ofono_error *error, void *data) __ofono_dbus_pending_reply(&sim->pending, __ofono_error_failed(sim->pending)); - sim_pin_retries_check(sim); + sim_pin_check(sim); return; } @@ -2231,6 +2231,15 @@ static void sim_pin_query_cb(const struct ofono_error *error, &pin_name); } + if (pin_type != OFONO_SIM_PASSWORD_NONE && + sim->state == OFONO_SIM_STATE_READY) { + /* Force the sim state out of READY */ + sim_free_main_state(sim); + + sim->state = OFONO_SIM_STATE_INSERTED; + __ofono_modem_sim_reset(__ofono_atom_get_modem(sim->atom)); + } + sim_pin_retries_check(sim); checkdone: