Remove Profile Build Dependency (TV) 59/97059/2
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 11 Nov 2016 05:30:05 +0000 (14:30 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 11 Nov 2016 06:40:08 +0000 (15:40 +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:
connection$ grep -r "TIZEN_TV" *
connection$

Change-Id: I762dbbd6d44ef27987b7463fd717fa604187858a
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
CMakeLists.txt
packaging/capi-network-connection.spec
src/connection.c

index 1fc7890..1dbc63c 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_DUALSIM_ENABLE)
     ADD_DEFINITIONS(-DTIZEN_DUALSIM_ENABLE)
 ENDIF(TIZEN_DUALSIM_ENABLE)
-IF(TIZEN_TV)
-    ADD_DEFINITIONS(-DTIZEN_TV)
-ENDIF(TIZEN_TV)
 
 
 INCLUDE(FindPkgConfig)
 
 
 INCLUDE(FindPkgConfig)
index c5ba36d..71546c8 100755 (executable)
@@ -38,9 +38,6 @@ cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
 %if 0%{?model_build_feature_network_dsds} == 1
        -DTIZEN_DUALSIM_ENABLE=1 \
 %endif
 %if 0%{?model_build_feature_network_dsds} == 1
        -DTIZEN_DUALSIM_ENABLE=1 \
 %endif
-%if "%{profile}" == "tv"
-       -DTIZEN_TV=1 \
-%endif
        .
 
 make %{?_smp_mflags}
        .
 
 make %{?_smp_mflags}
index 3901e2e..e01c914 100755 (executable)
 
 #include <glib.h>
 #include <stdio.h>
 
 #include <glib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <vconf/vconf.h>
 #include <string.h>
 #include <vconf/vconf.h>
+#include <system_info.h>
 
 #include "net_connection_private.h"
 
 static __thread GSList *conn_handle_list = NULL;
 
 #include "net_connection_private.h"
 
 static __thread GSList *conn_handle_list = NULL;
+static int tv_profile = -1; // Unknown
 
 //LCOV_EXCL_START
 static int __connection_convert_net_state(int status)
 
 //LCOV_EXCL_START
 static int __connection_convert_net_state(int status)
@@ -556,37 +559,46 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
 
        switch (type) {
        case CONNECTION_TYPE_WIFI:
 
        switch (type) {
        case CONNECTION_TYPE_WIFI:
-#if defined TIZEN_TV
-               fp = fopen(WIFI_MAC_INFO_FILE, "r");
-               if (fp == NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_OUT_OF_MEMORY; //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) {
+                       fp = fopen(WIFI_MAC_INFO_FILE, "r");
+                       if (fp == NULL) {
+                               CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
+                               return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+                       }
 
 
-               if (fgets(buf, sizeof(buf), fp) == NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
-                       fclose(fp); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_OPERATION_FAILED;
-               }
+                       if (fgets(buf, sizeof(buf), fp) == NULL) {
+                               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
+                               fclose(fp); //LCOV_EXCL_LINE
+                               return CONNECTION_ERROR_OPERATION_FAILED;
+                       }
 
 
-               CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf);
+                       CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf);
 
 
-               *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
-               if (*mac_addr == NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed"); //LCOV_EXCL_LINE
-                       fclose(fp); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
-               }
-               g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
-               fclose(fp);
-#else
-               *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+                       *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
+                       if (*mac_addr == NULL) {
+                               CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed"); //LCOV_EXCL_LINE
+                               fclose(fp); //LCOV_EXCL_LINE
+                               return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+                       }
+                       g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
+                       fclose(fp);
+               } else {
+                       *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
 
 
-               if (*mac_addr == NULL) {
-                       CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS); //LCOV_EXCL_LINE
-                       return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+                       if (*mac_addr == NULL) {
+                               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS); //LCOV_EXCL_LINE
+                               return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+                       }
                }
                }
-#endif
                break;
        //LCOV_EXCL_START
        case CONNECTION_TYPE_ETHERNET:
                break;
        //LCOV_EXCL_START
        case CONNECTION_TYPE_ETHERNET: