#include <aul.h>
#include <bundle.h>
+#include <rua.h>
#include <tzplatform_config.h>
#include <cynara-client.h>
#include <cynara-creds-socket.h>
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;
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) {
} 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");
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)
close(fd);
return -1;
}
+ r = rua_init();
+ r = rua_clear_history();
+
+ _D("rua_clear_history : %d", r);
return 0;
}
#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__"
#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_"