From aa1df925c5e86a78d9e4d653387cb42370e4aebb Mon Sep 17 00:00:00 2001 From: hyunho Date: Thu, 4 Jan 2018 15:05:54 +0900 Subject: [PATCH] Remove unnecessary feature check Change-Id: Icd2bf5a123c224c42752b3f035d5f0e20523a1e1 Signed-off-by: hyunho --- src/watch_app_main.c | 89 ++++++++++++++++++++++++++++++++++++------------- src/watch_app_private.h | 10 ------ 2 files changed, 65 insertions(+), 34 deletions(-) diff --git a/src/watch_app_main.c b/src/watch_app_main.c index a295cfa..1ede5b6 100755 --- a/src/watch_app_main.c +++ b/src/watch_app_main.c @@ -167,6 +167,23 @@ static void __on_ambient_tick(void *watchtime, void *data); static void __on_ambient_changed(int ambient, void *data); static void __on_time_tick(void *watchtime, void *data); +static bool __check_feature(void) +{ + static bool is_checked = false; + static bool is_supported = false; + + if (is_checked) + return is_supported; + if (!system_info_get_platform_bool(WATCH_APP_FEATURE, &is_supported)) { + is_checked = true; + if (!is_supported) { + LOGE("[%s] feature is disabled", WATCH_APP_FEATURE); + return false; + } + } + return is_supported; +} + static void __alarm_init(void) { int r = 0; @@ -837,7 +854,8 @@ EXPORT_API int watch_app_main(int argc, char **argv, appcore_efl_base_ops ops = appcore_efl_base_get_default_ops(); char *viewer_visibility_str = NULL; - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; /* override methods */ ops.ui_base.base.create = __on_create; @@ -950,7 +968,8 @@ EXPORT_API int watch_app_add_event_handler(app_event_handler_h *event_handler, { app_event_handler_h handler; - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (event_handler == NULL || callback == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -981,7 +1000,8 @@ EXPORT_API int watch_app_remove_event_handler(app_event_handler_h event_handler) int ret; app_event_type_e type; - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (event_handler == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1006,7 +1026,8 @@ EXPORT_API int watch_time_get_current_time(watch_time_h *watch_time) { struct _watch_time_s *time_info; - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1026,7 +1047,8 @@ EXPORT_API int watch_time_get_current_time(watch_time_h *watch_time) EXPORT_API int watch_time_delete(watch_time_h watch_time) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1042,7 +1064,8 @@ EXPORT_API int watch_time_delete(watch_time_h watch_time) EXPORT_API int watch_time_get_year(watch_time_h watch_time, int *year) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1054,7 +1077,8 @@ EXPORT_API int watch_time_get_year(watch_time_h watch_time, int *year) EXPORT_API int watch_time_get_month(watch_time_h watch_time, int *month) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1066,7 +1090,8 @@ EXPORT_API int watch_time_get_month(watch_time_h watch_time, int *month) EXPORT_API int watch_time_get_day(watch_time_h watch_time, int *day) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1079,7 +1104,8 @@ EXPORT_API int watch_time_get_day(watch_time_h watch_time, int *day) EXPORT_API int watch_time_get_day_of_week(watch_time_h watch_time, int *day_of_week) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1091,7 +1117,8 @@ EXPORT_API int watch_time_get_day_of_week(watch_time_h watch_time, EXPORT_API int watch_time_get_hour(watch_time_h watch_time, int *hour) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1103,7 +1130,8 @@ EXPORT_API int watch_time_get_hour(watch_time_h watch_time, int *hour) EXPORT_API int watch_time_get_hour24(watch_time_h watch_time, int *hour24) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1115,7 +1143,8 @@ EXPORT_API int watch_time_get_hour24(watch_time_h watch_time, int *hour24) EXPORT_API int watch_time_get_minute(watch_time_h watch_time, int *minute) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1127,7 +1156,8 @@ EXPORT_API int watch_time_get_minute(watch_time_h watch_time, int *minute) EXPORT_API int watch_time_get_second(watch_time_h watch_time, int *second) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1140,7 +1170,8 @@ EXPORT_API int watch_time_get_second(watch_time_h watch_time, int *second) EXPORT_API int watch_time_get_millisecond(watch_time_h watch_time, int *millisecond) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1155,7 +1186,8 @@ EXPORT_API int watch_time_get_utc_time(watch_time_h watch_time, { time_t timestamp; - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL || utc_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1171,7 +1203,8 @@ EXPORT_API int watch_time_get_utc_time(watch_time_h watch_time, EXPORT_API int watch_time_get_utc_timestamp(watch_time_h watch_time, time_t *utc_timestamp) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1185,7 +1218,8 @@ EXPORT_API int watch_time_get_utc_timestamp(watch_time_h watch_time, EXPORT_API int watch_time_get_time_zone(watch_time_h watch_time, char **time_zone_id) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL || watch_time->timezone == NULL || time_zone_id == NULL) @@ -1199,7 +1233,8 @@ EXPORT_API int watch_time_get_time_zone(watch_time_h watch_time, EXPORT_API int watch_time_get_dst_status(watch_time_h watch_time, bool *status) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (watch_time == NULL || status == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); @@ -1214,7 +1249,8 @@ EXPORT_API int watch_time_get_dst_status(watch_time_h watch_time, bool *status) EXPORT_API int watch_time_get_daylight_time_status(watch_time_h watch_time, bool *daylight) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; return watch_time_get_dst_status(watch_time, daylight); } @@ -1236,7 +1272,8 @@ EXPORT_API int watch_app_get_elm_win(Evas_Object **win) Ecore_Wl_Window *wl_win; char buffer[256]; - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (win == NULL) return watch_app_error(APP_ERROR_INVALID_PARAMETER, @@ -1268,7 +1305,8 @@ EXPORT_API int watch_app_get_elm_win(Evas_Object **win) EXPORT_API int watch_app_set_ambient_tick_type(watch_app_ambient_tick_type_e type) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (type < WATCH_APP_AMBIENT_TICK_NO_TICK || type > WATCH_APP_AMBIENT_TICK_EVERY_DAY) return APP_ERROR_INVALID_PARAMETER; @@ -1277,7 +1315,8 @@ EXPORT_API int watch_app_set_ambient_tick_type(watch_app_ambient_tick_type_e typ EXPORT_API int watch_app_get_ambient_tick_type(watch_app_ambient_tick_type_e *type) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (type == NULL) return APP_ERROR_INVALID_PARAMETER; @@ -1286,7 +1325,8 @@ EXPORT_API int watch_app_get_ambient_tick_type(watch_app_ambient_tick_type_e *ty EXPORT_API int watch_app_set_time_tick_frequency(int ticks, watch_app_time_tick_resolution_e type) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (type < WATCH_APP_TIME_TICKS_PER_SECOND || type > WATCH_APP_TIME_TICKS_PER_HOUR) return APP_ERROR_INVALID_PARAMETER; @@ -1295,7 +1335,8 @@ EXPORT_API int watch_app_set_time_tick_frequency(int ticks, watch_app_time_tick_ EXPORT_API int watch_app_get_time_tick_frequency(int *ticks, watch_app_time_tick_resolution_e *type) { - CHECK_WATCH_APP_FEATURE(); + if (!__check_feature()) + return APP_ERROR_NOT_SUPPORTED; if (type == NULL || ticks == NULL) return APP_ERROR_INVALID_PARAMETER; diff --git a/src/watch_app_private.h b/src/watch_app_private.h index 05de80f..4c56433 100755 --- a/src/watch_app_private.h +++ b/src/watch_app_private.h @@ -27,16 +27,6 @@ extern "C" { #endif #define WATCH_APP_FEATURE "http://tizen.org/feature/watch_app" -#define CHECK_WATCH_APP_FEATURE() \ - do { \ - bool is_supported = false; \ - if (!system_info_get_platform_bool(WATCH_APP_FEATURE, &is_supported)) { \ - if (is_supported == false) { \ - LOGE("[%s] feature is disabled", WATCH_APP_FEATURE); \ - return APP_ERROR_NOT_SUPPORTED; \ - } \ - } \ - } while (0) int watch_app_error(app_error_e error, const char *function, const char *description); -- 2.7.4