As the P2P technology does not have any devices or rfkill switches associated
with it, unconditionally enable or disable the technology when it is created.
When creating the P2P technology, also take the WiFi powered state into
account.
---
 src/technology.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/technology.c b/src/technology.c
index d80d9e6..cd4bc6f 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -84,6 +84,9 @@ struct connman_technology {
 
 static GSList *driver_list = NULL;
 
+static int technology_enabled(struct connman_technology *technology);
+static int technology_disabled(struct connman_technology *technology);
+
 static gint compare_priority(gconstpointer a, gconstpointer b)
 {
        const struct connman_technology_driver *driver1 = a;
@@ -618,8 +621,13 @@ static int technology_affect_devices(struct 
connman_technology *technology,
        GSList *list;
        int err = -ENXIO;
 
-       if (technology->type == CONNMAN_SERVICE_TYPE_P2P)
+       if (technology->type == CONNMAN_SERVICE_TYPE_P2P) {
+               if (enable_device)
+                       __connman_technology_enabled(technology->type);
+               else
+                       __connman_technology_disabled(technology->type);
                return 0;
+       }
 
        for (list = technology->device_list; list; list = list->next) {
                struct connman_device *device = list->data;
@@ -1186,13 +1194,6 @@ static struct connman_technology *technology_get(enum 
connman_service_type type)
        technology->type = type;
        technology->path = g_strdup_printf("%s/technology/%s",
                                                        CONNMAN_PATH, str);
-       if (type == CONNMAN_SERVICE_TYPE_P2P) {
-               struct connman_technology *wifi;
-
-               wifi = technology_find(CONNMAN_SERVICE_TYPE_WIFI);
-               if (wifi)
-                       technology->enabled = wifi->enabled;
-       }
 
        technology_load(technology);
        technology_list = g_slist_prepend(technology_list, technology);
@@ -1211,7 +1212,20 @@ static struct connman_technology *technology_get(enum 
connman_service_type type)
                return NULL;
        }
 
-       DBG("technology %p", technology);
+       if (type == CONNMAN_SERVICE_TYPE_P2P) {
+               struct connman_technology *wifi;
+               bool enable;
+
+               enable = technology->enable_persistent;
+
+               wifi = technology_find(CONNMAN_SERVICE_TYPE_WIFI);
+               if (enable && wifi)
+                       enable = wifi->enabled;
+
+               technology_affect_devices(technology, enable);
+       }
+
+       DBG("technology %p %s", technology, get_name(technology->type));
 
        return technology;
 }
-- 
2.1.1

_______________________________________________
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Reply via email to