Fix: Don't remove wrong atoms
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>
Fri, 7 May 2010 00:26:48 +0000 (02:26 +0200)
committerDenis Kenzior <denkenz@gmail.com>
Mon, 10 May 2010 20:26:09 +0000 (15:26 -0500)
When the state goes from INSERTED to NOT PRESENT and we have not
advanced past the SIM PIN entry, we remove the pre_sim atoms.

Similarly, if we advanced past the SIM PIN stage and subsequently
removed the SIM, the pre_sim atom list should not be tampered with.

src/modem.c

index 8319702..0d0cb2a 100644 (file)
@@ -1132,13 +1132,16 @@ static void modem_sim_ready(void *user, enum ofono_sim_state new_state)
 
        switch (new_state) {
        case OFONO_SIM_STATE_NOT_PRESENT:
-               remove_all_atoms(&modem->atoms);
+               if (modem->pre_sim_atoms != NULL)
+                       remove_all_atoms(&modem->atoms);
                break;
        case OFONO_SIM_STATE_INSERTED:
                break;
        case OFONO_SIM_STATE_READY:
-               modem->pre_sim_atoms = modem->atoms;
-               modem->atoms = NULL;
+               if (modem->pre_sim_atoms == NULL) {
+                       modem->pre_sim_atoms = modem->atoms;
+                       modem->atoms = NULL;
+               }
 
                if (modem->driver->post_sim)
                        modem->driver->post_sim(modem);