Remove Profile Build Dependency: do it at runtime / CAPI defragmentation 46/102346/6
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 5 Dec 2016 11:16:22 +0000 (20:16 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 21 Feb 2017 00:26:15 +0000 (16:26 -0800)
- This is for Tizen 4.0.

- API per profile for SDK is filetered by sdk-image.git.
 You may include APIs not included for Wearable profile, which
 is filtered during rootstraping of wearable SDK.

- API disable for .so is done at runtime.

- CC'ed SDK (sh.cat.lee@samsung.com) for SDK review

Change-Id: Ie4640b3f15a8044570e02b0e0a94fc91253bdb7a
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
CMakeLists.txt
include/efl_util.h.in
packaging/capi-ui-efl-util.spec
src/efl_util.c

index 5ae9076..cf31d63 100644 (file)
@@ -7,15 +7,11 @@ PROJECT(${fw_name})
 SET(CMAKE_INSTALL_PREFIX /usr)
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
-IF (TIZEN_WEARABLE)
-    ADD_DEFINITIONS("-DTIZEN_WEARABLE")
-ENDIF (TIZEN_WEARABLE)
-
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
 # required dependencies
-SET(dependents "dlog elementary capi-base-common libdrm libtbm")
+SET(dependents "dlog elementary capi-base-common capi-system-info libdrm libtbm")
 
 SET(dependents "${dependents} ecore-wayland wayland-client wayland-tbm-client screenshooter-client tizen-extension-client")
 
index aa16c9c..ff3df31 100644 (file)
@@ -191,9 +191,7 @@ API int efl_util_set_window_opaque_state(Evas_Object *window, int opaque);
  * @privilege %http://tizen.org/privilege/display
  * @remarks This API needs the privilege.
  *          If the application which is not get the privilege use this API, the window manager generates the permission deny error.
- $TZ_CFG_KEEP_BEGIN$
- *          The application can notice this error if it set the callback function using the efl_util_set_window_screen_mode_error_cb().
- $TZ_CFG_KEEP_END$
+ *          The application can notice this error if it set the callback function using the efl_util_set_window_screen_mode_error_cb() (non-wearable only).
  * @param[in] window The EFL window
  * @param[in] mode The screen mode
  * @return @c 0 on success, otherwise a negative error value
@@ -214,11 +212,10 @@ API int efl_util_set_window_screen_mode(Evas_Object *window, efl_util_screen_mod
  */
 API int efl_util_get_window_screen_mode(Evas_Object *window, efl_util_screen_mode_e *mode);
 
-$TZ_CFG_KEEP_BEGIN$
 /**
  * @deprecated Deprecated since 3.0.
  * @brief Called when an error occurs for setting window's screen mode
- * @since_tizen 2.4
+ * @since_tizen $TZ_CFG_NONWEARABLE_24
  * @remarks An application can check error by the return value of efl_util_set_window_screen_mode since 3.0.
  * @param[in] window The EFL window
  * @param[in] error_code The error code (#EFL_UTIL_ERROR_PERMISSION_DENIED)
@@ -231,7 +228,7 @@ typedef void (*efl_util_window_screen_mode_error_cb)(Evas_Object *window, int er
 /**
  * @deprecated Deprecated since 3.0. Use the return value of efl_util_set_window_screen_mode() instead.
  * @brief Registers a callback function to be invoked when an error which set the screen mode.
- * @since_tizen 2.4
+ * @since_tizen $TZ_CFG_NONWEARABLE_24
  * @remarks An application can check error by the return value of efl_util_set_window_screen_mode since 3.0.
  * @param[in] window The EFL window
  * @param[in] callback The callback function to register
@@ -249,7 +246,7 @@ API int efl_util_set_window_screen_mode_error_cb(Evas_Object *window, efl_util_w
 /**
  * @deprecated Deprecated since 3.0. Use the return value of efl_util_set_window_screen_mode() instead.
  * @brief Unregisters the callback function.
- * @since_tizen 2.4
+ * @since_tizen $TZ_CFG_NONWEARABLE_24
  * @remarks An application can check error by the return value of efl_util_set_window_screen_mode since 3.0.
  * @param[in] window The EFL window
  * @return @c 0 on success, otherwise a negative error value
@@ -258,7 +255,6 @@ API int efl_util_set_window_screen_mode_error_cb(Evas_Object *window, efl_util_w
  * @see efl_util_set_window_screen_mode_error_cb()
  */
 API int efl_util_unset_window_screen_mode_error_cb(Evas_Object *window) TIZEN_DEPRECATED_API;
-$TZ_CFG_KEEP_END$
 
 /**
  * @brief Sets the user's preferred brightness of the specified window.
index c7c3185..bf75a96 100644 (file)
@@ -16,6 +16,7 @@ BuildRequires:  pkgconfig(tizen-extension-client)
 BuildRequires:  pkgconfig(ecore-wayland)
 BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(libdrm)
 BuildRequires:  pkgconfig(libtbm)
 
@@ -37,24 +38,13 @@ Requires: %{name} = %{version}-%{release}
 cp %{SOURCE1001} .
 
 cp -a include/efl_util.h.in include/efl_util.h
-%if "%{profile}" != "wearable"
-   sed -i 's/\$TZ_CFG_VER_24_OR_30\$/2.4/g'    include/efl_util.h
-   sed -i 's/\$TZ_CFG_VER_24_OR_231\$/2.4/g'   include/efl_util.h
-   sed -i '/\$TZ_CFG_KEEP_BEGIN\$/d'           include/efl_util.h
-   sed -i '/\$TZ_CFG_KEEP_END\$/d'             include/efl_util.h
-%else
-   sed -i 's/\$TZ_CFG_VER_24_OR_30\$/3.0/g'    include/efl_util.h
-   sed -i 's/\$TZ_CFG_VER_24_OR_231\$/2.3.1/g' include/efl_util.h
-   sed -ie '/\$TZ_CFG_KEEP_BEGIN\$/,/\$TZ_CFG_KEEP_END\$/{s/\$TZ_CFG_KEEP_BEGIN\$//p;d}' include/efl_util.h
-%endif
-
+sed -i 's/\$TZ_CFG_VER_24_OR_30\$/@if WEARABLE 3.0 @else 2.4 @endif/g'    include/efl_util.h
+sed -i 's/\$TZ_CFG_VER_24_OR_231\$/@if WEARABLE 2.3.1 @else 2.4 @endif/g'   include/efl_util.h
+sed -i 's/\$TZ_CFG_NONWEARABLE_24\$/@if WEARABLE @else 2.4 @endif/g'   include/efl_util.h
 
 %build
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
-%if "%{profile}" == "wearable"
-    -DTIZEN_WEARABLE=YES \
-%endif
 
 make %{?jobs:-j%jobs}
 
index 95d0874..170f0dc 100644 (file)
 #undef LOG_TAG
 #endif
 
+/* Determine Tizen profile at runtime */
+#include <system_info.h>
+typedef enum {
+   TIZEN_PROFILE_UNKNOWN = 0,
+   TIZEN_PROFILE_MOBILE = 0x1,
+   TIZEN_PROFILE_WEARABLE = 0x2,
+   TIZEN_PROFILE_TV = 0x4,
+   TIZEN_PROFILE_IVI = 0x8,
+   TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+static tizen_profile_t _get_tizen_profile()
+{
+   char *profileName;
+   system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+   switch (*profileName) {
+   case 'm':
+   case 'M':
+     profile = TIZEN_PROFILE_MOBILE;
+     break;
+   case 'w':
+   case 'W':
+     profile = TIZEN_PROFILE_WEARABLE;
+     break;
+   case 't':
+   case 'T':
+     profile = TIZEN_PROFILE_TV;
+     break;
+   case 'i':
+   case 'I':
+     profile = TIZEN_PROFILE_IVI;
+     break;
+   default: // common or unknown ==> ALL ARE COMMON.
+     profile = TIZEN_PROFILE_COMMON;
+   }
+   free(profileName);
+
+   return profile;
+}
+static inline tizen_profile_t get_tizen_profile()
+{
+   if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+     return profile;
+   return _get_tizen_profile();
+}
+
+
 #define LOG_TAG "TIZEN_N_EFL_UTIL"
 
 
@@ -1045,12 +1092,15 @@ efl_util_get_window_screen_mode(Evas_Object *window,
      return EFL_UTIL_ERROR_INVALID_PARAMETER;
 }
 
-#ifndef TIZEN_WEARABLE
 API int
 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
                                          efl_util_window_screen_mode_error_cb callback,
                                          void *user_data)
 {
+   /* Wearable device cannot use this. */
+   if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
+     return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
+
    dlog_print(DLOG_WARN, LOG_TAG,
      "DEPRECATION WARNING: efl_util_set_window_screen_mode_error_cb() is deprecated and will be removed from next release. Use the return value of efl_util_set_window_screen_mode() instead.");
 
@@ -1071,6 +1121,10 @@ efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
 API int
 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
 {
+   /* Wearable device cannot use this. */
+   if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
+     return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
+
    dlog_print(DLOG_WARN, LOG_TAG,
      "DEPRECATION WARNING: efl_util_unset_window_screen_mode_error_cb() is deprecated and will be removed from next release. Use the return value of efl_util_set_window_screen_mode() instead.");
 
@@ -1083,7 +1137,6 @@ efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
 
    return EFL_UTIL_ERROR_NONE;
 }
-#endif
 
 API int
 efl_util_set_window_brightness(Evas_Object *window, int brightness)