From: MyungJoo Ham Date: Fri, 11 Nov 2016 06:49:32 +0000 (+0900) Subject: Remove Profile Build Dependency (TV) X-Git-Tag: submit/tizen/20170210.072732~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d348bd5523f0caa76754da389b247b8f396540f;p=platform%2Fcore%2Fapi%2Fwifi.git Remove Profile Build Dependency (TV) - This is for Tizen 4.0 - TV or not is determined at runtime, unifying the binary for all. After this commit, there is no more TIZEN_TV: wifi$ grep -r "TIZEN_TV" * wifi$ Change-Id: I95d59350394500508a513a811c2a4a5e849b332d Signed-off-by: MyungJoo Ham --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a93688e..e36c92d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,6 @@ SET(pc_dependents "capi-base-common") IF(TIZEN_DUALSIM_ENABLE) ADD_DEFINITIONS(-DTIZEN_DUALSIM_ENABLE) ENDIF(TIZEN_DUALSIM_ENABLE) -IF(TIZEN_TV) - ADD_DEFINITIONS(-DTIZEN_TV) -ENDIF(TIZEN_TV) INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents} ${APPFW_REQUIRED_PKGS}) diff --git a/packaging/capi-network-wifi.spec b/packaging/capi-network-wifi.spec index f5146db..8336f46 100755 --- a/packaging/capi-network-wifi.spec +++ b/packaging/capi-network-wifi.spec @@ -39,9 +39,6 @@ cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ -DLIB_PATH=%{_lib} \ %if 0%{?model_build_feature_network_dsds} == 1 -DTIZEN_DUALSIM_ENABLE=1 \ -%endif -%if "%{profile}" == "tv" - -DTIZEN_TV=1 \ %endif . diff --git a/src/net_wifi.c b/src/net_wifi.c index 4b8a9a2..99abfed 100755 --- a/src/net_wifi.c +++ b/src/net_wifi.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "net_wifi_private.h" @@ -29,6 +30,7 @@ static __thread wifi_rssi_level_changed_cb rssi_level_changed_cb = NULL; static __thread void *rssi_level_changed_user_data = NULL; +static int tv_profile = -1; // Unknown //LCOV_EXCL_START static gboolean __rssi_level_changed_cb_idle(gpointer data) @@ -202,44 +204,53 @@ EXPORT_API int wifi_get_mac_address(char** mac_address) return WIFI_ERROR_INVALID_PARAMETER; } -#if defined TIZEN_TV - FILE *fp = NULL; - char buf[WIFI_MAC_ADD_LENGTH + 1]; - if (0 == access(WIFI_MAC_ADD_PATH, F_OK)) - fp = fopen(WIFI_MAC_ADD_PATH, "r"); - - if (fp == NULL) { - WIFI_LOG(WIFI_ERROR, "Failed to open file" //LCOV_EXCL_LINE - " %s\n", WIFI_MAC_ADD_PATH); - return WIFI_ERROR_OPERATION_FAILED; - } - - if (fgets(buf, sizeof(buf), fp) == NULL) { - WIFI_LOG(WIFI_ERROR, "Failed to get MAC" - " info from %s\n", WIFI_MAC_ADD_PATH); //LCOV_EXCL_LINE - fclose(fp); //LCOV_EXCL_LINE - return WIFI_ERROR_OPERATION_FAILED; - } - - WIFI_LOG(WIFI_INFO, "%s : %s\n", WIFI_MAC_ADD_PATH, buf); - - *mac_address = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1); - if (*mac_address == NULL) { - WIFI_LOG(WIFI_ERROR, "malloc() failed"); //LCOV_EXCL_LINE - fclose(fp); //LCOV_EXCL_LINE - return WIFI_ERROR_OUT_OF_MEMORY; - } - g_strlcpy(*mac_address, buf, WIFI_MAC_ADD_LENGTH + 1); - fclose(fp); -#else - *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS); - - if (*mac_address == NULL || strlen(*mac_address) == 0) { - WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE - " from %s", VCONFKEY_WIFI_BSSID_ADDRESS); - return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE + if (__builtin_expect(tv_profile == -1, 0)) { + char *profileName; + system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); + if (*profileName == 't' || *profileName == 'T') + tv_profile = 1; + else + tv_profile = 0; + free(profileName); + } + if (tv_profile == 1) { + FILE *fp = NULL; + char buf[WIFI_MAC_ADD_LENGTH + 1]; + if (0 == access(WIFI_MAC_ADD_PATH, F_OK)) + fp = fopen(WIFI_MAC_ADD_PATH, "r"); + + if (fp == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to open file" //LCOV_EXCL_LINE + " %s\n", WIFI_MAC_ADD_PATH); + return WIFI_ERROR_OPERATION_FAILED; + } + + if (fgets(buf, sizeof(buf), fp) == NULL) { + WIFI_LOG(WIFI_ERROR, "Failed to get MAC" + " info from %s\n", WIFI_MAC_ADD_PATH); //LCOV_EXCL_LINE + fclose(fp); //LCOV_EXCL_LINE + return WIFI_ERROR_OPERATION_FAILED; + } + + WIFI_LOG(WIFI_INFO, "%s : %s\n", WIFI_MAC_ADD_PATH, buf); + + *mac_address = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1); + if (*mac_address == NULL) { + WIFI_LOG(WIFI_ERROR, "malloc() failed"); //LCOV_EXCL_LINE + fclose(fp); //LCOV_EXCL_LINE + return WIFI_ERROR_OUT_OF_MEMORY; + } + g_strlcpy(*mac_address, buf, WIFI_MAC_ADD_LENGTH + 1); + fclose(fp); + } else { + *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS); + + if (*mac_address == NULL || strlen(*mac_address) == 0) { + WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE + " from %s", VCONFKEY_WIFI_BSSID_ADDRESS); + return WIFI_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE + } } -#endif return WIFI_ERROR_NONE; }