Add the Tizen feature information management 91/137691/2
authorJiung Yu <jiung.yu@samsung.com>
Fri, 7 Jul 2017 05:54:17 +0000 (14:54 +0900)
committertaesub kim <taesub.kim@samsung.com>
Tue, 18 Jul 2017 01:31:25 +0000 (01:31 +0000)
Description: We have made each features as build MACRO.
But that method raises maintaining issues because the Tizen
supports multiple profiles and targets that have different
feature configuration. Currently, we should rebuild wfd-manager
to support them. It seems not efficient.
So we'll make the wfd-manager manage some Tizen features at run time.

Change-Id: Ic1bf12a939d132065720c18d4b6d68c47a7cd304
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
include/wifi-direct-manager.h
include/wifi-direct-util.h
packaging/wifi-direct-manager.spec
src/wifi-direct-manager.c
src/wifi-direct-util.c

index 2c5f386..0988a5d 100644 (file)
@@ -214,6 +214,12 @@ typedef struct {
 
        int session_timer;
        gboolean auto_group_remove_enable;
+       gboolean is_on_demand_supported;
+       gboolean is_service_discovery_supported;
+       gboolean is_wifi_display_supported;
+       gboolean is_tethering_wifi_supported;
+       gboolean is_tethering_wifi_direct_supported;
+       gboolean is_asp_supported;
 } wfd_manager_s;
 
 wfd_manager_s *wfd_get_manager();
index 0d6ea78..4014f8b 100644 (file)
@@ -27,7 +27,6 @@
 
 #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]
@@ -57,8 +56,9 @@ void wfd_util_set_dev_name_notification();
 void wfd_util_unset_dev_name_notification();
 int wfd_util_set_country();
 
+void wfd_util_check_features();
 int wfd_util_check_wifi_state();
-int wfd_util_check_p2p_hotspot_state(void);
+int wfd_util_check_p2p_hotspot_state();
 int wfd_util_check_mobile_ap_state();
 int wfd_util_wifi_direct_activatable();
 #if 0
index c2f279e..9cae31e 100644 (file)
@@ -8,7 +8,7 @@
 
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.227
+Version:       1.2.228
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
index e22b014..2783a7d 100644 (file)
@@ -1735,6 +1735,7 @@ static wfd_manager_s *wfd_manager_init()
        manager->max_station = 8;
        manager->session_timer = 120;
        manager->auto_group_remove_enable = TRUE;
+       wfd_util_check_features();
        res = _wfd_local_init_device(manager);
        if (res < 0) {
                WDS_LOGE("Failed to initialize local device");
index 49483b2..7a278f0 100644 (file)
 #include <netlink/socket.h>
 #include <netlink/route/neighbour.h>
 
+#define ASP_FEATURE "http://tizen.org/feature/network.asp"
+#define WIFI_DIRECT_DISPLAY_FEATURE "http://tizen.org/feature/network.wifi.direct.display"
+#define WIFI_DIRECT_SERVICE_DISCOVERY_FEATURE "http://tizen.org/feature/network.wifi.direct.service_discovery"
+#define TETHERING_WIFI_FEATURE "http://tizen.org/feature/network.tethering.wifi"
+#define TETHERING_WIFI_DIRECT_FEATURE "http://tizen.org/feature/network.tethering.wifi.direct"
+
 #define TIZEN_P2P_GO_IPADDR "192.168.49.1"
 #define MAX_SIZE_ERROR_BUFFER 256
 
@@ -485,22 +491,108 @@ static void __check_feature_supported(const char *key,
 {
        if (system_info_get_platform_bool(key, feature_supported) < 0) {
                WDS_LOGE("system-info failed to get feature supported flag");
-               return;
+               *feature_supported = false;
        }
+       return;
+}
+
+static bool __is_wifi_direct_display_feature_supported()
+{
+       bool supported;
+
+       __check_feature_supported(WIFI_DIRECT_DISPLAY_FEATURE, &supported);
+
+       return supported;
+}
+
+static bool __is_wifi_direct_service_discovery_feature_supported()
+{
+       bool supported;
+
+       __check_feature_supported(WIFI_DIRECT_SERVICE_DISCOVERY_FEATURE, &supported);
+
+       return supported;
+}
+
+static bool __is_asp_feature_supported()
+{
+       bool supported;
+
+       __check_feature_supported(ASP_FEATURE, &supported);
+
+       return supported;
+}
+
+static bool __is_tethering_wifi_feature_supported()
+{
+       bool supported;
+
+       __check_feature_supported(TETHERING_WIFI_FEATURE, &supported);
+
+       return supported;
+}
+
+static bool __is_tethering_wifi_direct_feature_supported()
+{
+       bool supported;
+
+       __check_feature_supported(TETHERING_WIFI_DIRECT_FEATURE, &supported);
+
+       return supported;
 }
 
-int wfd_util_check_p2p_hotspot_state(void)
+void wfd_util_check_features()
+{
+       __WDS_LOG_FUNC_ENTER__;
+       wfd_manager_s * manager = NULL;
+
+       manager = wfd_get_manager();
+       if (!manager)
+               return;
+
+       manager->is_on_demand_supported = TRUE;
+
+       if (__is_wifi_direct_display_feature_supported())
+               manager->is_wifi_display_supported = TRUE;
+       else
+               manager->is_wifi_display_supported = FALSE;
+
+       if (__is_wifi_direct_service_discovery_feature_supported())
+               manager->is_service_discovery_supported = TRUE;
+       else
+               manager->is_service_discovery_supported = FALSE;
+
+       if (__is_asp_feature_supported())
+               manager->is_asp_supported = TRUE;
+       else
+               manager->is_asp_supported = FALSE;
+
+       if (__is_tethering_wifi_feature_supported())
+               manager->is_tethering_wifi_supported = TRUE;
+       else
+               manager->is_tethering_wifi_supported = FALSE;
+
+       if (__is_tethering_wifi_direct_feature_supported())
+               manager->is_tethering_wifi_direct_supported = TRUE;
+       else
+               manager->is_tethering_wifi_direct_supported = FALSE;
+
+       return;
+
+}
+
+int wfd_util_check_p2p_hotspot_state()
 {
        __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__;
+       wfd_manager_s * manager = wfd_get_manager();
+       if (!manager)
+               return -1;
+
+       if (!manager->is_tethering_wifi_direct_supported)
                return -1;
-       }
 
        res = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
        if (res < 0) {