BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(capi-appfw-app-control)
BuildRequires: pkgconfig(capi-appfw-app-common)
+BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(appcore-common)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(ecore)
%description
Service Application basic
-%if "%{?profile}" == "wearable"
-%define tizen_feature_background_management 1
-%else
-%if "%{?profile}" == "mobile"
-%define tizen_feature_background_management 1
-%else
-%if "%{?profile}" == "tv"
-%define tizen_feature_background_management 0
-%endif
-%endif
-%endif
-
%package devel
Summary: Application Core Agent
Group: Application Framework/Development
%build
-%if 0%{?tizen_feature_background_management}
-_TIZEN_FEATURE_BACKGROUND_MANAGEMENT=ON
-%endif
-
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
%cmake -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
- -D_TIZEN_FEATURE_BACKGROUND_MANAGEMENT:BOOL=${_TIZEN_FEATURE_BACKGROUND_MANAGEMENT} \
.
%__make %{?_smp_mflags}
#include <app_control_internal.h>
#include <dlog.h>
#include <vconf.h>
+#include <system_info.h>
#include "appcore-agent.h"
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
#include <gio/gio.h>
#define RESOURCED_FREEZER_PATH "/Org/Tizen/Resourced/Freezer"
#define APPFW_SUSPEND_HINT_INTERFACE "org.tizen.appfw.SuspendHint"
#define APPFW_SUSPEND_HINT_SIGNAL "SuspendHint"
-#endif
-
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define APPID_MAX 256
#define PATH_LOCALE "locale"
+
+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;
+
+static tizen_profile_t _get_tizen_profile()
+{
+ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+ char *profileName;
+
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return profile;
+
+ 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 unknown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}
+#define TIZEN_FEATURE_BACKGROUND_MANAGEMENT (_get_tizen_profile() & (TIZEN_PROFILE_MOBILE | TIZEN_PROFILE_WEARABLE))
+
static pid_t _pid;
/**
},
};
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
static GDBusConnection *bus = NULL;
static guint __suspend_dbus_handler_initialized = 0;
-#endif
extern int app_control_create_event(bundle *data, struct app_control_s **app_control);
static int __sys_do(struct agent_appcore *ac, void *event_info, enum sys_event event);
/* LCOV_EXCL_START */
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
static int appcore_agent_flush_memory(void)
{
int (*flush_fn) (int);
ac->suspended_state = true;
}
}
-#endif
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
static void __exit_from_suspend(void *data)
{
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
- int suspend = APPCORE_AGENT_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
- struct agent_appcore *ac = data;
-
- if (ac && !ac->allowed_bg && ac->suspended_state) {
- _DBG("[__SUSPEND__]");
- __sys_do(ac, &suspend, SE_SUSPENDED_STATE);
- ac->suspended_state = false;
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+ int suspend = APPCORE_AGENT_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
+ struct agent_appcore *ac = data;
+
+ if (ac && !ac->allowed_bg && ac->suspended_state) {
+ _DBG("[__SUSPEND__]");
+ __sys_do(ac, &suspend, SE_SUSPENDED_STATE);
+ ac->suspended_state = false;
+ }
}
-#endif
}
/* LCOV_EXCL_START */
/* LCOV_EXCL_START */
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
static gboolean __flush_memory(gpointer data)
{
struct agent_appcore *ac = (struct agent_appcore *)data;
__prepare_to_suspend(ac);
return FALSE;
}
-#endif
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
static void __add_suspend_timer(struct agent_appcore *ac)
{
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
- ac->tid = g_timeout_add_seconds(5, __flush_memory, ac);
-#endif
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT)
+ ac->tid = g_timeout_add_seconds(5, __flush_memory, ac);
}
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
static void __remove_suspend_timer(struct agent_appcore *ac)
{
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
- if (ac->tid > 0) {
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT && ac->tid > 0) {
g_source_remove(ac->tid);
ac->tid = 0;
}
-#endif
}
/* LCOV_EXCL_STOP */
return r;
}
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
static gboolean __init_suspend(gpointer data)
{
int r;
return FALSE;
}
-#endif
static int __get_locale_resource_dir(char *locale_dir, int size)
{
free(app_name);
_retv_if(r == -1, -1);
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
- g_idle_add(__init_suspend, NULL);
-#endif
+ if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT)
+ g_idle_add(__init_suspend, NULL);
r = aul_launch_init(__aul_handler, &core);
if (r < 0)
}
/* LCOV_EXCL_START */
-#ifdef TIZEN_FEATURE_BACKGROUND_MANAGEMENT
static void __suspend_dbus_signal_handler(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
return 0;
}
-
-#endif