- This is for Tizen 4.0.
: Tizen 4.0 Configurability and Build Blocks require
to remove all profile-depending build options in spec files.
(No More profile macros)
- It is recommended to distinguish features/profiles at runtime.
unless it incurs too much overhead, which requires you to
create multiple binaries and subpackages.
Change-Id: I200b851806704eba228709e07f0f6e634f521032
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
SET(SRCS_common ${SRCS_common} src/appcore-X.c)
ENDIF(_WITH_X11)
-IF(_APPFW_FEATURE_BACKGROUND_MANAGEMENT)
- ADD_DEFINITIONS("-D_APPFW_FEATURE_BACKGROUND_MANAGEMENT")
-ENDIF(_APPFW_FEATURE_BACKGROUND_MANAGEMENT)
-
SET(HEADERS_common appcore-common.h)
INCLUDE(FindPkgConfig)
-SET(APPCORE_PKG_CHECK_MODULES "gio-2.0 vconf sensor aul dlog ecore")
+SET(APPCORE_PKG_CHECK_MODULES "gio-2.0 vconf sensor aul dlog ecore capi-system-info")
IF(_WITH_X11)
SET(APPCORE_PKG_CHECK_MODULES "${APPCORE_PKG_CHECK_MODULES} x11 eina ecore-x")
ENDIF(_WITH_X11)
SET(HEADERS_efl appcore-efl.h)
INCLUDE(FindPkgConfig)
-SET(APPCORE_PKG_CHECK_MODULES2 "elementary dlog ecore gobject-2.0 glib-2.0 aul pkgmgr-info ttrace")
+SET(APPCORE_PKG_CHECK_MODULES2 "elementary dlog ecore gobject-2.0 glib-2.0 aul pkgmgr-info ttrace capi-system-info")
IF(_WITH_X11)
SET(APPCORE_PKG_CHECK_MODULES2 "${APPCORE_PKG_CHECK_MODULES2} ecore-x")
ENDIF(_WITH_X11)
#define MEMORY_FLUSH_ACTIVATE
+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;
+extern tizen_profile_t _get_tizen_profile();
+
+#define _APPFW_FEATURE_BACKGROUND_MANAGEMENT (_get_tizen_profile() & (TIZEN_PROFILE_WEARABLE | TIZEN_PROFILE_MOBILE))
+
#endif /* __APPCORE_INTERNAL_H__ */
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(ttrace)
BuildRequires: cmake
+BuildRequires: pkgconfig(capi-system-info)
%description
SLP common application basic
%description template
Application basics template
-%if "%{?profile}" == "wearable"
-%define appfw_feature_background_management 1
-%else
-%if "%{?profile}" == "mobile"
-%define appfw_feature_background_management 1
-%else
-%if "%{?profile}" == "tv"
-%define appfw_feature_background_management 0
-%endif
-%endif
-%endif
-
%prep
%setup -q
cp %{SOURCE1001} .
%if %{with x}
_WITH_X11=ON
%endif
-%if 0%{?appfw_feature_background_management}
-_APPFW_FEATURE_BACKGROUND_MANAGEMENT=ON
-%endif
%cmake . \
-D_WITH_WAYLAND:BOOL=${_WITH_WAYLAND} \
-D_WITH_X11:BOOL=${_WITH_X11} \
- -D_APPFW_FEATURE_BACKGROUND_MANAGEMENT:BOOL=${_APPFW_FEATURE_BACKGROUND_MANAGEMENT} \
-DENABLE_GTK=OFF
make %{?_smp_mflags}
#include "appcore-internal.h"
#include "appcore-efl.h"
+#include <system_info.h>
static pid_t _pid;
static bool resource_reclaiming = TRUE;
Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */
struct appcore *app_core;
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
void (*prepare_to_suspend) (void *data);
void (*exit_from_suspend) (void *data);
-#endif
struct appcore_ops *ops;
void (*mfcb) (void); /* Memory Flushing Callback */
__finish_wl();
}
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
static void __appcore_efl_prepare_to_suspend(void *data)
{
struct ui_priv *ui = (struct ui_priv *)data;
}
_DBG("[__SUSPEND__]");
}
-#endif
static void __appcore_efl_update_requested(void *data)
{
if (ui)
ui->mftimer = NULL;
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- if (ui && ui->prepare_to_suspend) {
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && ui && ui->prepare_to_suspend) {
_DBG("[__SUSPEND__] flush case");
ui->prepare_to_suspend(ui);
}
-#endif
return ECORE_CALLBACK_CANCEL;
}
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) {
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && ui->exit_from_suspend) {
_DBG("[__SUSPEND__] reset case");
ui->exit_from_suspend(ui);
}
-#endif
if (ui->ops->reset) {
traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name);
if (first_launch) {
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- if (ui->app_core->allowed_bg)
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && ui->app_core->allowed_bg)
__appcore_timer_add(ui);
-#endif
first_launch = FALSE;
} else {
_INFO("[APP %d] App already running, raise the window", _pid);
ui->state = AS_PAUSED;
if (r >= 0 && resource_reclaiming == TRUE)
__appcore_timer_add(ui);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- else if (r >= 0 && resource_reclaiming == FALSE
+ else if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && r >= 0 && resource_reclaiming == FALSE
&& ui->prepare_to_suspend) {
_DBG("[__SUSPEND__] pause case");
ui->prepare_to_suspend(ui);
}
-#endif
}
/* TODO : rotation stop */
/* r = appcore_pause_rotation_cb(); */
case AE_RESUME:
LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]",
ui->name);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- if (ui->exit_from_suspend) {
- _DBG("[__SUSPEND__] resume case");
- ui->exit_from_suspend(ui);
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+ if (ui->exit_from_suspend) {
+ _DBG("[__SUSPEND__] resume case");
+ ui->exit_from_suspend(ui);
+ }
+ if (ui->app_core->allowed_bg)
+ __appcore_timer_del(ui);
}
- if (ui->app_core->allowed_bg)
- __appcore_timer_del(ui);
-#endif
if (ui->state == AS_PAUSED || ui->state == AS_CREATED) {
_DBG("[APP %d] RESUME", _pid);
{
int r;
char *hwacc = NULL;
-#if _APPFW_FEATURE_BACKGROUND_MANAGEMENT
struct appcore *ac = NULL;
-#endif
bundle *b;
const char *bg_launch;
r = appcore_init(ui->name, &efl_ops, *argc, *argv);
_retv_if(r == -1, -1);
-#if _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- appcore_get_app_core(&ac);
- ui->app_core = ac;
- SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: #%x", ac);
-#endif
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+ appcore_get_app_core(&ac);
+ ui->app_core = ac;
+ SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: #%x", ac);
+ }
b = bundle_import_from_argv(*argc, *argv);
if (b) {
ui->rot_cb_data = NULL;
ui->rot_mode = APPCORE_RM_UNKNOWN;
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- ui->app_core = NULL;
- ui->prepare_to_suspend = __appcore_efl_prepare_to_suspend;
- ui->exit_from_suspend = __appcore_efl_exit_from_suspend;
-#endif
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+ ui->app_core = NULL;
+ ui->prepare_to_suspend = __appcore_efl_prepare_to_suspend;
+ ui->exit_from_suspend = __appcore_efl_exit_from_suspend;
+ }
return 0;
}
return 0;
}
#endif
+
+tizen_profile_t _get_tizen_profile()
+{
+ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return 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 unTIZEN_nown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}
#include <aul.h>
#include <bundle_internal.h>
#include "appcore-internal.h"
+#include <system_info.h>
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
#include <gio/gio.h>
#define RESOURCED_FREEZER_PATH "/Org/Tizen/Resourced/Freezer"
int __appcore_init_suspend_dbus_handler(void *data);
void __appcore_fini_suspend_dbus_handler(void);
-#endif
#define SQLITE_FLUSH_MAX (1024*1024)
},
};
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
static GDBusConnection *bus;
static guint __suspend_dbus_handler_initialized;
-#endif
static int __get_locale_resource_dir(char *locale_dir, int size)
{
return 0;
}
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
static gboolean __flush_memory(gpointer data)
{
int suspend = APPCORE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
ac->tid = 0;
}
}
-#endif
static int __aul_handler(aul_type type, bundle *b, void *data)
{
const char **tep_path = NULL;
int len = 0;
int i;
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
const char *bg = NULL;
struct appcore *ac = data;
int suspend = APPCORE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
-#endif
switch (type) {
case AUL_START:
}
}
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
- if (bg && strncmp(bg, "ALLOWED_BG", strlen("ALLOWED_BG")) == 0) {
- _DBG("[__SUSPEND__] allowed background");
- ac->allowed_bg = true;
- __remove_suspend_timer(data);
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+ bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
+ if (bg && strncmp(bg, "ALLOWED_BG", strlen("ALLOWED_BG")) == 0) {
+ _DBG("[__SUSPEND__] allowed background");
+ ac->allowed_bg = true;
+ __remove_suspend_timer(data);
+ }
}
-#endif
__app_reset(data, b);
break;
case AUL_RESUME:
_DBG("[APP %d] AUL event: AUL_RESUME", _pid);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
- if (bg && strncmp(bg, "ALLOWED_BG", strlen("ALLOWED_BG")) == 0) {
- _DBG("[__SUSPEND__] allowed background");
- ac->allowed_bg = true;
- __remove_suspend_timer(data);
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+ bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
+ if (bg && strncmp(bg, "ALLOWED_BG", strlen("ALLOWED_BG")) == 0) {
+ _DBG("[__SUSPEND__] allowed background");
+ ac->allowed_bg = true;
+ __remove_suspend_timer(data);
+ }
}
-#endif
if (open.callback) {
ret = open.callback(open.cbdata);
break;
case AUL_TERMINATE:
_DBG("[APP %d] AUL event: AUL_TERMINATE", _pid);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- if (!ac->allowed_bg)
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && !ac->allowed_bg)
__remove_suspend_timer(data);
-#endif
__app_terminate(data);
break;
case AUL_TERMINATE_BGAPP:
_DBG("[APP %d] AUL event: AUL_TERMINATE_BGAPP", _pid);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- if (!ac->allowed_bg)
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && !ac->allowed_bg)
__remove_suspend_timer(data);
-#endif
__bgapp_terminate(data);
break;
_DBG("[APP %d] AUL event: AUL_PAUSE", _pid);
__app_pause(data);
break;
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
case AUL_WAKE:
- _DBG("[APP %d] AUL event: AUL_WAKE", _pid);
- if (!ac->allowed_bg && ac->suspended_state) {
- __remove_suspend_timer(data);
- __sys_do(ac, &suspend, SE_SUSPENDED_STATE);
- ac->suspended_state = false;
- }
-
- if (b) {
- bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
- if (bg && strcmp(bg, "ALLOWED_BG") == 0) {
- _DBG("[__SUSPEND__] allowed background");
- ac->allowed_bg = true;
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+ _DBG("[APP %d] AUL event: AUL_WAKE", _pid);
+ if (!ac->allowed_bg && ac->suspended_state) {
+ __remove_suspend_timer(data);
+ __sys_do(ac, &suspend, SE_SUSPENDED_STATE);
+ ac->suspended_state = false;
+ }
+ if (b) {
+ bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
+ if (bg && strcmp(bg, "ALLOWED_BG") == 0) {
+ _DBG("[__SUSPEND__] allowed background");
+ ac->allowed_bg = true;
+ }
}
+ break;
}
- break;
+ goto __default__;
case AUL_SUSPEND:
- _DBG("[APP %d] AUL event: AUL_SUSPEND", _pid);
- ac->allowed_bg = false;
- if (!ac->suspended_state) {
- __remove_suspend_timer(data);
- __flush_memory((gpointer)ac);
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+ _DBG("[APP %d] AUL event: AUL_SUSPEND", _pid);
+ ac->allowed_bg = false;
+ if (!ac->suspended_state) {
+ __remove_suspend_timer(data);
+ __flush_memory((gpointer)ac);
+ }
+ break;
}
- break;
-#endif
+ goto __default__;
case AUL_UPDATE_REQUESTED:
_DBG("[APP %d] AUL event: AUL_UPDATE_REQUESTED", _pid);
__app_update_requested(data);
break;
+__default__:
default:
_DBG("[APP %d] AUL event: %d", _pid, type);
/* do nothing */
return 0;
}
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
static gboolean __init_suspend(gpointer data)
{
int r;
return FALSE;
}
-#endif
EXPORT_API int appcore_init(const char *name, const struct ui_ops *ops,
int argc, char **argv)
_pid = getpid();
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- g_idle_add(__init_suspend, NULL);
-#endif
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT)
+ g_idle_add(__init_suspend, NULL);
return 0;
err:
if (core.state) {
__del_vconf_list();
__clear(&core);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
- __remove_suspend_timer(&core);
- __appcore_fini_suspend_dbus_handler();
-#endif
+ if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+ __remove_suspend_timer(&core);
+ __appcore_fini_suspend_dbus_handler();
+ }
}
aul_finalize();
}
return 0;
}
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
static void __suspend_dbus_signal_handler(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
g_object_unref(bus);
bus = NULL;
}
-#endif
+tizen_profile_t _get_tizen_profile()
+{
+ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return 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 unTIZEN_nown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}