X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fappcore-efl.c;h=f0161b33d50e842e30e04c70103e13b4f67a59b5;hb=39cbcf2218aafa82ccdc9cb460cc99ef06173f05;hp=d190acf8e6828e584beac2085aeb3843df137204;hpb=8d5d4007f59e19fc112051a8479ef2be3714231c;p=platform%2Fcore%2Fappfw%2Fapp-core.git diff --git a/src/appcore-efl.c b/src/appcore-efl.c index d190acf..f0161b3 100644 --- a/src/appcore-efl.c +++ b/src/appcore-efl.c @@ -26,6 +26,9 @@ #if defined(WAYLAND) #include +#include +#include +#include #elif defined(X11) #include #include @@ -42,28 +45,17 @@ #include #include #include +#include +#include #include #include "appcore-internal.h" #include "appcore-efl.h" -#define RESOURCED_PROCESS_PATH "/Org/Tizen/ResourceD/Process" -#define RESOURCED_PROCESS_INTERFACE "org.tizen.resourced.process" -#define RESOURCED_PROCSTATUS_SIGNAL "ProcStatus" - static pid_t _pid; static bool resource_reclaiming = TRUE; static int tmp_val = 0; -/* cgroup command type */ -enum proc_status_type { - PROC_STATUS_LAUNCH, - PROC_STATUS_RESUME, - PROC_STATUS_TERMINATE, - PROC_STATUS_FOREGRD, - PROC_STATUS_BACKGRD, -}; - struct ui_priv { const char *name; enum app_state state; @@ -78,8 +70,8 @@ struct ui_priv { Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */ -#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT struct appcore *app_core; +#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT void (*prepare_to_suspend) (void *data); void (*exit_from_suspend) (void *data); #endif @@ -93,6 +85,7 @@ struct ui_priv { void *rot_cb_data; enum appcore_rm rot_mode; bundle *pending_data; + char *below_app; }; static struct ui_priv priv; @@ -106,6 +99,7 @@ static const char *_ae_name[AE_MAX] = { [AE_RESET] = "RESET", [AE_LOWMEM_POST] = "LOWMEM_POST", [AE_MEM_FLUSH] = "MEM_FLUSH", + [AE_UPDATE_REQUESTED] = "UPDATE_REQUESTED", }; static const char *_as_name[] = { @@ -131,41 +125,103 @@ struct win_node { static struct ui_wm_rotate wm_rotate; #endif static Eina_Bool __visibility_cb(void *data, int type, void *event); +static GSList *g_winnode_list; + +static struct wl_display *dsp; +static struct wl_registry *reg; +static struct tizen_policy *tz_policy; +static bool bg_state = false; -static void __send_to_resourced(enum proc_status_type type) +static void __wl_listener_cb(void *data, struct wl_registry *reg, + uint32_t id, const char *interface, uint32_t ver) { - GDBusConnection *conn; - GError *err = NULL; + if (interface && !strcmp(interface, "tizen_policy")) { + if (!tz_policy) + tz_policy = wl_registry_bind(reg, id, + &tizen_policy_interface, 1); + } +} - conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); - if (!conn) { - _ERR("g_bus_bus_get() is failed: [%s]", err->message); - g_error_free(err); - return; +static void __wl_listener_remove_cb(void *data, struct wl_registry *reg, + unsigned int id) +{ + /* do nothing */ +} + +static const struct wl_registry_listener reg_listener = { + __wl_listener_cb, + __wl_listener_remove_cb +}; + +static int __init_wl(void) +{ + _DBG("initialize wayland"); + dsp = wl_display_connect(NULL); + if (dsp == NULL) { + _ERR("Failed to connect wl display"); + return -1; } - if (g_dbus_connection_emit_signal(conn, - NULL, - RESOURCED_PROCESS_PATH, - RESOURCED_PROCESS_INTERFACE, - RESOURCED_PROCSTATUS_SIGNAL, - g_variant_new("(ii)", type, _pid), - &err) == FALSE) { - _ERR("g_dbus_connection_emit_signal() is failed: [%s]", - err->message); - g_error_free(err); - return; + reg = wl_display_get_registry(dsp); + if (reg == NULL) { + _ERR("Failed to get registry"); + wl_display_disconnect(dsp); + return -1; } - if (g_dbus_connection_flush_sync(conn, NULL, &err) == FALSE) - _ERR("g_dbus_connection_flush_sync() is failed: [%s]", - err->message); + wl_registry_add_listener(reg, ®_listener, NULL); + wl_display_roundtrip(dsp); + + if (!tz_policy) { + _ERR("Failed to get tizen policy interface"); + wl_registry_destroy(reg); + wl_display_disconnect(dsp); + return -1; + } - g_clear_error(&err); - g_object_unref(conn); + return 0; } -static GSList *g_winnode_list; +static void __finish_wl(void) +{ + if (tz_policy) { + tizen_policy_destroy(tz_policy); + tz_policy = NULL; + } + + if (reg) { + wl_registry_destroy(reg); + reg = NULL; + } + + if (dsp) { + wl_display_disconnect(dsp); + dsp = NULL; + } +} + +static void __set_bg_state(void) +{ + if (__init_wl() < 0) + return; + + tizen_policy_set_background_state(tz_policy, getpid()); + wl_display_roundtrip(dsp); + bg_state = true; + _DBG("bg state: %d", bg_state); +} + +static void __unset_bg_state(void) +{ + if (!tz_policy) + return; + + tizen_policy_unset_background_state(tz_policy, getpid()); + wl_display_roundtrip(dsp); + bg_state = false; + _DBG("bg state: %d", bg_state); + __finish_wl(); +} #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT static void __appcore_efl_prepare_to_suspend(void *data) @@ -201,6 +257,20 @@ static void __appcore_efl_exit_from_suspend(void *data) } #endif +static void __appcore_efl_update_requested(void *data) +{ + struct ui_priv *ui = (struct ui_priv *)data; + struct sys_op *op; + int dummy = 0; + + if (ui->app_core) { + op = &ui->app_core->sops[SE_UPDATE_REQUESTED]; + if (op && op->func) + op->func((void *)&dummy, op->data); + } + _DBG("[__UPDATE_REQUESTED__]"); +} + #if defined(MEMORY_FLUSH_ACTIVATE) static Eina_Bool __appcore_memory_flush_cb(void *data) { @@ -296,6 +366,8 @@ static void __do_app(enum app_event event, void *data, bundle * b) { int r = -1; struct ui_priv *ui = data; + const char *below_app; + const char *bg_launch; _DBG("[APP %d] Event: %d", _pid, event); _ret_if(ui == NULL || event >= AE_MAX); @@ -350,9 +422,19 @@ static void __do_app(enum app_event event, void *data, bundle * b) switch (event) { case AE_RESET: _DBG("[APP %d] RESET", _pid); + if (ui->pending_data) + bundle_free(ui->pending_data); ui->pending_data = bundle_dup(b); LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", ui->name); + if (ui->below_app) { + free(ui->below_app); + ui->below_app = NULL; + } + + below_app = bundle_get_val(b, AUL_SVC_K_RELOCATE_BELOW); + if (below_app) + ui->below_app = strdup(below_app); #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT if (ui->exit_from_suspend) { _DBG("[__SUSPEND__] reset case"); @@ -369,9 +451,18 @@ static void __do_app(enum app_event event, void *data, bundle * b) LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name); if (first_launch) { +#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT + if (ui->app_core->allowed_bg) + __appcore_timer_add(ui); +#endif first_launch = FALSE; } else { _INFO("[APP %d] App already running, raise the window", _pid); + if (bg_state) { + bg_launch = bundle_get_val(b, AUL_SVC_K_BG_LAUNCH); + if (!bg_launch || strcmp(bg_launch, "enable")) + __unset_bg_state(); + } #ifdef X11 x_raise_win(getpid()); #else @@ -404,7 +495,6 @@ static void __do_app(enum app_event event, void *data, bundle * b) /* TODO : rotation stop */ /* r = appcore_pause_rotation_cb(); */ aul_status_update(STATUS_BG); - __send_to_resourced(PROC_STATUS_BACKGRD); break; case AE_RESUME: LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]", @@ -414,6 +504,8 @@ static void __do_app(enum app_event event, void *data, bundle * b) _DBG("[__SUSPEND__] resume case"); ui->exit_from_suspend(ui); } + if (ui->app_core->allowed_bg) + __appcore_timer_del(ui); #endif if (ui->state == AS_PAUSED || ui->state == AS_CREATED) { @@ -431,6 +523,12 @@ static void __do_app(enum app_event event, void *data, bundle * b) traceEnd(TTRACE_TAG_APPLICATION_MANAGER); } ui->state = AS_RUNNING; + + if (ui->below_app) { + aul_app_group_activate_below(ui->below_app); + free(ui->below_app); + ui->below_app = NULL; + } } /*TODO : rotation start*/ /* r = appcore_resume_rotation_cb(); */ @@ -439,7 +537,6 @@ static void __do_app(enum app_event event, void *data, bundle * b) LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:Launching:done]", ui->name); aul_status_update(STATUS_VISIBLE); - __send_to_resourced(PROC_STATUS_FOREGRD); break; case AE_TERMINATE_BGAPP: if (ui->state == AS_PAUSED) { @@ -453,6 +550,9 @@ static void __do_app(enum app_event event, void *data, bundle * b) _DBG("[APP %d] is another state", _pid); } break; + case AE_UPDATE_REQUESTED: + __appcore_efl_update_requested(ui); + break; default: /* do nothing */ break; @@ -584,14 +684,10 @@ static bool __update_win(unsigned int win, bool bfobscured) return FALSE; } - g_winnode_list = g_slist_remove_link(g_winnode_list, f); - t = (struct win_node *)f->data; t->win = win; t->bfobscured = bfobscured; - g_winnode_list = g_slist_concat(g_winnode_list, f); - return TRUE; } #elif defined(WAYLAND) @@ -610,16 +706,12 @@ static bool __update_win(unsigned int win, unsigned int surf, bool bfobscured) return FALSE; } - g_winnode_list = g_slist_remove_link(g_winnode_list, f); - t = (struct win_node *)f->data; t->win = win; if (surf != 0) t->surf = surf; t->bfobscured = bfobscured; - g_winnode_list = g_slist_concat(g_winnode_list, f); - return TRUE; } #endif @@ -884,6 +976,11 @@ static int __before_loop(struct ui_priv *ui, int *argc, char ***argv) { int r; char *hwacc = NULL; +#if _APPFW_FEATURE_BACKGROUND_MANAGEMENT + struct appcore *ac = NULL; +#endif + bundle *b; + const char *bg_launch; if (argc == NULL || argv == NULL) { _ERR("argc/argv is NULL"); @@ -915,9 +1012,18 @@ static int __before_loop(struct ui_priv *ui, int *argc, char ***argv) #if _APPFW_FEATURE_BACKGROUND_MANAGEMENT appcore_get_app_core(&ac); ui->app_core = ac; - SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: 0x%x", ac); + SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: #%x", ac); #endif + b = bundle_import_from_argv(*argc, *argv); + if (b) { + bg_launch = bundle_get_val(b, AUL_SVC_K_BG_LAUNCH); + if (bg_launch && strcmp(bg_launch, "enable") == 0) + __set_bg_state(); + + bundle_free(b); + } + LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:appcore_init:done]", ui->name); if (ui->ops && ui->ops->create) { traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:CREATE"); @@ -982,6 +1088,12 @@ static void __after_loop(struct ui_priv *ui) __appcore_timer_del(ui); elm_shutdown(); + + /* Check loader case */ + if (getenv("AUL_LOADER_INIT")) { + unsetenv("AUL_LOADER_INIT"); + elm_shutdown(); + } } static int __set_data(struct ui_priv *ui, const char *name, @@ -1179,7 +1291,7 @@ EXPORT_API int appcore_set_preinit_window_name(const char *win_name) return ret; } - preinit_window = aul_get_preinit_window(win_name); + preinit_window = elm_win_precreated_object_get(); if (!preinit_window) { _ERR("Failed to get preinit window"); return ret;