summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghoon Park <jh9216.park@samsung.com>2015-12-02 09:43:22 +0900
committerJunghoon Park <jh9216.park@samsung.com>2015-12-02 09:43:22 +0900
commitcaa33930a3ec017ca3fbf986facfbfa07071bad3 (patch)
tree11ee0146da5b0bf0a2aa8c141ac84dc1bdeacde3
parent04f6d00b87471ef4d9c014e5f0ab2337fc31870f (diff)
downloadaul-1-caa33930a3ec017ca3fbf986facfbfa07071bad3.tar.gz
aul-1-caa33930a3ec017ca3fbf986facfbfa07071bad3.tar.bz2
aul-1-caa33930a3ec017ca3fbf986facfbfa07071bad3.zip
Change-Id: I52042baad1dd983e982cdef95ceca8feac60561f Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r--am_daemon/amd_launch.c88
-rw-r--r--am_daemon/amd_launch.h3
-rw-r--r--am_daemon/amd_request.c2
-rw-r--r--include/app_sock.h3
-rw-r--r--include/aul.h2
5 files changed, 43 insertions, 55 deletions
diff --git a/am_daemon/amd_launch.c b/am_daemon/amd_launch.c
index 2a2b9463..d7e1e0f9 100644
--- a/am_daemon/amd_launch.c
+++ b/am_daemon/amd_launch.c
@@ -74,6 +74,8 @@ typedef struct {
char *pkg_type;
} app_info_from_pkgmgr;
+static int __pid_of_last_launched_ui_app;
+
static void __set_reply_handler(int fd, int pid, int clifd, int cmd);
static void __real_send(int clifd, int ret);
static int __nofork_processing(int cmd, int pid, bundle * kb, int clifd);
@@ -90,52 +92,8 @@ static void __set_stime(bundle *kb)
int _start_app_local_with_bundle(uid_t uid, const char *appid, bundle *kb)
{
- int ret;
- int pid;
- const struct appinfo *ai;
- const char *app_path;
- const char *pkg_type;
- const char *pkg_id;
- const char *hwacc;
- const char *process_pool;
- char tmpbuf[MAX_PID_STR_BUFSZ];
-
- snprintf(tmpbuf, sizeof(tmpbuf), "%d", getpid());
- bundle_add_str(kb, AUL_K_CALLER_PID, tmpbuf);
- snprintf(tmpbuf, sizeof(tmpbuf), "%d", uid);
- bundle_add_str(kb, AUL_K_CALLER_UID, tmpbuf);
- bundle_add_str(kb, AUL_K_APPID, appid);
-
- pid = _status_app_is_running(appid, uid);
- if (pid > 0) {
- ret = __nofork_processing(APP_START, pid, kb, -1);
- return ret;
- }
-
- ai = appinfo_find(uid, appid);
- if (ai == NULL) {
- _E("cannot find appinfo of %s", appid);
- return -1;
- }
-
- hwacc = appinfo_get_value(ai, AIT_HWACC);
- app_path = appinfo_get_value(ai, AIT_EXEC);
- pkg_type = appinfo_get_value(ai, AIT_TYPE);
- pkg_id = appinfo_get_value(ai, AIT_PKGID);
- process_pool = appinfo_get_value(ai, AIT_POOL);
-
__set_stime(kb);
- bundle_add_str(kb, AUL_K_HWACC, hwacc);
- bundle_add_str(kb, AUL_K_EXEC, app_path);
- bundle_add_str(kb, AUL_K_PACKAGETYPE, pkg_type);
- bundle_add_str(kb, AUL_K_PKGID, pkg_id);
- bundle_add_str(kb, AUL_K_INTERNAL_POOL, process_pool);
-
- pid = app_agent_send_cmd(uid, APP_START, kb);
- if (pid > 0)
- _status_add_app_info_list(appid, app_path, pid, LAUNCHPAD_PID, uid);
-
- return pid;
+ return _start_app(appid, kb, APP_START, getpid(), uid, -1);
}
int _start_app_local(uid_t uid, const char *appid)
@@ -737,11 +695,32 @@ static int __check_app_control_privilege(int fd, const char *operation)
return 0;
}
+int _send_hint_for_visibility(uid_t uid)
+{
+ bundle *b = NULL;
+ int ret;
+
+ b = bundle_create();
+
+ ret = app_agent_send_cmd(uid, PAD_CMD_VISIBILITY, b);
+
+ if (b)
+ bundle_free(b);
+ __pid_of_last_launched_ui_app = 0;
+
+ return ret;
+}
+
+int _get_pid_of_last_launched_ui_app()
+{
+ return __pid_of_last_launched_ui_app;
+}
+
int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
uid_t caller_uid, int fd)
{
+ int ret;
const struct appinfo *ai;
- int ret = -1;
const char *status;
const char *multiple = NULL;
const char *app_path = NULL;
@@ -756,11 +735,10 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
const char *hwacc;
char *caller_appid;
int delay_reply = 0;
- int pad_pid = LAUNCHPAD_PID;
int lpid;
int callee_status = -1;
- gboolean can_attach;
- gboolean new_process;
+ gboolean can_attach = FALSE;
+ gboolean new_process = FALSE;
app_group_launch_mode launch_mode;
snprintf(tmpbuf, MAX_PID_STR_BUFSZ, "%d", caller_pid);
@@ -849,7 +827,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
else
delay_reply = 1;
}
- } else if (cmd != APP_RESUME) {
+ } else {
if (callee_status == STATUS_DYING && pid > 0) {
ret = kill(pid, SIGKILL);
if (ret == -1)
@@ -862,23 +840,23 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
bundle_add(kb, AUL_K_PACKAGETYPE, pkg_type);
bundle_add(kb, AUL_K_PKGID, pkg_id);
bundle_add(kb, AUL_K_INTERNAL_POOL, process_pool);
+ bundle_add(kb, AUL_K_COMP_TYPE, component_type);
pid = app_agent_send_cmd(caller_uid, cmd, kb);
+ }
+ if (pid > 0) {
+ _status_add_app_info_list(appid, app_path, pid, LAUNCHPAD_PID, caller_uid);
if (strncmp(component_type, APP_TYPE_UI, strlen(APP_TYPE_UI)) == 0) {
if (new_process) {
_D("add app group info");
+ __pid_of_last_launched_ui_app = pid;
app_group_start_app(pid, kb, lpid, can_attach, launch_mode);
} else {
app_group_restart_app(pid, kb);
}
}
- } else {
- _E("Unknown application: %s", appid);
}
- if (pid > 0)
- _status_add_app_info_list(appid, app_path, pid, pad_pid, caller_uid);
-
if (!delay_reply)
__real_send(fd, pid);
diff --git a/am_daemon/amd_launch.h b/am_daemon/amd_launch.h
index 212124d8..5c57d20a 100644
--- a/am_daemon/amd_launch.h
+++ b/am_daemon/amd_launch.h
@@ -37,5 +37,8 @@ int _fake_launch_app(int cmd, int pid, bundle * kb, int clifd);
int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_uid, int fd);
int _start_app_local(uid_t uid, const char *appid);
int _start_app_local_with_bundle(uid_t uid, const char *appid, bundle *kb);
+int _get_pid_of_last_launched_ui_app();
+int _send_hint_for_visibility(uid_t uid);
+
#endif /* __AUL_AMD_LAUNCH_H_ */
diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c
index 80f4f5d9..637c78be 100644
--- a/am_daemon/amd_request.c
+++ b/am_daemon/amd_request.c
@@ -888,6 +888,8 @@ static int __dispatch_app_status_update(int clifd, const app_pkt_t *pkt, struct
ai = appinfo_find(cr->uid, appid);
appinfo_set_value((struct appinfo *)ai, AIT_STATUS, "norestart");
} else {
+ if (*status == STATUS_VISIBLE && cr->pid == _get_pid_of_last_launched_ui_app())
+ _send_hint_for_visibility(cr->uid);
_status_update_app_info_list(cr->pid, *status, cr->uid);
}
close(clifd);
diff --git a/include/app_sock.h b/include/app_sock.h
index ed3866eb..d9a4594f 100644
--- a/include/app_sock.h
+++ b/include/app_sock.h
@@ -87,6 +87,9 @@ enum app_cmd {
#define ENOLAUNCHPAD 125
#define EREJECTED 123
+#define PAD_CMD_LAUNCH 0
+#define PAD_CMD_VISIBILITY 10
+
typedef struct _app_pkt_t {
int cmd;
int len;
diff --git a/include/aul.h b/include/aul.h
index 163bd013..981b7023 100644
--- a/include/aul.h
+++ b/include/aul.h
@@ -155,6 +155,8 @@ typedef enum _aul_type{
#define AUL_K_INTERNAL_POOL "__AUL_INTERNAL_POOL__"
/** AUL internal private key */
#define AUL_TEP_PATH "_AUL_TEP_PATH_"
+/** AUL internal private key */
+#define AUL_K_COMP_TYPE "__AUL_COMP_TYPE__"
/**
* @brief This is callback function for aul_launch_init