diff options
author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2010-12-21 17:27:10 -0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-12-21 13:37:25 -0600 |
commit | 67486801d02bae51c45bcfa1741d193fb3f9e431 (patch) | |
tree | e215e7d5835238f977969781834374d61d7c14d6 /plugins/huawei.c | |
parent | 34d3917f84469da9c1803c78462106d0be39a020 (diff) | |
download | ofono-67486801d02bae51c45bcfa1741d193fb3f9e431.tar.bz2 |
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.
Diffstat (limited to 'plugins/huawei.c')
-rw-r--r-- | plugins/huawei.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/huawei.c b/plugins/huawei.c index 0c8d8c07..f40889e0 100644 --- a/plugins/huawei.c +++ b/plugins/huawei.c @@ -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); } } |