#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;
+}