Support Wi-Fi Direct Tethering feature for Tizen 4.0 27/129427/3
authorMilind Ramesh Murhekar <m.murhekar@samsung.com>
Tue, 16 May 2017 10:17:48 +0000 (15:47 +0530)
committerMilind Ramesh Murhekar <m.murhekar@samsung.com>
Thu, 1 Jun 2017 04:28:46 +0000 (09:58 +0530)
Decription: This patch blocks or do not allow
Wi-Fi Direct Application to control wfd-manager
if Wi-Fi Direct Tethering is in progress.

Change-Id: I8854f4a3df5321f5da6f099592edf638a28a5ee4
Signed-off-by: Milind Ramesh Murhekar <m.murhekar@samsung.com>
CMakeLists.txt
include/wifi-direct-util.h
packaging/wifi-direct-manager.spec
src/wifi-direct-iface.c
src/wifi-direct-util.c

index 5cc0a3d..5193b1a 100644 (file)
@@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(wfd-manager C)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog libnl-2.0 capi-appfw-application vconf aul libsystemd-login libtzplatform-config ${MDM_REQUIRED_PKGS})
+pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog libnl-2.0 capi-appfw-application vconf aul libsystemd-login capi-system-info libtzplatform-config ${MDM_REQUIRED_PKGS})
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
index d1286bc..0d6ea78 100644 (file)
@@ -27,7 +27,7 @@
 
 #ifndef __WIFI_DIRECT_UTIL_H__
 #define __WIFI_DIRECT_UTIL_H__
-
+#define TETHERING_WIFI_DIRECT_FEATURE "http://tizen.org/feature/network.tethering.wifi.direct"
 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
 #define IP2STR(a) (a)[0], (a)[1], (a)[2], (a)[3]
@@ -58,6 +58,7 @@ void wfd_util_unset_dev_name_notification();
 int wfd_util_set_country();
 
 int wfd_util_check_wifi_state();
+int wfd_util_check_p2p_hotspot_state(void);
 int wfd_util_check_mobile_ap_state();
 int wfd_util_wifi_direct_activatable();
 #if 0
index 79f8cac..ebe1f76 100644 (file)
@@ -8,7 +8,7 @@
 
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.222
+Version:       1.2.223
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
@@ -24,6 +24,7 @@ BuildRequires:        pkgconfig(vconf)
 BuildRequires:  pkgconfig(libnl-2.0)
 BuildRequires: pkgconfig(dbus-1)
 BuildRequires: pkgconfig(aul)
+BuildRequires:  pkgconfig(capi-system-info)
 
 BuildRequires: pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(libsystemd-login)
index d0d173d..1ce91bb 100644 (file)
@@ -506,6 +506,12 @@ static void __wfd_manager_manage_iface_handler(const gchar *method_name,
 #endif/* TIZEN_FEATURE_WIFI_DIRECT_ON_DEMAND */
        } else if (!g_strcmp0(method_name, "Deactivate")) {
 
+               ret = wfd_util_check_p2p_hotspot_state();
+               if (ret > 0) {
+                       ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+                       goto failed;
+               }
+
                if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
                        WDS_LOGE("Already deactivated");
                        ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
@@ -1225,6 +1231,12 @@ static void __wfd_manager_group_iface_handler(const gchar *method_name,
                        goto failed;
                }
 
+               ret = wfd_util_check_p2p_hotspot_state();
+               if (ret > 0) {
+                       ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+                       goto failed;
+               }
+
                if (group->pending == FALSE) {
                        ret = wfd_oem_destroy_group(manager->oem_ops, group->ifname);
                        if (ret < 0) {
index 5a39420..49483b2 100644 (file)
@@ -44,6 +44,7 @@
 
 #include <vconf.h>
 #include <tzplatform_config.h>
+#include <system_info.h>
 #if defined(TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT)
 #include <systemd/sd-login.h>
 #include <aul.h>
@@ -479,6 +480,46 @@ int wfd_util_check_mobile_ap_state()
        return 0;
 }
 
+static void __check_feature_supported(const char *key,
+                bool *feature_supported)
+{
+       if (system_info_get_platform_bool(key, feature_supported) < 0) {
+               WDS_LOGE("system-info failed to get feature supported flag");
+               return;
+       }
+}
+
+int wfd_util_check_p2p_hotspot_state(void)
+{
+       __WDS_LOG_FUNC_ENTER__;
+       int hotspot_state = 0;
+       int res = 0;
+       bool supported = false;
+
+       __check_feature_supported(TETHERING_WIFI_DIRECT_FEATURE, &supported);
+       if (!supported) {
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       res = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
+       if (res < 0) {
+               WDS_LOGE("Failed to get vconf value[%s]", VCONFKEY_MOBILE_HOTSPOT_MODE);
+               __WDS_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       if (hotspot_state & VCONFKEY_MOBILE_HOTSPOT_MODE_P2P) {
+               WDS_LOGD("P2P Hotspot is on");
+               __WDS_LOG_FUNC_EXIT__;
+               return 1;
+       }
+
+       WDS_LOGD("P2P Hotspot is off");
+       __WDS_LOG_FUNC_EXIT__;
+       return 0;
+}
+
 int wfd_util_wifi_direct_activatable()
 {
        __WDS_LOG_FUNC_ENTER__;