From: Hwankyu Jhun Date: Mon, 3 Jul 2017 04:59:29 +0000 (+0900) Subject: Support legacy lifecycle X-Git-Tag: accepted/tizen/unified/20170707.154809~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fappfw%2Fapp-core.git;a=commitdiff_plain;h=b525984fc57b70bc02fffb8f875077675db69d93 Support legacy lifecycle This patch is for backward compatibility. In Tizen 2.3, the resume callback is invoked when getting the reset event. Change-Id: I741be7217ef3b81435a72a84f2e6bf592fcff18f Signed-off-by: Hwankyu Jhun --- diff --git a/include/appcore_efl_base.h b/include/appcore_efl_base.h index ac86a72..90903d2 100644 --- a/include/appcore_efl_base.h +++ b/include/appcore_efl_base.h @@ -35,6 +35,7 @@ enum appcore_efl_base_hint { APPCORE_EFL_BASE_HINT_BG_LAUNCH_CONTROL = APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL, APPCORE_EFL_BASE_HINT_HW_ACC_CONTROL = APPCORE_UI_BASE_HINT_HW_ACC_CONTROL, APPCORE_EFL_BASE_HINT_WINDOW_AUTO_CONTROL = APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL, + APPCORE_EFL_BASE_HINT_LEGACY_CONTROL = APPCORE_UI_BASE_HINT_LEGACY_CONTROL, }; int appcore_efl_base_on_receive(aul_type type, bundle *b); @@ -60,6 +61,8 @@ void appcore_efl_base_group_remove(); unsigned int appcore_efl_base_get_main_window(void); unsigned int appcore_efl_base_get_main_surface(void); int appcore_efl_base_get_hint(void); +bool appcore_efl_base_get_bg_state(void); +void appcore_efl_base_set_bg_state(bool bg_state); #ifdef __cplusplus } diff --git a/include/appcore_ui_base.h b/include/appcore_ui_base.h index 9359564..83f648d 100644 --- a/include/appcore_ui_base.h +++ b/include/appcore_ui_base.h @@ -46,6 +46,7 @@ enum appcore_ui_base_hint { APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL = 0x4, APPCORE_UI_BASE_HINT_HW_ACC_CONTROL = 0x8, APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL = 0x10, + APPCORE_UI_BASE_HINT_LEGACY_CONTROL = 0x20, }; int appcore_ui_base_on_receive(aul_type type, bundle *b); @@ -72,6 +73,8 @@ void appcore_ui_base_group_remove(); unsigned int appcore_ui_base_get_main_window(void); unsigned int appcore_ui_base_get_main_surface(void); int appcore_ui_base_get_hint(void); +bool appcore_ui_base_get_bg_state(void); +void appcore_ui_base_set_bg_state(bool bg_state); #ifdef __cplusplus } diff --git a/src/efl_base/appcore_efl_base.c b/src/efl_base/appcore_efl_base.c index 5cea46c..1ac09fd 100644 --- a/src/efl_base/appcore_efl_base.c +++ b/src/efl_base/appcore_efl_base.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#define _GNU_SOURCE #include #include #include @@ -190,3 +191,13 @@ EXPORT_API int appcore_efl_base_get_hint(void) { return appcore_ui_base_get_hint(); } + +EXPORT_API bool appcore_efl_base_get_bg_state(void) +{ + return appcore_ui_base_get_bg_state(); +} + +EXPORT_API void appcore_efl_base_set_bg_state(bool bg_state) +{ + appcore_ui_base_set_bg_state(bg_state); +} diff --git a/src/legacy/appcore-efl.c b/src/legacy/appcore-efl.c index 503e550..b171a27 100644 --- a/src/legacy/appcore-efl.c +++ b/src/legacy/appcore-efl.c @@ -99,7 +99,8 @@ EXPORT_API int appcore_efl_init(const char *name, int *argc, char ***argv, APPCORE_EFL_BASE_HINT_WINDOW_STACK_CONTROL | APPCORE_EFL_BASE_HINT_BG_LAUNCH_CONTROL | APPCORE_EFL_BASE_HINT_HW_ACC_CONTROL | - APPCORE_EFL_BASE_HINT_WINDOW_AUTO_CONTROL); + APPCORE_EFL_BASE_HINT_WINDOW_AUTO_CONTROL | + APPCORE_EFL_BASE_HINT_LEGACY_CONTROL); return ret; } diff --git a/src/ui_base/appcore_ui_base.c b/src/ui_base/appcore_ui_base.c index d6521b3..4aaa141 100644 --- a/src/ui_base/appcore_ui_base.c +++ b/src/ui_base/appcore_ui_base.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#define _GNU_SOURCE #include #include #include @@ -62,6 +63,7 @@ typedef struct _appcore_ui_base_context { unsigned int hint; char *below_app; char *appid; + bool bg_state; int state; Ecore_Event_Handler *hshow; @@ -86,7 +88,6 @@ static appcore_ui_base_context __context; static struct wl_display *dsp; static struct wl_registry *reg; static struct tizen_policy *tz_policy; -static bool bg_state = false; static void __wl_listener_cb(void *data, struct wl_registry *reg, uint32_t id, const char *interface, uint32_t ver) @@ -406,8 +407,8 @@ static void __set_bg_state(void) tizen_policy_set_background_state(tz_policy, getpid()); wl_display_roundtrip(dsp); - bg_state = true; - _DBG("bg state: %d", bg_state); + __context.bg_state = true; + _DBG("bg state: %d", __context.bg_state); } static void __unset_bg_state(void) @@ -417,8 +418,8 @@ static void __unset_bg_state(void) tizen_policy_unset_background_state(tz_policy, getpid()); wl_display_roundtrip(dsp); - bg_state = false; - _DBG("bg state: %d", bg_state); + __context.bg_state = false; + _DBG("bg state: %d", __context.bg_state); } static void __do_start(bundle *b) @@ -445,20 +446,43 @@ static void __do_start(bundle *b) if (__context.hint & APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL) { bg_launch = bundle_get_val(b, AUL_SVC_K_BG_LAUNCH); if (bg_launch && strcmp(bg_launch, "enable") == 0) { - if (!bg_state && __context.state != AS_RUNNING) + if (!__context.bg_state && + __context.state != AS_RUNNING) __set_bg_state(); } else { - if (bg_state) + if (__context.bg_state) __unset_bg_state(); } } if (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL) { - if (!bg_state) + if (!__context.bg_state) __raise_win(); } } +static int __is_legacy_lifecycle(void) +{ + static int is_legacy = -1; + const char *api_version; + + if (is_legacy != -1) + return is_legacy; + + api_version = getenv("TIZEN_API_VERSION"); + if (api_version) { + if (strverscmp("2.4", api_version) > 0 && + strverscmp("2.2.1", api_version) < 0) + is_legacy = 1; + else + is_legacy = 0; + } else { + is_legacy = 0; + } + + return is_legacy; +} + EXPORT_API int appcore_ui_base_on_receive(aul_type type, bundle *b) { if (__context.state == AS_DYING) { @@ -477,9 +501,15 @@ EXPORT_API int appcore_ui_base_on_receive(aul_type type, bundle *b) switch (type) { case AUL_START: __do_start(b); + if (__context.hint & APPCORE_UI_BASE_HINT_LEGACY_CONTROL) { + if (!__context.bg_state && __is_legacy_lifecycle()) { + _DBG("Legacy lifecycle"); + __do_resume(); + } + } break; case AUL_RESUME: - if (bg_state) + if (__context.bg_state) __unset_bg_state(); __raise_win(); break; @@ -502,17 +532,66 @@ EXPORT_API int appcore_ui_base_on_receive(aul_type type, bundle *b) return 0; } -EXPORT_API int appcore_ui_base_on_create(void) +static void __add_ecore_events(void) { - appcore_base_on_create(); + __context.hshow = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, + __stub_show_cb, NULL); + if (!__context.hshow) + _ERR("Failed to add ECORE_WL_EVENT_WINDOW_SHOW event"); + + __context.hhide = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, + __stub_hide_cb, NULL); + if (!__context.hhide) + _ERR("Failed to add ECORE_WL_EVENT_WINDOW_HIDE event"); - __context.hshow = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __stub_show_cb, NULL); - __context.hhide = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __stub_hide_cb, NULL); __context.hvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, - __stub_visibility_cb, NULL); - __context.hlower = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER, __stub_lower_cb, NULL); + __stub_visibility_cb, NULL); + if (!__context.hvchange) + _ERR("Failed to add ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE event"); + + __context.hlower = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER, + __stub_lower_cb, NULL); + if (!__context.hlower) + _ERR("Failed to add ECORE_WL_EVENT_WINDOW_LOWER event"); + __context.hpvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_PRE_VISIBILITY_CHANGE, __stub_pre_visibility_cb, NULL); + if (!__context.hpvchange) + _ERR("Failed to add ECORE_WL_EVENT_WINDOW_PRE_VISIBILITY_CHANGE event"); +} + +static void __del_ecore_events(void) +{ + if (__context.hshow) { + ecore_event_handler_del(__context.hshow); + __context.hshow = NULL; + } + + if (__context.hhide) { + ecore_event_handler_del(__context.hhide); + __context.hhide = NULL; + } + + if (__context.hvchange) { + ecore_event_handler_del(__context.hvchange); + __context.hvchange = NULL; + } + + if (__context.hlower) { + ecore_event_handler_del(__context.hlower); + __context.hlower = NULL; + } + + if (__context.hpvchange) { + ecore_event_handler_del(__context.hpvchange); + __context.hpvchange = NULL; + } +} + +EXPORT_API int appcore_ui_base_on_create(void) +{ + __add_ecore_events(); + appcore_base_on_create(); __context.state = AS_CREATED; LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]", __context.appid); @@ -743,17 +822,7 @@ EXPORT_API int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **ar EXPORT_API void appcore_ui_base_fini(void) { - if (__context.hshow) - ecore_event_handler_del(__context.hshow); - if (__context.hhide) - ecore_event_handler_del(__context.hhide); - if (__context.hvchange) - ecore_event_handler_del(__context.hvchange); - if (__context.hlower) - ecore_event_handler_del(__context.hlower); - if (__context.hpvchange) - ecore_event_handler_del(__context.hpvchange); - + __del_ecore_events(); __finish_wl(); free(__context.appid); @@ -799,6 +868,16 @@ EXPORT_API int appcore_ui_base_get_hint(void) return __context.hint; } +EXPORT_API bool appcore_ui_base_get_bg_state(void) +{ + return __context.bg_state; +} + +EXPORT_API void appcore_ui_base_set_bg_state(bool bg_state) +{ + __context.bg_state = bg_state; +} + static int __on_receive(aul_type type, bundle *b, void *data) { return appcore_ui_base_on_receive(type, b);