ofono: Create the cellular network only when attached to the PS network
authorPhilippe Nunes <philippe.nunes@linux.intel.com>
Fri, 30 Sep 2011 14:08:05 +0000 (16:08 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 5 Oct 2011 09:43:34 +0000 (11:43 +0200)
3G auto-connection may fail as the cellular network service may not be
ready to connect.
With this patch, the cellular network service should be exposed only after
PS network attachment is done.

plugins/ofono.c

index 6652077..95bb612 100644 (file)
@@ -1247,10 +1247,15 @@ static void modem_gprs_changed(struct modem_data *modem,
        if (g_str_equal(key, "Attached") == TRUE) {
                DBG("Attached %d", value);
 
+               if (modem->attached == value)
+                       return;
+
                modem->attached = value;
 
-               if (value)
+               if (value == TRUE) {
                        modem_clear_network_errors(modem);
+                       check_networks(modem);
+               }
        } else if (g_str_equal(key, "Powered") == TRUE) {
                DBG("Powered %d", value);
 
@@ -1295,7 +1300,6 @@ done:
 
        dbus_pending_call_unref(call);
 
-       check_networks(modem);
 }
 
 static void check_gprs(struct modem_data *modem)
@@ -1769,6 +1773,10 @@ static gboolean context_added(DBusConnection *connection,
        if (modem == NULL || modem->device == NULL)
                return TRUE;
 
+       /* Create the related network only when we are attached */
+       if (modem->attached == FALSE)
+               return TRUE;
+
        if (dbus_message_iter_init(message, &iter) == FALSE)
                return TRUE;