P2P is not tight to any devices, thus the need of automatically
triggering the proper enabling/disabling function which will in turn
send the signal about Powered being changed accordingly.
---
 src/technology.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/technology.c b/src/technology.c
index bc8557c..2893761 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -688,6 +688,14 @@ static int technology_enabled(struct connman_technology 
*technology)
 
        technology->enabled = true;
 
+       if (technology->type == CONNMAN_SERVICE_TYPE_WIFI) {
+               struct connman_technology *p2p;
+
+               p2p = technology_find(CONNMAN_SERVICE_TYPE_P2P);
+               if (p2p && !p2p->enabled && p2p->enable_persistent)
+                       technology_enabled(p2p);
+       }
+
        if (technology->tethering_persistent)
                enable_tethering(technology);
 
@@ -704,6 +712,16 @@ static int technology_enable(struct connman_technology 
*technology)
        DBG("technology %p enable", technology);
 
        __sync_synchronize();
+
+       if (technology->type == CONNMAN_SERVICE_TYPE_P2P) {
+               struct connman_technology *wifi;
+
+               wifi = technology_find(CONNMAN_SERVICE_TYPE_WIFI);
+               if (wifi->enabled)
+                       return technology_enabled(technology);
+               return 0;
+       }
+
        if (technology->enabled)
                return -EALREADY;
 
@@ -745,6 +763,20 @@ static int technology_disable(struct connman_technology 
*technology)
        DBG("technology %p disable", technology);
 
        __sync_synchronize();
+
+       if (technology->type == CONNMAN_SERVICE_TYPE_P2P) {
+               technology->enable_persistent = false;
+               return technology_disabled(technology);
+       } else if (technology->type == CONNMAN_SERVICE_TYPE_WIFI) {
+               struct connman_technology *p2p;
+
+               p2p = technology_find(CONNMAN_SERVICE_TYPE_P2P);
+               if (p2p && p2p->enabled) {
+                       p2p->enable_persistent = true;
+                       technology_disabled(p2p);
+               }
+       }
+
        if (!technology->enabled)
                return -EALREADY;
 
-- 
1.8.3.2

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

Reply via email to