From a965f1d459b462930885f8bffa6a533a7ab990d1 Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Tue, 14 Mar 2017 19:24:39 +0900 Subject: [PATCH] Check support before getting some value - Some features aren't supported but these vconf value is existed - Therefore, we check support by using system-info Change-Id: I8a77ed61472842d4861c99cb527973dc8365bc43 Signed-off-by: Kichan Kwon --- CMakeLists.txt | 2 +- packaging/capi-system-runtime-info.spec | 1 + src/runtime_info_connectivity.c | 26 ++++++++++++++++++++++++++ src/runtime_info_location.c | 10 ++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d596761..cacd1a6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(requires "dlog vconf capi-base-common edbus") +SET(requires "dlog vconf capi-base-common edbus capi-system-info") SET(pc_requires "capi-base-common") INCLUDE(FindPkgConfig) diff --git a/packaging/capi-system-runtime-info.spec b/packaging/capi-system-runtime-info.spec index 6d8c32d..8674643 100644 --- a/packaging/capi-system-runtime-info.spec +++ b/packaging/capi-system-runtime-info.spec @@ -12,6 +12,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(edbus) +BuildRequires: pkgconfig(capi-system-info) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig diff --git a/src/runtime_info_connectivity.c b/src/runtime_info_connectivity.c index a7a101d..1324758 100644 --- a/src/runtime_info_connectivity.c +++ b/src/runtime_info_connectivity.c @@ -24,6 +24,8 @@ #include #include +#include + #ifdef LOG_TAG #undef LOG_TAG #endif @@ -80,6 +82,14 @@ 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; ret = runtime_info_vconf_get_value_int(VCONF_WIFI_HOTSPOT_ENABLED, &vconf_value); if (ret == RUNTIME_INFO_ERROR_NONE) @@ -102,6 +112,14 @@ 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; ret = runtime_info_vconf_get_value_int(VCONF_BT_HOTSPOT_ENABLED, &vconf_value); if (ret == RUNTIME_INFO_ERROR_NONE) @@ -124,6 +142,14 @@ 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; 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 e276bd8..608ccdc 100644 --- a/src/runtime_info_location.c +++ b/src/runtime_info_location.c @@ -24,6 +24,8 @@ #include #include +#include + #ifdef LOG_TAG #undef LOG_TAG #endif @@ -59,6 +61,14 @@ int runtime_info_location_network_get_value(runtime_info_value_h value) { int vconf_value; int ret; + bool supported; + + 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; ret = runtime_info_vconf_get_value_int(VCONF_LOCATION_NETWORK_ENABLED, &vconf_value); if (ret == RUNTIME_INFO_ERROR_NONE) -- 2.7.4