From: Pasi Sjöholm <[email protected]>

Bringing the device down when the IMSI is really changed will force the
service have correct identifier and not to use the old one (eg. when SIM-
card is changed).
---
 plugins/ofono.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index 7af551b..0d296d7 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -1908,6 +1908,7 @@ static gboolean sim_changed(DBusConnection *conn, 
DBusMessage *message,
        struct modem_data *modem;
        DBusMessageIter iter, value;
        const char *key;
+       char *new_imsi;
 
        modem = g_hash_table_lookup(modem_hash, path);
        if (!modem)
@@ -1925,7 +1926,14 @@ static gboolean sim_changed(DBusConnection *conn, 
DBusMessage *message,
        dbus_message_iter_recurse(&iter, &value);
 
        if (g_str_equal(key, "SubscriberIdentity")) {
-               sim_update_imsi(modem, &value);
+               dbus_message_iter_get_basic(&value, &new_imsi);
+
+               if (g_strcmp0(modem->imsi,new_imsi) != 0) {
+                       sim_update_imsi(modem, &value);
+
+                       if (modem->device)
+                               destroy_device(modem);
+               }
 
                if (!ready_to_create_device(modem))
                        return TRUE;
-- 
1.9.1

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to