Add new APIs to get last caller process id 78/80678/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 19 Jul 2016 11:26:01 +0000 (20:26 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 19 Jul 2016 11:26:01 +0000 (20:26 +0900)
- Add APIs
aul_app_get_last_caller()
aul_app_get_last_caller_for_uid()

Change-Id: I5495250cfac1a3a22daf1a496112fb897e0e0a1b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul.h
include/aul_cmd.h
src/pkginfo.c
tool/aul_test.c

index 1470fe9..0b3ebfc 100644 (file)
@@ -2782,6 +2782,35 @@ int aul_widget_instance_foreach(const char *widget_id, aul_widget_instance_forea
  */
 int aul_widget_instance_update(const char *widget_id, const char *instance_id, bundle *b);
 
+/**
+ * @par Description:
+ *     This API gets the last caller process id of specified application process id.
+ * @par Purpose:
+ *     This API's purpose is to get the application's last caller process id.
+ *
+ * @param[in]  pid     pid of application
+ * @return     caller pid if success, nagative value if fail
+ *
+ * @remark
+ *     This API is only available in User Session.
+ */
+int aul_app_get_last_caller_pid(int pid);
+
+/**
+ * @par Description:
+ *     This API gets the last caller process id of specified application process id.
+ * @par Purpose:
+ *     This API's purpose is to get the last caller process id of the application.
+ *
+ * @param[in]  pid     pid of application
+ * @param[in]   uid     User ID
+ * @return     caller pid if success, nagative value if fail
+ *
+ * @remark
+ *     This API is only available in System users.
+ */
+int aul_app_get_last_caller_pid_for_uid(int pid, uid_t uid);
+
 #ifdef __cplusplus
        }
 #endif
index 77615fa..ce2ee7b 100644 (file)
@@ -105,6 +105,7 @@ enum app_cmd {
        APP_PREPARE_CANDIDATE_PROCESS,
        APP_TERM_BY_PID_SYNC,
        APP_GET_STATUS_BY_APPID,
+       APP_GET_LAST_CALLER_PID,
        APP_CMD_MAX
 };
 
index 2b716dd..1741a40 100644 (file)
@@ -437,3 +437,27 @@ API int aul_unset_default_app_by_operation(const char *app_id)
 
        return AUL_R_OK;
 }
+
+API int aul_app_get_last_caller_pid(int pid)
+{
+       return aul_app_get_last_caller_pid_for_uid(pid, getuid());
+}
+
+API int aul_app_get_last_caller_pid_for_uid(int pid, uid_t uid)
+{
+       int ret;
+
+       if (pid < 0) {
+               _E("Invalid parameter");
+               return AUL_R_EINVAL;
+       }
+
+       ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_LAST_CALLER_PID,
+                       (unsigned char *)&pid, sizeof(int),
+                       AUL_SOCK_NONE);
+       if (ret < 0)
+               return aul_error_convert(ret);
+
+       return ret;
+}
+
index ae50976..f552064 100644 (file)
@@ -650,6 +650,22 @@ static int get_status_test_for_uid(void)
        return 0;
 }
 
+static int get_last_caller_pid_test(void)
+{
+       static int num;
+
+       printf("[aul_app_get_last_caller_pid %d test] %d \n", num++, apn_pid);
+       return aul_app_get_last_caller_pid(apn_pid);
+}
+
+static int get_last_caller_pid_test_for_uid(void)
+{
+       static int num;
+
+       printf("[aul_app_get_last_caller_pid_for_uid %d test] %d \n", num++, apn_pid);
+       return aul_app_get_last_caller_pid_for_uid(apn_pid, atoi(gargv[3]));
+}
+
 static int test_regex()
 {
        char *token;
@@ -781,6 +797,10 @@ static test_func_t test_func[] = {
                "[usage] get_status <appid>"},
        {"get_status_for_uid", get_status_test_for_uid, "aul_app_get_status_for_uid test",
                "[usage] get_status_for_uid <appid> <uid>"},
+       {"get_last_caller_pid", get_last_caller_pid_test, "aul_app_get_last_caller_pid test",
+               "[usage] get_last_caller_pid <pid>"},
+       {"get_last_caller_pid_for_uid", get_last_caller_pid_test_for_uid, "aul_app_get_last_caller_pid_for_uid test",
+               "[usage] get_last_caller_pid_for_uid <pid> <uid"},
 };
 
 int callfunc(char *testname)