From: Daniel Wagner <[email protected]>

---
 plugins/ofono.c |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index e229e8a..3be5f44 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -96,6 +96,7 @@ static DBusConnection *connection;
 
 static GHashTable *modem_hash;
 static GHashTable *context_hash;
+static connman_bool_t technology_enabled;
 
 struct network_context {
        char *path;
@@ -1926,9 +1927,6 @@ static gboolean modem_changed(DBusConnection *connection, 
DBusMessage *message,
                dbus_message_iter_get_basic(&value, &modem->powered);
 
                DBG("%s Powered %d", modem->path, modem->powered);
-
-               if (modem->powered == FALSE)
-                       modem_set_powered(modem);
        } else if (g_str_equal(key, "Online") == TRUE) {
                dbus_message_iter_get_basic(&value, &modem->online);
 
@@ -2062,7 +2060,7 @@ static void add_modem(const char *path, DBusMessageIter 
*prop)
        if (modem->ignore == TRUE)
                return;
 
-       if (modem->powered == FALSE)
+       if (technology_enabled == TRUE && modem->powered == FALSE)
                modem_set_powered(modem);
        else if (has_interface(modem->interfaces, OFONO_API_SIM) == TRUE)
                sim_get_properties(modem);
@@ -2070,12 +2068,28 @@ static void add_modem(const char *path, DBusMessageIter 
*prop)
                connection_manager_init(modem);
 }
 
+static void modem_power_up(gpointer key, gpointer value, gpointer user_data)
+{
+       struct modem_data *modem = value;
+
+       DBG("%s", modem->path);
+
+       technology_enabled = TRUE;
+
+       if (modem->ignore ==  TRUE)
+               return;
+
+       modem_set_powered(modem);
+}
+
 static void modem_power_down(gpointer key, gpointer value, gpointer user_data)
 {
        struct modem_data *modem = value;
 
        DBG("%s", modem->path);
 
+       technology_enabled = FALSE;
+
        if (modem->ignore ==  TRUE)
                return;
 
@@ -2376,6 +2390,11 @@ static int tech_enable(struct connman_technology 
*technology)
 {
        DBG("");
 
+       if (modem_hash == NULL)
+               return 0;
+
+       g_hash_table_foreach(modem_hash, modem_power_up, NULL);
+
        return 0;
 }
 
@@ -2383,6 +2402,11 @@ static int tech_disable(struct connman_technology 
*technology)
 {
        DBG("");
 
+       if (modem_hash == NULL)
+               return 0;
+
+       g_hash_table_foreach(modem_hash, modem_power_down, NULL);
+
        return 0;
 }
 
-- 
1.7.8.110.g4cb5d1

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

Reply via email to