Remove Profile Build Dependency (TV) 05/97105/2
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 11 Nov 2016 06:49:32 +0000 (15:49 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 9 Dec 2016 05:53:31 +0000 (14:53 +0900)
- 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 <myungjoo.ham@samsung.com>
CMakeLists.txt
packaging/capi-network-wifi.spec
src/net_wifi.c

index a93688e..e36c92d 100755 (executable)
@@ -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})
index f5146db..8336f46 100755 (executable)
@@ -40,9 +40,6 @@ cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
 %if 0%{?model_build_feature_network_dsds} == 1
        -DTIZEN_DUALSIM_ENABLE=1 \
 %endif
-%if "%{profile}" == "tv"
-       -DTIZEN_TV=1 \
-%endif
        .
 
 make %{?_smp_mflags}
index 4b8a9a2..99abfed 100755 (executable)
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <glib.h>
+#include <system_info.h>
 
 #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;
 }