From: Hyunho Kang Date: Wed, 22 Jun 2016 05:43:31 +0000 (+0900) Subject: Add APIs for rua multi-user feature X-Git-Tag: submit/tizen_common/20160701.180000 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Fsubmit%2Ftizen_common%2F20160701.180000;p=platform%2Fcore%2Fappfw%2Faul-1.git Add APIs for rua multi-user feature Change-Id: I4cf07a08c6ae2049d28efdd0626d8205d0c848a3 Signed-off-by: Hyunho Kang --- diff --git a/include/aul.h b/include/aul.h index 632b3bb..8bdd212 100644 --- a/include/aul.h +++ b/include/aul.h @@ -118,7 +118,10 @@ typedef enum _aul_type { #define AUL_K_RUA_PKGNAME "__K_RUA_PKGNAME" /** AUL public key - To support rua delete */ #define AUL_K_RUA_APPPATH "__K_RUA_APPPATH" - +/** AUL public key - To support rua add */ +#define AUL_K_RUA_ARG "__K_RUA_ARG" +/** AUL public key - To support rua add */ +#define AUL_K_RUA_TIME "__K_RUA_TIME" /** AUL internal private key */ @@ -2525,9 +2528,39 @@ int aul_app_get_pid_for_uid(const char *appid, uid_t uid); /** * @par Description: - * This function delete rua history. + * This function update rua stat. * - * @param[in] b Bundle object Target Package name or app path. If NULL or has no value, delete all rua history. + * @param[in] b Bundle object contains caller and tag information. + * @param[in] uid Target uid + * + * @return 0 if success, negative value(<0) if fail + * @see None + * @remarks This API is only for Appfw internally. + * + * @par Sample code: + * @code +#include + +... +{ + int r; + bundle *b = bundle_create(); + bundle_add_str(b, AUL_SVC_K_RUA_STAT_CALLER, caller); + bundle_add_str(b, AUL_SVC_K_RUA_STAT_TAG, tag); + + r = aul_update_rua_stat_for_uid(b); +} + + * @endcode + **/ +int aul_update_rua_stat_for_uid(bundle *b, uid_t uid); + +/** + * @par Description: + * This function add rua history. + * + * @param[in] b Bundle object Target Package name or app path. + * @param[in] uid Target uid * * @return 0 if success, negative value(<0) if fail * @see None @@ -2542,16 +2575,46 @@ int aul_app_get_pid_for_uid(const char *appid, uid_t uid); int r; bundle *b = bundle_create(); if (pkg_name) - bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name); + bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name); else if (app_path) - bundle_add_str(b, AUL_K_RUA_APPPATH, app_path); + bundle_add_str(b, AUL_K_RUA_APPPATH, app_path); + + r = aul_add_rua_history_for_uid(b); +} + + * @endcode + **/ +int aul_add_rua_history_for_uid(bundle *b, uid_t uid); + +/** + * @par Description: + * This function delete rua history. + * + * @param[in] b Bundle object Target Package name. If NULL or has no value, delete all rua history. + * @param[in] uid Target uid + * + * @return 0 if success, negative value(<0) if fail + * @see None + * @remarks This API is only for Appfw internally. + * + * @par Sample code: + * @code +#include - r = aul_delete_rua_history(b); +... +{ + int r; + bundle *b = NULL; + if (pkg_name) { + b = bundle_create(); + bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name); + } + r = aul_delete_rua_history_for_uid(b, getuid()); } * @endcode **/ -int aul_delete_rua_history(bundle *b); +int aul_delete_rua_history_for_uid(bundle *b, uid_t uid); /** diff --git a/include/aul_cmd.h b/include/aul_cmd.h index 7eff16d..99fc1e6 100644 --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -28,6 +28,7 @@ enum app_cmd { APP_START_RES, APP_CANCEL, APP_KILL_BY_PID, + APP_UPDATE_RUA_STAT, APP_ADD_HISTORY, APP_REMOVE_HISTORY, APP_RUNNING_INFO, diff --git a/src/pkginfo.c b/src/pkginfo.c index 2e2fd45..8a120be 100644 --- a/src/pkginfo.c +++ b/src/pkginfo.c @@ -366,7 +366,29 @@ API int aul_app_get_pkgid_bypid(int pid, char *pkgid, int len) return aul_app_get_pkgid_bypid_for_uid(pid, pkgid, len, getuid()); } -API int aul_delete_rua_history(bundle *b) +API int aul_update_rua_stat_for_uid(bundle *b, uid_t uid) +{ + int ret; + + ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, + APP_UPDATE_RUA_STAT, b, AUL_SOCK_NONE); + return ret; +} + +API int aul_add_rua_history_for_uid(bundle *b, uid_t uid) +{ + int ret; + + if (b == NULL) { + SECURE_LOGE("invalid param"); + return AUL_R_EINVAL; + } + ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, + APP_ADD_HISTORY, b, AUL_SOCK_NONE); + return ret; +} + +API int aul_delete_rua_history_for_uid(bundle *b, uid_t uid) { int ret; bundle_raw *br = NULL; @@ -376,7 +398,7 @@ API int aul_delete_rua_history(bundle *b) if (b != NULL) bundle_encode(b, &br, &datalen); - ret = aul_sock_send_raw(AUL_UTIL_PID, getuid(), + ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_REMOVE_HISTORY, br, datalen, AUL_SOCK_NONE); if (br != NULL)