#include <aul.h>
#include <bundle_internal.h>
#include <sensor_internal.h>
+#include <ttrace.h>
+#include <system_info.h>
#include "appcore_base.h"
#include "appcore_base_private.h"
static char *__locale_dir;
static appcore_base_rotation __rotation;
+appcore_base_tizen_profile_t appcore_base_get_tizen_profile(void)
+{
+ static appcore_base_tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+ char *profile_name = NULL;
+
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return profile;
+
+ system_info_get_platform_string("http://tizen.org/feature/profile",
+ &profile_name);
+ if (profile_name == NULL)
+ return profile;
+
+ switch (*profile_name) {
+ 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:
+ profile = TIZEN_PROFILE_COMMON;
+ break;
+ }
+ free(profile_name);
+
+ return profile;
+}
+
+
static void __invoke_callback(void *event, int type)
{
GList *iter = __events;
if (lang == NULL)
return list;
+ list = g_list_append(list, strdup(lang));
+
extract_lang = __get_string_before(lang, ".");
if (extract_lang == NULL)
return list;
setenv("LC_MESSAGES", lang, 1);
r = setlocale(LC_ALL, "");
if (r == NULL) {
- r = setlocale(LC_ALL, lang);
+ r = setlocale(LC_ALL, "en_US.UTF-8");
if (r != NULL)
_DBG("*****appcore setlocale=%s\n", r);
}
static void __on_region_change(keynode_t *key, void *data)
{
- char *val = NULL;
+ char *val;
const char *name;
name = vconf_keynode_get_name(key);
- if (name && !strcmp(name, VCONFKEY_REGIONFORMAT))
- val = vconf_keynode_get_str(key);
+ if (name == NULL)
+ return;
+
+ if (strcmp(name, VCONFKEY_REGIONFORMAT) &&
+ strcmp(name, VCONFKEY_REGIONFORMAT_TIME1224))
+ return;
+
+ val = vconf_get_str(VCONFKEY_REGIONFORMAT);
__update_region();
__invoke_callback((void *)val, APPCORE_BASE_EVENT_REGION_CHANGE);
+ free(val);
}
static gboolean __flush_memory(gpointer data)
static int __set_i18n(const char *domain, const char *dir)
{
char *r;
- char *lan;
if (domain == NULL) {
errno = EINVAL;
__update_region();
r = setlocale(LC_ALL, "");
- /* if locale is not set properly, try again to set as language base */
+ /* if locale is not set properly, try to set "en_US" again */
if (r == NULL) {
- lan = vconf_get_str(VCONFKEY_LANGSET);
- if (lan != NULL) {
- r = setlocale(LC_ALL, lan);
- _DBG("*****appcore setlocale=%s\n", r);
- free(lan);
- }
+ r = setlocale(LC_ALL, "en_US.UTF-8");
+ _DBG("*****appcore setlocale=%s\n", r);
}
if (r == NULL)
_ERR("appcore: setlocale() error");
char *name = NULL;
r = aul_app_get_appid_bypid(getpid(), appid, PATH_MAX);
- if (r < 0)
+ if (r < 0) {
+ _ERR("Failed to get application ID - pid(%d)", getpid());
return -1;
+ }
r = __get_app_name(appid, &name);
if (r < 0)
EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, void *data)
{
int i;
+ int r;
__context.ops = ops;
__context.argc = argc;
__context.suspended_state = false;
__context.allowed_bg = false;
+ if (__context.ops.init)
+ __context.ops.init(argc, argv, data);
+
if (__context.ops.set_i18n)
__context.ops.set_i18n(__context.data);
- __init_suspend_dbus_handler();
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT)
+ __init_suspend_dbus_handler();
if (!__context.dirty) {
__context.dirty = true;
}
}
- if (__context.ops.create && __context.ops.create(__context.data) < 0) {
- aul_status_update(STATUS_DYING);
- return 0;
+ if (__context.ops.create) {
+ traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:CREATE");
+ r = __context.ops.create(__context.data);
+ traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
+ if (r < 0) {
+ aul_status_update(STATUS_DYING);
+ return 0;
+ }
}
if (__context.ops.run)
int i;
aul_status_update(STATUS_DYING);
- if (__context.ops.terminate)
+ if (__context.ops.terminate) {
+ traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:TERMINATE");
__context.ops.terminate(__context.data);
+ traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
+ }
for (i = APPCORE_BASE_EVENT_START + 1; i < APPCORE_BASE_EVENT_MAX; i++) {
if (__exist_callback(i)) {
g_list_free_full(__events, free);
__events = NULL;
- __fini_suspend_dbus_handler();
+
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT)
+ __fini_suspend_dbus_handler();
if (__locale_dir) {
free(__locale_dir);
}
__context.dirty = false;
+
+ if (__context.ops.finish)
+ __context.ops.finish();
}
EXPORT_API int appcore_base_flush_memory(void)
}
}
- bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
- if (bg && strncmp(bg, "ALLOWED_BG", strlen("ALLOWED_BG")) == 0) {
- _DBG("[__SUSPEND__] allowed background");
- __context.allowed_bg = true;
- __remove_suspend_timer();
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+ bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
+ if (bg && !strcmp(bg, "ALLOWED_BG")) {
+ _DBG("[__SUSPEND__] allowed background");
+ __context.allowed_bg = true;
+ __remove_suspend_timer();
+ }
}
- if (__context.ops.control)
- __context.ops.control(b, __context.data);
+ if (__context.ops.control) {
+ traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:RESET");
+ __context.ops.control(b, __context.data);
+ traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
+ }
break;
case AUL_RESUME:
_DBG("[APP %d] AUL event: AUL_RESUME", getpid());
- bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
- if (bg && strncmp(bg, "ALLOWED_BG", strlen("ALLOWED_BG")) == 0) {
- _DBG("[__SUSPEND__] allowed background");
- __context.allowed_bg = true;
- __remove_suspend_timer();
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+ bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
+ if (bg && !strcmp(bg, "ALLOWED_BG")) {
+ _DBG("[__SUSPEND__] allowed background");
+ __context.allowed_bg = true;
+ __remove_suspend_timer();
+ }
}
break;
case AUL_TERMINATE:
break;
case AUL_WAKE:
_DBG("[APP %d] AUL event: AUL_WAKE", getpid());
- if (!__context.allowed_bg && __context.suspended_state) {
- int suspend = APPCORE_BASE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
- __remove_suspend_timer();
- __invoke_callback((void *)&suspend, APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE);
- __context.suspended_state = false;
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+ if (!__context.allowed_bg &&
+ __context.suspended_state) {
+ int suspend = APPCORE_BASE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
+ __remove_suspend_timer();
+ __invoke_callback((void *)&suspend, APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE);
+ __context.suspended_state = false;
+ }
}
break;
case AUL_SUSPEND:
_DBG("[APP %d] AUL event: AUL_SUSPEND", getpid());
- if (!__context.allowed_bg && !__context.suspended_state) {
- __remove_suspend_timer();
- __flush_memory(NULL);
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+ if (!__context.allowed_bg &&
+ !__context.suspended_state) {
+ __remove_suspend_timer();
+ __flush_memory(NULL);
+ }
}
break;
case AUL_UPDATE_REQUESTED:
EXPORT_API int appcore_base_on_terminate()
{
aul_finalize();
- if (__context.ops.exit)
- __context.ops.exit(__context.data);
return 0;
}
__context.suspended_state ^= __context.suspended_state;
}
+EXPORT_API void appcore_base_exit(void)
+{
+ if (__context.ops.exit)
+ __context.ops.exit(__context.data);
+}
+
static int __on_receive(aul_type type, bundle *b, void *data)
{
return appcore_base_on_receive(type, b);
ops.terminate = __on_terminate;
ops.receive = __on_receive;
ops.set_i18n = __on_set_i18n;
+ ops.init = NULL;
+ ops.finish = NULL;
ops.run = NULL;
ops.exit = NULL;
ops.set_event = __on_set_event;
return ops;
}
-
-