From: Caiwen Zhang <[email protected]>

When sim pin is blocked after input wrong pin code three times,
modem will change to pre-sim status, at this time, STK function
should be available. stk atoms shouldn't be removed.
---
 src/modem.c |    7 ++++++-
 src/stk.c   |    4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/modem.c b/src/modem.c
index 01b0e35..7124d53 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -196,7 +196,12 @@ struct ofono_atom *__ofono_modem_add_atom(struct 
ofono_modem *modem,
        atom = g_new0(struct ofono_atom, 1);
 
        atom->type = type;
-       atom->modem_state = modem->modem_state;
+       /* to avoid STK is removed when modem change to
+               MODEM_STATE_PRE_SIM status */
+       if (type == OFONO_ATOM_TYPE_STK)
+               atom->modem_state = MODEM_STATE_PRE_SIM;
+       else
+               atom->modem_state = modem->modem_state;
        atom->destruct = destruct;
        atom->data = data;
        atom->modem = modem;
diff --git a/src/stk.c b/src/stk.c
index 01c95b5..a00a425 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -3196,6 +3196,10 @@ struct ofono_stk *ofono_stk_create(struct ofono_modem 
*modem,
        if (driver == NULL)
                return NULL;
 
+       /* STK may already exist, in the case that restore from pin blocked */
+       if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_STK) != NULL)
+               return NULL;
+
        stk = g_try_new0(struct ofono_stk, 1);
 
        if (stk == NULL)
-- 
1.7.9.5

_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to