huawei: fix SIM state notification when locked

When SIM is locked, huawei modem does not send any notification about
SIM state change because it does not differentiate 'invalid' from
'locked'.

In order to be able to unlock the sim, this patch forces a notification
of a valid state after a timeout.
This commit is contained in:
Lucas De Marchi 2010-12-21 17:27:10 -02:00 committed by Denis Kenzior
parent 34d3917f84
commit 67486801d0
1 changed files with 28 additions and 0 deletions

View File

@ -221,6 +221,30 @@ static gboolean notify_sim_state(struct ofono_modem *modem,
return FALSE;
}
static void cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
if (!ok)
return;
/* Force notification of SIM ready because it's in a locked state */
notify_sim_state(modem, HUAWEI_SIM_STATE_VALID);
}
static gboolean query_sim_locked(gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct huawei_data *data = ofono_modem_get_data(modem);
data->sim_poll_timeout = 0;
g_at_chat_send(data->pcui, "AT+CPIN?", NULL,
cpin_cb, modem, NULL);
return FALSE;
}
static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@ -259,6 +283,10 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
data->sim_poll_timeout = g_timeout_add_seconds(2,
query_sim_state,
modem);
} else if (sim_state == HUAWEI_SIM_STATE_INVALID_OR_LOCKED) {
data->sim_poll_timeout = g_timeout_add_seconds(2,
query_sim_locked,
modem);
}
}