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 2c5f386438090a1075b813176d3c61ecde899e9c..0988a5d7fe19a6c8bb63968d1ba9ed45ab780ac2 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 0d6ea7802d6bef7a8660adf6665e8c41721628c0..4014f8b0a977970fe180163402cd78f4f7f75f4b 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 c2f279ecc777071faba59b12f1ea1cbcee71850b..9cae31e4fee654e29efbf39e45d6e68b0a8aef89 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 e22b014b59444ed70fc3a2dc84d5f0c6df107ad4..2783a7d5d4fe5a918cfd941b3c581cb814ced423 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 49483b2b53c5cf641aee98232bf78b3c344aa48b..7a278f005891e24aedcaff83be5a73a4bcded4f2 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) {