AMD_BACKGROUND_CATEGORY_SYSTEM = 0x40
};
+bool amd_suspend_is_excluded(int pid);
bool amd_suspend_is_allowed_background(amd_appinfo_h ai);
void amd_suspend_add_timer(int pid);
void amd_suspend_remove_timer(int pid);
BACKGROUND_CATEGORY_SYSTEM = 0x40
};
+int _suspend_exclude(int pid);
+int _suspend_include(int pid);
+bool _suspend_is_excluded(int pid);
bool _suspend_is_allowed_background(const struct appinfo *ai);
void _suspend_add_timer(int pid);
void _suspend_remove_timer(int pid);
const char *appid;
const char *pkgid;
bool bg_allowed;
+ bool excluded;
uid_t uid;
app_status = amd_app_status_find_by_effective_pid(pid);
pkgid = amd_appinfo_get_value(ai, AMD_AIT_PKGID);
bg_allowed = amd_suspend_is_allowed_background(ai);
+ excluded = amd_suspend_is_excluded(pid);
LOGD("Send %s signal %s", flag ? "FG" : "BG", appid);
aul_send_app_status_change_signal(pid, appid, pkgid,
flag ? STATUS_FOREGROUND : STATUS_BACKGROUND,
APP_TYPE_UI);
- if (!bg_allowed) {
+ if (!excluded && !bg_allowed) {
amd_app_status_find_service_apps(app_status,
flag ? STATUS_VISIBLE : STATUS_BG,
flag ? __prepare_to_wake : __prepare_to_suspend,
const char *taskmanage;
const char *appid;
bool bg_allowed;
+ bool excluded;
GList *iter;
uid_t uid;
ai = amd_appinfo_find(uid, appid);
taskmanage = amd_appinfo_get_value(ai, AMD_AIT_TASKMANAGE);
bg_allowed = amd_suspend_is_allowed_background(ai);
- if (taskmanage && !strcmp(taskmanage, "false") && !bg_allowed) {
+ excluded = amd_suspend_is_excluded(group->leader_pid);
+ if (taskmanage && !strcmp(taskmanage, "false") &&
+ !bg_allowed && !excluded) {
SECURE_LOGW("Terminate leader app(%s:%d)",
appid, group->leader_pid);
aul_send_app_terminate_request_signal(group->leader_pid,
const struct appinfo *ai;
struct app_status_s *svc_status;
bool bg_allowed;
+ bool excluded;
uid_t uid;
if (app_status == NULL) {
if (svc_status && svc_status->uid == uid) {
ai = _appinfo_find(uid, svc_status->appid);
bg_allowed = _suspend_is_allowed_background(ai);
- if (!bg_allowed) {
+ excluded = _suspend_is_excluded(svc_status->pid);
+ if (!excluded && !bg_allowed) {
send_event_to_svc_core(svc_status->pid, uid);
if (svc_status->status != STATUS_DYING &&
suspend)
struct app_status_s *ui_status;
int ui_cnt = 0;
bool bg_allowed;
+ bool excluded;
const char *appid;
const struct appinfo *ai;
uid_t uid;
status = _app_status_get_status(app_status);
ai = _appinfo_find(uid, appid);
bg_allowed = _suspend_is_allowed_background(ai);
- if (!bg_allowed && status != STATUS_DYING) {
+ excluded = _suspend_is_excluded(app_status->pid);
+ if (!excluded && !bg_allowed && status != STATUS_DYING) {
send_event_to_svc_core(app_status->pid, uid);
_suspend_add_timer(app_status->pid);
}
_app_status_update_status(app_status, STATUS_BG, false, true);
appid = _app_status_get_appid(app_status);
ai = _appinfo_find(uid, appid);
- if (!_suspend_is_allowed_background(ai)) {
+ if (!_suspend_is_excluded(pid) &&
+ !_suspend_is_allowed_background(ai)) {
__prepare_to_suspend(pid, uid);
_suspend_add_timer(pid);
}
_util_save_log("LAUNCHING", handle->appid);
if (handle->debug_mode) {
_W("Exclude - %s(%d)", handle->appid, handle->pid);
- aul_update_freezer_status(handle->pid, "exclude");
+ _suspend_exclude(handle->pid);
return ret;
}
if (handle->bg_category == BACKGROUND_CATEGORY_BACKGROUND_NETWORK) {
if (!handle->bg_allowed)
- aul_update_freezer_status(handle->pid, "include");
+ _suspend_include(handle->pid);
}
if (comp_type && !strcmp(comp_type, APP_TYPE_SERVICE)) {
typedef struct proc_info {
pid_t pid;
guint timer_id;
+ int ex_ref;
} proc_info_t;
typedef struct network_info {
static network_info_t __net_info;
static guint __init_timer;
+static proc_info_t *__create_proc_info(int pid);
+static proc_info_t *__find_proc_info(int pid);
+
+int _suspend_exclude(int pid)
+{
+ proc_info_t *info;
+ int ret;
+
+ info = __find_proc_info(pid);
+ if (!info)
+ info = __create_proc_info(pid);
+
+ info->ex_ref++;
+ if (info->ex_ref == 1) {
+ ret = aul_update_freezer_status(pid, "exclude");
+ _W("[__SUSPEND__] Exclude pid(%d), result(%d)", pid, ret);
+ }
+
+ return 0;
+}
+
+int _suspend_include(int pid)
+{
+ proc_info_t *info;
+ int ret;
+
+ info = __find_proc_info(pid);
+ if (!info)
+ info = __create_proc_info(pid);
+
+ if (info->ex_ref > 0)
+ info->ex_ref--;
+
+ if (info->ex_ref == 0) {
+ ret = aul_update_freezer_status(pid, "include");
+ _W("[__SUSPEND__] Include pid(%d), result(%d)", pid, ret);
+ }
+
+ return 0;
+}
+
+bool _suspend_is_excluded(int pid)
+{
+ proc_info_t *info;
+
+ info = __find_proc_info(pid);
+ if (info)
+ return (info->ex_ref > 0) ? true : false;
+
+ return false;
+}
+
static void __destroy_proc_info_value(gpointer data)
{
proc_info_t *proc = (proc_info_t *)data;
__prepare_to_wake(pid, uid);
_app_status_find_service_apps(app_status, status,
__prepare_to_wake, false);
- aul_update_freezer_status(pid, "exclude");
+ _suspend_exclude(pid);
}
static void __suspend_bg_apps(app_status_h app_status, void *data)
__prepare_to_suspend, true);
__prepare_to_suspend(pid, uid);
_suspend_add_timer(pid);
- aul_update_freezer_status(pid, "include");
+ _suspend_include(pid);
}
static gboolean __handle_bg_network_apps(gpointer data)
return NULL;
}
- proc = (proc_info_t *)malloc(sizeof(proc_info_t));
+ proc = (proc_info_t *)calloc(1, sizeof(proc_info_t));
if (proc == NULL) {
_E("insufficient memory");
return NULL;
return _suspend_remove_proc(pid);
}
+EXPORT_API bool amd_suspend_is_excluded(int pid)
+{
+ return _suspend_is_excluded(pid);
+}
+
EXPORT_API bool amd_suspend_is_allowed_background(amd_appinfo_h ai)
{
return _suspend_is_allowed_background(ai);