summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyunho kang <hhstark.kang@samsung.com>2015-11-17 11:58:46 +0900
committerhyunho kang <hhstark.kang@samsung.com>2015-11-17 15:32:25 +0900
commitbed7161b19960cf65f7bcca65847e3de5e1975dc (patch)
treee0f1fff607cafefb0c9da51a4907d9679064db22
parent4a156e05bc6092396391633791c8361523f01642 (diff)
downloadaul-1-bed7161b19960cf65f7bcca65847e3de5e1975dc.tar.gz
aul-1-bed7161b19960cf65f7bcca65847e3de5e1975dc.tar.bz2
aul-1-bed7161b19960cf65f7bcca65847e3de5e1975dc.zip
Change-Id: I64856348513c4b65dfd69add4dca10c0055b8407 Signed-off-by: hyunho kang <hhstark.kang@samsung.com>
-rw-r--r--am_daemon/amd_request.c122
-rw-r--r--am_daemon/amd_status.h13
-rw-r--r--include/aul.h6
3 files changed, 134 insertions, 7 deletions
diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c
index c4c94931..55bfd117 100644
--- a/am_daemon/amd_request.c
+++ b/am_daemon/amd_request.c
@@ -32,6 +32,7 @@
#include <aul.h>
#include <bundle.h>
+#include <rua.h>
#include <tzplatform_config.h>
#include <cynara-client.h>
#include <cynara-creds-socket.h>
@@ -288,6 +289,57 @@ static int __app_process_by_pid(int cmd,
return ret;
}
+
+static gboolean __add_history_handler(gpointer user_data)
+{
+ struct rua_rec rec;
+ int ret;
+ char *app_path = NULL;
+ struct appinfo *ai;
+
+ rua_stat_pkt_t *pkt = (rua_stat_pkt_t *)user_data;
+
+ if (!pkt)
+ return FALSE;
+
+ if (!pkt->is_group_app) {
+
+ ai = (struct appinfo *)appinfo_find(pkt->uid, pkt->appid);;
+ app_path = (char *)appinfo_get_value(ai, AIT_EXEC);
+
+ memset((void *)&rec, 0, sizeof(rec));
+
+ rec.pkg_name = pkt->appid;
+ rec.app_path = app_path;
+
+ if(pkt->len > 0)
+ rec.arg = pkt->data;
+
+ SECURE_LOGD("add rua history %s %s", rec.pkg_name, rec.app_path);
+
+ ret = rua_add_history(&rec);
+ if (ret == -1)
+ _D("rua add history error");
+ }
+
+ if (pkt->stat_caller != NULL && pkt->stat_tag != NULL) {
+ SECURE_LOGD("rua_stat_caller: %s, rua_stat_tag: %s", pkt->stat_caller, pkt->stat_tag);
+ rua_stat_update(pkt->stat_caller, pkt->stat_tag);
+ }
+ if (pkt) {
+ if (pkt->data)
+ free(pkt->data);
+ if (pkt->stat_caller)
+ free(pkt->stat_caller);
+ if (pkt->stat_tag)
+ free(pkt->stat_tag);
+ free(pkt);
+ }
+
+ return FALSE;
+}
+
+
static int __release_srv(uid_t caller_uid, const char *appid)
{
int r;
@@ -583,7 +635,10 @@ static int __dispatch_app_start(int clifd, const app_pkt_t *pkt, struct ucred *c
int ret = -1;
int t_uid;
char *state;
- item_pkt_t *item;
+ item_pkt_t *item = NULL;
+ char *stat_caller = NULL;
+ char *stat_tag = NULL;
+ rua_stat_pkt_t *rua_stat_item = NULL;
kb = bundle_decode(pkt->data, pkt->len);
if (kb == NULL) {
@@ -604,7 +659,7 @@ static int __dispatch_app_start(int clifd, const app_pkt_t *pkt, struct ucred *c
} else {
_E("uid:%d session is %s", t_uid, state);
__real_send(clifd, AUL_R_ERROR);
- return -1;
+ goto error;
}
} else {
_E("request from root, treat as global user");
@@ -618,17 +673,72 @@ static int __dispatch_app_start(int clifd, const app_pkt_t *pkt, struct ucred *c
item = calloc(1, sizeof(item_pkt_t));
if (item == NULL) {
_E("out of memory");
- return -1;
+ goto error;
}
item->pid = ret;
item->uid = cr->uid;
strncpy(item->appid, appid, 511);
g_timeout_add(1200, __add_item_running_list, item);
+
+ rua_stat_item = calloc(1, sizeof(rua_stat_pkt_t));
+ if (rua_stat_item == NULL) {
+ _E("out of memory");
+ goto error;
+ }
+
+ if (pkt->len > 0) {
+ rua_stat_item->data = (char *)calloc(pkt->len, sizeof(char));
+ if (rua_stat_item->data == NULL) {
+ _E("out of memory");
+ goto error;
+ }
+ memcpy(rua_stat_item->data, pkt->data, pkt->len);
+ }
+ stat_caller = (char *)bundle_get_val(kb, AUL_SVC_K_RUA_STAT_CALLER);
+ stat_tag = (char *)bundle_get_val(kb, AUL_SVC_K_RUA_STAT_TAG);
+
+ rua_stat_item->len = pkt->len;
+ if (stat_caller != NULL) {
+ rua_stat_item->stat_caller = strdup(stat_caller);
+ if (rua_stat_item->stat_caller == NULL) {
+ _E("Out of memory");
+ goto error;
+ }
+ }
+
+ if (stat_tag != NULL) {
+ rua_stat_item->stat_tag = strdup(stat_tag);
+ if (rua_stat_item->stat_tag == NULL) {
+ _E("Out of memory");
+ goto error;
+ }
+
+ }
+ rua_stat_item->uid = cr->uid;
+ rua_stat_item->is_group_app = app_group_is_group_app(kb);
+ strncpy(rua_stat_item->appid, appid, 511);
+
+ g_timeout_add(1500, __add_history_handler, rua_stat_item);
}
bundle_free(kb);
-
return 0;
+
+error:
+ if (kb)
+ bundle_free(kb);
+ if (item)
+ free(item);
+ if (rua_stat_item) {
+ if (rua_stat_item->data)
+ free(rua_stat_item->data);
+ if (rua_stat_item->stat_caller)
+ free(rua_stat_item->stat_caller);
+ if (rua_stat_item->stat_tag)
+ free(rua_stat_item->stat_tag);
+ free(rua_stat_item);
+ }
+ return -1;
}
static int __dispatch_app_result(int clifd, const app_pkt_t *pkt, struct ucred *cr)
@@ -1134,6 +1244,10 @@ int _request_init(void)
close(fd);
return -1;
}
+ r = rua_init();
+ r = rua_clear_history();
+
+ _D("rua_clear_history : %d", r);
return 0;
}
diff --git a/am_daemon/amd_status.h b/am_daemon/amd_status.h
index 43b40448..ac1996c9 100644
--- a/am_daemon/amd_status.h
+++ b/am_daemon/amd_status.h
@@ -21,8 +21,7 @@
#include <unistd.h>
#include <sys/types.h>
-
-
+#include <glib.h>
int _status_add_app_info_list(const char *appid, const char *app_path, int pid, int pad_pid, uid_t uid);
int _status_update_app_info_list(int pid, int status, uid_t uid);
@@ -47,6 +46,16 @@ typedef struct _item_pkt_t {
char appid[512];
} item_pkt_t;
+typedef struct _rua_stat_pkt_t {
+ int uid;
+ char *stat_tag;
+ char *stat_caller;
+ char appid[512];
+ gboolean is_group_app;
+ char *data;
+ int len;
+} rua_stat_pkt_t;
+
gboolean __add_item_running_list(gpointer user_data);
diff --git a/include/aul.h b/include/aul.h
index 11836e0c..20e90274 100644
--- a/include/aul.h
+++ b/include/aul.h
@@ -110,6 +110,10 @@ typedef enum _aul_type{
#define AUL_V_KEY_PRESSED "__AUL_KEY_PRESSED__"
/** AUL public bundle value - To support Media key*/
#define AUL_V_KEY_RELEASED "__AUL_KEY_RELEASED__"
+/** AUL public key - To support rua stat */
+#define AUL_SVC_K_RUA_STAT_CALLER "__K_RUA_STAT_CALLER__"
+#define AUL_SVC_K_RUA_STAT_TAG "__K_RUA_STAT_TAG__"
+
/** AUL internal private key */
#define AUL_K_PKG_NAME "__AUL_PKG_NAME__"
@@ -143,7 +147,7 @@ typedef enum _aul_type{
#define AUL_K_WID "__AUL_WID__"
/** AUL internal private key */
#define AUL_K_LEADER_PID "__AUL_LEADER_PID__"
-/** AUL internal private key - To support data control*/
+/** AUL internal private key - To support data control */
#define AUL_K_DATA_CONTROL_TYPE "__AUL_DATA_CONTROL_TYPE__"
/** AUL internal private key */
#define AUL_K_PKGID "__AUL_PKGID_"