#if defined(WAYLAND)
#include <Ecore_Wayland.h>
+#include <wayland-client.h>
+#include <wayland-tbm-client.h>
+#include <tizen-extension-client-protocol.h>
#elif defined(X11)
#include <X11/Xatom.h>
#include <X11/Xlib.h>
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
[AE_RESET] = "RESET",
[AE_LOWMEM_POST] = "LOWMEM_POST",
[AE_MEM_FLUSH] = "MEM_FLUSH",
+ [AE_UPDATE_REQUESTED] = "UPDATE_REQUESTED",
};
static const char *_as_name[] = {
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 __wl_listener_cb(void *data, struct wl_registry *reg,
+ uint32_t id, const char *interface, uint32_t ver)
+{
+ if (interface && !strcmp(interface, "tizen_policy")) {
+ if (!tz_policy)
+ tz_policy = wl_registry_bind(reg, id,
+ &tizen_policy_interface, 1);
+ }
+}
+
+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;
+ }
+
+ reg = wl_display_get_registry(dsp);
+ if (reg == NULL) {
+ _ERR("Failed to get registry");
+ wl_display_disconnect(dsp);
+ return -1;
+ }
+
+ 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;
+ }
+
+ return 0;
+}
+
+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)
{
}
#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)
{
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);
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);
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
_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) {
_DBG("[APP %d] is another state", _pid);
}
break;
+ case AE_UPDATE_REQUESTED:
+ __appcore_efl_update_requested(ui);
+ break;
default:
/* do nothing */
break;
#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");
#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");