summaryrefslogtreecommitdiffstats
path: root/src/modem.c
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2011-02-15 08:58:51 +0100
committerDenis Kenzior <denkenz@gmail.com>2011-02-17 15:09:16 -0600
commit5815d9547c0be1cf1f1421aa44b9d9b394dd1391 (patch)
tree785f340ea5a6911f44871b40f8a9e77479b2258c /src/modem.c
parent72ad6ccd40c7dd35ab5c03272586751dba7ece8d (diff)
downloadofono-5815d9547c0be1cf1f1421aa44b9d9b394dd1391.tar.bz2
modem.c: Handle SIM Resets
The assumption so far was that SIM state would only go from NOT_PRESENT -> INSERTED -> READY -> NOT_PRESENT because there's no method to unauthenticate from SIM without removing. We need to be able to switch to INSERTED when SIM is being reset, reinitialised, etc. because going to NOT_PRESENT and then immediately INSERTED would be logically wrong.
Diffstat (limited to 'src/modem.c')
-rw-r--r--src/modem.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/modem.c b/src/modem.c
index bf8b0c08..3dd44ad1 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -532,7 +532,7 @@ static void common_online_cb(const struct ofono_error *error, void *data)
*
* Additionally, this process can be interrupted by the following
* events:
- * - Sim being removed
+ * - Sim being removed or reset
* - SetProperty(Powered, False) being called
* - SetProperty(Lockdown, True) being called
*
@@ -546,7 +546,7 @@ static void common_online_cb(const struct ofono_error *error, void *data)
/* The powered operation is pending */
break;
case MODEM_STATE_PRE_SIM:
- /* Go back offline if the sim was removed */
+ /* Go back offline if the sim was removed or reset */
modem->driver->set_online(modem, 0, NULL, NULL);
break;
case MODEM_STATE_ONLINE:
@@ -598,9 +598,13 @@ static void sim_state_watch(enum ofono_sim_state new_state, void *user)
switch (new_state) {
case OFONO_SIM_STATE_NOT_PRESENT:
- modem_change_state(modem, MODEM_STATE_PRE_SIM);
- break;
case OFONO_SIM_STATE_INSERTED:
+ if (modem->modem_state != MODEM_STATE_PRE_SIM) {
+ if (modem->modem_state == MODEM_STATE_ONLINE)
+ modem->get_online = TRUE;
+
+ modem_change_state(modem, MODEM_STATE_PRE_SIM);
+ }
break;
case OFONO_SIM_STATE_READY:
modem_change_state(modem, MODEM_STATE_OFFLINE);