summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghoon Park <jh9216.park@samsung.com>2015-12-14 19:13:05 +0900
committerJunghoon Park <jh9216.park@samsung.com>2015-12-14 19:55:33 +0900
commit2ff16ea79515b0c7a2dae96389b524923c485a2e (patch)
tree4c221d4ff44663597d11b9d7086de198de3c2f97
parent3829a47083ee911720141ab033e9839c0600ff60 (diff)
downloadaul-1-2ff16ea79515b0c7a2dae96389b524923c485a2e.tar.gz
aul-1-2ff16ea79515b0c7a2dae96389b524923c485a2e.tar.bz2
aul-1-2ff16ea79515b0c7a2dae96389b524923c485a2e.zip
Get information about running apps except for subapps
- add is_subapp in app_status_info_t - modify _status_app_is_running() - modify _status_app_is_running_v2() - remove unused file Change-Id: I5c0a2dc4834f6fb4468fab8f4f44f8aedebbc4b2 Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r--am_daemon/ac_status.c108
-rw-r--r--am_daemon/amd_launch.c11
-rw-r--r--am_daemon/amd_status.c70
-rw-r--r--am_daemon/amd_status.h5
-rw-r--r--include/aul_util.h9
5 files changed, 41 insertions, 162 deletions
diff --git a/am_daemon/ac_status.c b/am_daemon/ac_status.c
deleted file mode 100644
index ec8203b1..00000000
--- a/am_daemon/ac_status.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * aul
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <glib.h>
-#include <aul.h>
-#include "aul_util.h"
-#include "simple_util.h"
-
-GSList *app_status_info_list = NULL;
-
-int _add_app_status_info_list(char *appid, int pid, uid_t uid)
-{
- GSList *iter = NULL;
- app_status_info_t *info_t = NULL;
-
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
- info_t = (app_status_info_t *)iter->data;
- if(pid == info_t->pid) {
- return 0;
- }
- }
-
- info_t = malloc(sizeof(app_status_info_t));
- strncpy(info_t->appid, appid, MAX_PACKAGE_STR_SIZE-1);
- info_t->status = STATUS_LAUNCHING;
- info_t->pid = pid;
- info_t->user = uid;
- app_status_info_list = g_slist_append(app_status_info_list, info_t);
-
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
- info_t = (app_status_info_t *)iter->data;
-
- _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
- }
-
- return 0;
-}
-
-int _update_app_status_info_list(int pid, int status, uid_t uid)
-{
- GSList *iter = NULL;
- app_status_info_t *info_t = NULL;
-
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
- info_t = (app_status_info_t *)iter->data;
- if((pid == info_t->pid) && ((info_t->user == uid) || (info_t->user == 0))) {
- info_t->status = status;
- break;
- }
- }
-
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
- info_t = (app_status_info_t *)iter->data;
-
- _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
- }
-
- return 0;
-}
-
-int _remove_app_status_info_list(int pid, uid_t uid)
-{
- GSList *iter = NULL;
- app_status_info_t *info_t = NULL;
-
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
- info_t = (app_status_info_t *)iter->data;
- if((pid == info_t->pid) && ((info_t->user == uid) || (info_t->user == 0))) {
- app_status_info_list = g_slist_remove(app_status_info_list, info_t);
- free(info_t);
- break;
- }
- }
-
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
- info_t = (app_status_info_t *)iter->data;
-
- _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
- }
-
- return 0;
-}
-
diff --git a/am_daemon/amd_launch.c b/am_daemon/amd_launch.c
index 01811d4c..e46400ba 100644
--- a/am_daemon/amd_launch.c
+++ b/am_daemon/amd_launch.c
@@ -528,7 +528,8 @@ static int __compare_signature(const struct appinfo *ai, int cmd,
}
static int __get_pid_for_app_group(const char *appid, int pid, int caller_uid, bundle* kb,
- int *lpid, gboolean *can_attach, gboolean *new_process, app_group_launch_mode* launch_mode)
+ int *lpid, gboolean *can_attach, gboolean *new_process,
+ app_group_launch_mode* launch_mode, bool *is_subapp)
{
int st = -1;
int found_pid = -1;
@@ -536,6 +537,9 @@ static int __get_pid_for_app_group(const char *appid, int pid, int caller_uid, b
if (app_group_is_group_app(kb)) {
pid = -1;
+ *is_subapp = true;
+ } else {
+ *is_subapp = false;
}
if (pid > 0)
@@ -745,6 +749,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
gboolean new_process = FALSE;
app_group_launch_mode launch_mode;
const char *pad_type = LAUNCHPAD_PROCESS_POOL_SOCK;
+ bool is_subapp = false;
snprintf(tmpbuf, MAX_PID_STR_BUFSZ, "%d", caller_pid);
bundle_add(kb, AUL_K_CALLER_PID, tmpbuf);
@@ -808,7 +813,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
component_type = appinfo_get_value(ai, AIT_COMP);
if (strncmp(component_type, APP_TYPE_UI, strlen(APP_TYPE_UI)) == 0) {
pid = __get_pid_for_app_group(appid, pid, caller_uid, kb,
- &lpid, &can_attach, &new_process, &launch_mode);
+ &lpid, &can_attach, &new_process, &launch_mode, &is_subapp);
if (pid == -EILLEGALACCESS) {
__real_send(fd, pid);
return pid;
@@ -860,7 +865,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
}
if (pid > 0) {
- _status_add_app_info_list(appid, app_path, pid, LAUNCHPAD_PID, caller_uid);
+ _status_add_app_info_list(appid, app_path, pid, LAUNCHPAD_PID, is_subapp, caller_uid);
if (strncmp(component_type, APP_TYPE_UI, strlen(APP_TYPE_UI)) == 0) {
if (new_process) {
_D("add app group info");
diff --git a/am_daemon/amd_status.c b/am_daemon/amd_status.c
index 9a8a415b..162f3875 100644
--- a/am_daemon/amd_status.c
+++ b/am_daemon/amd_status.c
@@ -39,9 +39,20 @@
#include "menu_db_util.h"
#include "amd_app_group.h"
-GSList *app_status_info_list = NULL;
+typedef struct _app_status_info_t{
+ char appid[MAX_PACKAGE_STR_SIZE];
+ char app_path[MAX_PACKAGE_APP_PATH_SIZE];
+ int status;
+ int pid;
+ int pad_pid;
+ bool is_subapp;
+ uid_t uid;
+} app_status_info_t;
+
+static GSList *app_status_info_list = NULL;
-int _status_add_app_info_list(const char *appid, const char *app_path, int pid, int pad_pid, uid_t uid)
+int _status_add_app_info_list(const char *appid, const char *app_path, int pid,
+ int pad_pid, bool is_subapp, uid_t uid)
{
GSList *iter;
GSList *iter_next;
@@ -71,6 +82,7 @@ int _status_add_app_info_list(const char *appid, const char *app_path, int pid,
info_t->status = STATUS_LAUNCHING;
info_t->pid = pid;
info_t->pad_pid = pad_pid;
+ info_t->is_subapp = is_subapp;
info_t->uid = uid;
app_status_info_list = g_slist_append(app_status_info_list, info_t);
@@ -159,7 +171,8 @@ int _status_app_is_running(const char *appid, uid_t uid)
for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter)) {
info_t = (app_status_info_t *)iter->data;
- if ((strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE) == 0) && (info_t->uid == uid))
+ if ((strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE) == 0)
+ && (info_t->uid == uid) && !info_t->is_subapp)
return info_t->pid;
}
@@ -229,6 +242,20 @@ int _status_send_running_appinfo(int fd, uid_t uid)
return 0;
}
+static inline int __find_pid_by_appid(const char *dname, const char *appid,
+ void *priv, uid_t uid)
+{
+ int pid = 0;
+
+ if (strncmp(appid, (char *)priv, MAX_LOCAL_BUFSZ-1) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid) || app_group_is_sub_app(pid))
+ pid = 0;
+ }
+
+ return pid;
+}
+
int _status_app_is_running_v2(const char *appid, uid_t caller_uid)
{
int ret;
@@ -241,7 +268,7 @@ int _status_app_is_running_v2(const char *appid, uid_t caller_uid)
if (ai == NULL)
return -1;
- ret = __proc_iter_appid(NULL, (void *)appid);
+ ret = __proc_iter_appid(__find_pid_by_appid, (void *)appid);
return ret;
}
@@ -276,41 +303,6 @@ static int __get_pkginfo(const char *dname, const char *appid, void *priv, uid_t
return 0;
}
-int _status_send_running_appinfo_v2(int fd)
-{
- app_pkt_t *pkt = NULL;
- int len;
- char buf[AUL_SOCK_MAXBUFF] = {0 ,};
-
- __proc_iter_appid(__get_pkginfo, buf);
- len = strlen(buf);
-
- pkt = (app_pkt_t *)malloc(AUL_PKT_HEADER_SIZE + len);
- if (!pkt) {
- _E("malloc fail");
- close(fd);
- return 0;
- }
-
- pkt->cmd = APP_RUNNING_INFO_RESULT;
- pkt->len = len;
- memcpy(pkt->data, buf, len);
-
- if ((len = send(fd, pkt, pkt->len + AUL_PKT_HEADER_SIZE, 0))
- != pkt->len + AUL_PKT_HEADER_SIZE) {
- if (errno == EPIPE)
- _E("send failed due to EPIPE.\n");
- _E("send fail to client");
- }
-
- if(pkt)
- free(pkt);
-
- close(fd);
-
- return 0;
-}
-
static int __get_appid_bypid(int pid, char *appid, int len)
{
char *result;
diff --git a/am_daemon/amd_status.h b/am_daemon/amd_status.h
index a7bd5811..f4a6e7a8 100644
--- a/am_daemon/amd_status.h
+++ b/am_daemon/amd_status.h
@@ -22,8 +22,9 @@
#include <unistd.h>
#include <sys/types.h>
#include <glib.h>
+#include <stdbool.h>
-int _status_add_app_info_list(const char *appid, const char *app_path, int pid, int pad_pid, uid_t uid);
+int _status_add_app_info_list(const char *appid, const char *app_path, int pid, int pad_pid, bool is_subapp, uid_t uid);
int _status_update_app_info_list(int pid, int status, uid_t uid);
int _status_remove_app_info_list_with_uid(uid_t uid);
int _status_remove_app_info_list(int pid, uid_t uid);
@@ -32,12 +33,10 @@ int _status_send_running_appinfo(int fd, uid_t uid);
int _status_app_is_running(const char *appid, uid_t uid);
int _status_app_is_running_v2(const char *appid, uid_t caller_uid);
char *_status_app_get_appid_bypid(int pid);
-int _status_send_running_appinfo_v2(int fd); //depcrecated
int _status_get_appid_bypid(int fd, int pid);
int _status_get_pkgid_bypid(int fd, int pid);
int _status_init(void);
-
//TODO : remove
typedef struct _item_pkt_t {
diff --git a/include/aul_util.h b/include/aul_util.h
index 3f9bac9e..99609d6d 100644
--- a/include/aul_util.h
+++ b/include/aul_util.h
@@ -41,15 +41,6 @@
l = l_next, \
l_next = g_slist_next(l))
-typedef struct _app_status_info_t{
- char appid[MAX_PACKAGE_STR_SIZE];
- char app_path[MAX_PACKAGE_APP_PATH_SIZE];
- int status;
- int pid;
- int pad_pid;
- uid_t uid;
-} app_status_info_t;
-
int _add_app_status_info_list(char *appid, int pid, uid_t uid);
int _update_app_status_info_list(int pid, int status, uid_t uid);
int _remove_app_status_info_list(int pid, uid_t uid);