From: Kichan Kwon Date: Mon, 14 May 2018 01:51:45 +0000 (+0900) Subject: Define a macro checking feature support X-Git-Tag: accepted/tizen/unified/20180515.063732~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df0104a7f88f3ed7c5063077aa28fb5cf1cc76a7;p=platform%2Fcore%2Fapi%2Fruntime-info.git Define a macro checking feature support Change-Id: I9dc062ce590dfe654e31d0ecde2e96810c709763 Signed-off-by: Kichan Kwon --- diff --git a/include/runtime_info_private.h b/include/runtime_info_private.h index 17f6c28..c5f86f1 100644 --- a/include/runtime_info_private.h +++ b/include/runtime_info_private.h @@ -18,6 +18,7 @@ #ifndef __TIZEN_SYSTEM_RUNTIME_INFO_PRIVATE_H__ #define __TIZEN_SYSTEM_RUNTIME_INFO_PRIVATE_H__ +#include #include #ifdef __cplusplus @@ -40,6 +41,15 @@ extern "C" #define RUNTIME_INFO_INTERNAL_KEY_WIFI_STATUS 1 +#define RETURN_ERROR_IF_NOT_SUPPORTED(feature) \ +{ \ + bool _supported; \ + if (system_info_get_platform_bool(feature, &_supported) != SYSTEM_INFO_ERROR_NONE) \ + return RUNTIME_INFO_ERROR_IO_ERROR; \ + if (!_supported) \ + return RUNTIME_INFO_ERROR_NOT_SUPPORTED; \ +} + typedef enum { RUNTIME_INFO_DATA_TYPE_STRING, RUNTIME_INFO_DATA_TYPE_INT, diff --git a/src/runtime_info_connectivity.c b/src/runtime_info_connectivity.c index a268629..a9c1f84 100644 --- a/src/runtime_info_connectivity.c +++ b/src/runtime_info_connectivity.c @@ -24,8 +24,6 @@ #include #include -#include - #ifdef LOG_TAG #undef LOG_TAG #endif @@ -123,14 +121,8 @@ int runtime_info_wifi_hotspot_get_value(runtime_info_value_h value) { int vconf_value; int ret; - bool supported; - - ret = system_info_get_platform_bool("http://tizen.org/feature/network.tethering.wifi", &supported); - if (ret != SYSTEM_INFO_ERROR_NONE) - return RUNTIME_INFO_ERROR_IO_ERROR; - if (!supported) - return RUNTIME_INFO_ERROR_NOT_SUPPORTED; + RETURN_ERROR_IF_NOT_SUPPORTED("http://tizen.org/feature/network.tethering.wifi"); ret = runtime_info_vconf_get_value_int(VCONF_WIFI_HOTSPOT_ENABLED, &vconf_value); if (ret == RUNTIME_INFO_ERROR_NONE) @@ -153,14 +145,8 @@ int runtime_info_bt_hotspot_get_value(runtime_info_value_h value) { int vconf_value; int ret; - bool supported; - ret = system_info_get_platform_bool("http://tizen.org/feature/network.tethering.bluetooth", &supported); - if (ret != SYSTEM_INFO_ERROR_NONE) - return RUNTIME_INFO_ERROR_IO_ERROR; - - if (!supported) - return RUNTIME_INFO_ERROR_NOT_SUPPORTED; + RETURN_ERROR_IF_NOT_SUPPORTED("http://tizen.org/feature/network.tethering.bluetooth"); ret = runtime_info_vconf_get_value_int(VCONF_BT_HOTSPOT_ENABLED, &vconf_value); if (ret == RUNTIME_INFO_ERROR_NONE) @@ -183,14 +169,8 @@ int runtime_info_usb_hotspot_get_value(runtime_info_value_h value) { int vconf_value; int ret; - bool supported; - - ret = system_info_get_platform_bool("http://tizen.org/feature/network.tethering.usb", &supported); - if (ret != SYSTEM_INFO_ERROR_NONE) - return RUNTIME_INFO_ERROR_IO_ERROR; - if (!supported) - return RUNTIME_INFO_ERROR_NOT_SUPPORTED; + RETURN_ERROR_IF_NOT_SUPPORTED("http://tizen.org/feature/network.tethering.usb"); ret = runtime_info_vconf_get_value_int(VCONF_USB_HOTSPOT_ENABLED, &vconf_value); if (ret == RUNTIME_INFO_ERROR_NONE) diff --git a/src/runtime_info_location.c b/src/runtime_info_location.c index d1824fc..a74b006 100644 --- a/src/runtime_info_location.c +++ b/src/runtime_info_location.c @@ -24,8 +24,6 @@ #include #include -#include - #ifdef LOG_TAG #undef LOG_TAG #endif @@ -68,16 +66,10 @@ int runtime_info_location_network_get_value(runtime_info_value_h value) { int vconf_value; int ret; - bool supported; LOGW("DEPRECATION WARNING: RUNTIME_INFO_KEY_LOCATION_NETWORK_POSITION_ENABLED is deprecated and will be removed from next release."); - ret = system_info_get_platform_bool("http://tizen.org/feature/location.wps", &supported); - if (ret != SYSTEM_INFO_ERROR_NONE) - return RUNTIME_INFO_ERROR_IO_ERROR; - - if (!supported) - return RUNTIME_INFO_ERROR_NOT_SUPPORTED; + RETURN_ERROR_IF_NOT_SUPPORTED("http://tizen.org/feature/location.wps"); ret = runtime_info_vconf_get_value_int(VCONF_LOCATION_NETWORK_ENABLED, &vconf_value); if (ret == RUNTIME_INFO_ERROR_NONE)