Modify how to check for some supported features 70/47670/1 accepted/tizen/mobile/20150908.073800 accepted/tizen/tv/20150908.073827 accepted/tizen/wearable/20150908.073816 submit/tizen/20150908.040601
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 3 Sep 2015 07:05:02 +0000 (16:05 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Tue, 8 Sep 2015 01:25:49 +0000 (10:25 +0900)
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
Change-Id: I49a447949b66e536744382881a946af6d007d904

include/connection_profile.h [changed mode: 0644->0755]
include/net_connection_private.h
src/libnetwork.c

old mode 100644 (file)
new mode 100755 (executable)
index ab00c7d..0a389c4 100755 (executable)
@@ -49,12 +49,25 @@ typedef enum
        CONNECTION_CELLULAR_SUBSCRIBER_2 = 0x01,
 } connection_cellular_subscriber_id_e;
 
+typedef enum
+{
+       CONNECTION_SUPPORTED_FEATURE_TELEPHONY,
+       CONNECTION_SUPPORTED_FEATURE_WIFI,
+       CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH,
+       CONNECTION_SUPPORTED_FEATURE_ETHERNET,
+       CONNECTION_SUPPORTED_FEATURE_MAX,
+} connection_supported_feature_e;
+
+#if !defined TIZEN_TV
 #define CHECK_FEATURE_SUPPORTED(...) \
        do { \
                int rv = _connection_check_feature_supported(__VA_ARGS__, NULL); \
                if( rv != CONNECTION_ERROR_NONE ) \
                        return rv; \
        } while(0)
+#else
+#define CHECK_FEATURE_SUPPORTED(...)
+#endif
 
 #define CONNECTION_LOG(log_level, format, args...) \
        do { \
index f167480..cda1205 100755 (executable)
@@ -67,6 +67,8 @@ struct managed_idle_data {
 static __thread struct _profile_list_s profile_iterator = {0, 0, NULL};
 static __thread struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL, false};
 static __thread GSList *managed_idler_list = NULL;
+static __thread bool connection_is_feature_checked[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
+static __thread bool connection_feature_supported[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
 
 bool _connection_is_created(void)
 {
@@ -1517,20 +1519,42 @@ int _connection_libnet_check_profile_privilege()
        return CONNECTION_ERROR_NONE;
 }
 
+bool __libnet_check_feature_supported(const char *key, connection_supported_feature_e feature)
+{
+       if(!connection_is_feature_checked[feature]) {
+               if(system_info_get_platform_bool(key, &connection_feature_supported[feature]) < 0) {
+                       CONNECTION_LOG(CONNECTION_ERROR, "Error - Feature getting from System Info");
+                       set_last_result(CONNECTION_ERROR_OPERATION_FAILED);
+                       return CONNECTION_ERROR_OPERATION_FAILED;
+               }
+               connection_is_feature_checked[feature] = true;
+       }
+       return connection_feature_supported[feature];
+}
+
 int _connection_check_feature_supported(const char *feature_name, ...)
 {
        va_list list;
        const char *key;
-       bool value, feature_supported = false;
+       bool value = false;
+       bool feature_supported = false;
 
        va_start(list, feature_name);
        key = feature_name;
        while(1) {
-               if(system_info_get_platform_bool(key, &value) < 0) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Error - Feature getting from System Info");
-                       set_last_result(CONNECTION_ERROR_OPERATION_FAILED);
-                       return CONNECTION_ERROR_OPERATION_FAILED;
+               if((strcmp(key, TELEPHONY_FEATURE) == 0)){
+                       value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TELEPHONY);
+               }
+               if((strcmp(key, WIFI_FEATURE) == 0)){
+                       value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_WIFI);
                }
+               if((strcmp(key, TETHERING_BLUETOOTH_FEATURE) == 0)){
+                       value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH);
+               }
+               if((strcmp(key, ETHERNET_FEATURE) == 0)){
+                       value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_ETHERNET);
+               }
+
                SECURE_CONNECTION_LOG(CONNECTION_INFO, "%s feature is %s", key, (value?"true":"false"));
                feature_supported |= value;
                key = va_arg(list, const char *);