Add APIs for rua multi-user feature 88/75888/10 accepted/tizen/common/20160703.130338 accepted/tizen/ivi/20160701.032806 accepted/tizen/mobile/20160701.032825 accepted/tizen/tv/20160701.032725 accepted/tizen/wearable/20160701.032746 submit/tizen/20160630.070457 submit/tizen_common/20160701.180000
authorHyunho Kang <hhstark.kang@samsung.com>
Wed, 22 Jun 2016 05:43:31 +0000 (14:43 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Thu, 30 Jun 2016 02:01:06 +0000 (19:01 -0700)
Change-Id: I4cf07a08c6ae2049d28efdd0626d8205d0c848a3
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
include/aul.h
include/aul_cmd.h
src/pkginfo.c

index 632b3bb..8bdd212 100644 (file)
@@ -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 <aul.h>
+
+...
+{
+    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 <aul.h>
 
-    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);
 
 
 /**
index 7eff16d..99fc1e6 100644 (file)
@@ -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,
index 2e2fd45..8a120be 100644 (file)
@@ -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)