Add asynchronous API to resume an application 58/86258/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 31 Aug 2016 08:45:47 +0000 (17:45 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 31 Aug 2016 08:45:47 +0000 (17:45 +0900)
- Add APIs
aul_resume_pid_async()
aul_resume_pid_async_for_uid()

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

index fb60307..26df2b3 100644 (file)
@@ -2847,6 +2847,59 @@ int aul_app_get_last_caller_pid(int pid);
  */
 int aul_app_get_last_caller_pid_for_uid(int pid, uid_t uid);
 
+/**
+ * @par Description:
+ *      This API trigger to resume application asynchronously.
+ *      If the application is running, this API send a resume event to the App.
+ *      If the application is not running, this API return AUL_R_ERROR.
+ *      Although the application is running, if the application cannot receive resume event,
+ *      AUL try to raise the application's default windows.
+ * @par Purpose:
+ *      This API is for caller.
+ *      This API's purpose is to send resume event.
+ * @par Typical use case:
+ *      In multiple application model, If you want to only resume specific application, Use this API
+ *
+ * @param[in]   pid     application's pid to be resumed
+ * @return      0 if success, negative value(<0) if fail
+ * @retval      AUL_R_OK        - success
+ * @retval      AUL_R_EINVAL    - invaild pid
+ * @retval      AUL_R_ECOM      - internal AUL IPC error
+ * @retval      AUL_R_ERROR     - general error (include application is not running)
+ * @warning     This API need to require root or inhouse permisssion \n
+ *              If you have not the permission, this API return AUL_R_ERROR. \n
+ * @remark
+ *      This API is only available to User Session.
+ */
+int aul_resume_pid_async(int pid);
+
+/**
+ * @par Description:
+ *      This API trigger to resume application asynchronously.
+ *      If the application is running, this API send a resume event to the App.
+ *      If the application is not running, this API return AUL_R_ERROR.
+ *      Although the application is running, if the application cannot receive resume event,
+ *      AUL try to raise the application's default windows.
+ * @par Purpose:
+ *      This API is for caller.
+ *      This API's purpose is to send resume event.
+ * @par Typical use case:
+ *      In multiple application model, If you want to only resume specific application, Use this API
+ *
+ * @param[in]   pid     application's pid to be resumed
+ * @param[in]   uid     User ID
+ * @return      0 if success, negative value(<0) if fail
+ * @retval      AUL_R_OK        - success
+ * @retval      AUL_R_EINVAL    - invaild pid
+ * @retval      AUL_R_ECOM      - internal AUL IPC error
+ * @retval      AUL_R_ERROR     - general error (include application is not running)
+ * @warning     This API need to require root or inhouse permisssion \n
+ *              If you have not the permission, this API return AUL_R_ERROR. \n
+ * @remark
+ *      This API is only available to System user.
+ */
+int aul_resume_pid_async_for_uid(int pid, uid_t uid);
+
 #ifdef __cplusplus
        }
 #endif
index e566ddf..59a86f9 100644 (file)
@@ -107,6 +107,7 @@ enum app_cmd {
        APP_GET_STATUS_BY_APPID,
        APP_GET_LAST_CALLER_PID,
        APP_TERM_BY_PID_SYNC_WITHOUT_RESTART,
+       APP_RESUME_BY_PID_ASYNC,
        APP_CMD_MAX
 };
 
index c19c2ba..ed538d8 100644 (file)
@@ -328,6 +328,7 @@ int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid
                case APP_OPEN:
                case APP_RESUME:
                case APP_RESUME_BY_PID:
+               case APP_RESUME_BY_PID_ASYNC:
                        ret = __app_resume_local();
                        break;
                default:
@@ -1067,3 +1068,22 @@ API int aul_terminate_pid_sync_for_uid(int pid, uid_t uid)
        return ret;
 }
 
+API int aul_resume_pid_async(int pid)
+{
+       return aul_resume_pid_async_for_uid(pid, getuid());
+}
+
+API int aul_resume_pid_async_for_uid(int pid, uid_t uid)
+{
+       char pid_str[MAX_PID_STR_BUFSZ];
+       int ret;
+
+       if (pid <= 0)
+               return AUL_R_EINVAL;
+
+       snprintf(pid_str, sizeof(pid_str), "%d", pid);
+       ret = app_request_to_launchpad_for_uid(APP_RESUME_BY_PID_ASYNC,
+                       pid_str, NULL, uid);
+       return ret;
+}
+
index f552064..ba4fc62 100644 (file)
@@ -666,6 +666,22 @@ static int get_last_caller_pid_test_for_uid(void)
        return aul_app_get_last_caller_pid_for_uid(apn_pid, atoi(gargv[3]));
 }
 
+static int resume_pid_async_test(void)
+{
+       static int num;
+
+       printf("aul_resume_pid_async %d test] %d \n", num++, apn_pid);
+       return aul_resume_pid_async(apn_pid);
+}
+
+static int resume_pid_async_test_for_uid(void)
+{
+       static int num;
+
+       printf("aul_resume_pid_async_for_uid %d test] %d \n", num++, apn_pid);
+       return aul_resume_pid_async_for_uid(apn_pid, atoi(gargv[3]));
+}
+
 static int test_regex()
 {
        char *token;
@@ -801,6 +817,10 @@ static test_func_t test_func[] = {
                "[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"},
+       {"resume_pid_async", resume_pid_async_test, "aul_resume_pid_async",
+               "[usage] resume_pid_async <pid>"},
+       {"resume_pid_async_for_uid", resume_pid_async_test_for_uid, "aul_resume_pid_async_for_uid",
+               "[usage] resume_pid_async_for_uid <pid> <uid>"},
 };
 
 int callfunc(char *testname)