From: Hwankyu Jhun Date: Tue, 23 Feb 2016 09:59:33 +0000 (+0900) Subject: Add aul_launch_app_async APIs X-Git-Tag: accepted/tizen/common/20160229.160524^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddcea2ec35c87b7dba514d5e93e3e9e19499604a;p=platform%2Fcore%2Fappfw%2Faul-1.git Add aul_launch_app_async APIs These APIs don't check whether the application is executed successfully. Change-Id: I4054126e3650a589b6e626997d640fee87182a0f Signed-off-by: Hwankyu Jhun --- diff --git a/include/aul.h b/include/aul.h index 5142e81..37c360b 100644 --- a/include/aul.h +++ b/include/aul.h @@ -2167,6 +2167,64 @@ int aul_set_default_app_by_operation(bundle *b); * */ int aul_unset_default_app_by_operation(const char *app_id); + +/** + * @par Description: + * This API launches application with the given bundle asynchronously. + * If the application is not running or a multiple-instance one, this API launches with the given bundle. + * If the application is running, this API sends a RESET event to the App. + * While the application is running, if the application cannot receive the RESET event, + * this API returns a general error(AUL_R_ERROR).\n + * @par Purpose: + * This API is for caller. + * This API's purpose is to launch/reset application with given bundle. + * @par Typical use case: + * If you know the target application's pkgname and bundle types, + * you can use this API to launch/reset the application. + * + * @param[in] pkgname package name to be run as callee + * @param[in] kb bundle to be passed to callee + * @return 0 if success, negative value(<0) if fail + * @retval AUL_R_OK - success + * @retval AUL_R_EINVAL - invaild package name + * @retval AUL_R_ECOM - internal AUL IPC error + * @retval AUL_R_ERROR - general error + * + * @remark + * This API is only available in User Session. + * This API doesn't check whether the callee application is executed successfully. + */ +int aul_launch_app_async(const char *appid, bundle *kb); + +/** + * @par Description: + * This API launches application with the given bundle asynchronously. + * If the application is not running or a multiple-instance one, this API launches with the given bundle. + * If the application is running, this API sends a RESET event to the App. + * While the application is running, if the application cannot receive the RESET event, + * this API returns a general error(AUL_R_ERROR).\n + * @par Purpose: + * This API is for caller. + * This API's purpose is to launch/reset application with given bundle. + * @par Typical use case: + * If you know the target application's pkgname and bundle types, + * you can use this API to launch/reset the application. + * + * @param[in] pkgname package name to be run as callee + * @param[in] kb bundle to be passed to callee + * @param[in] uid User ID + * @return 0 if success, negative value(<0) if fail + * @retval AUL_R_OK - success + * @retval AUL_R_EINVAL - invaild package name + * @retval AUL_R_ECOM - internal AUL IPC error + * @retval AUL_R_ERROR - general error + * + * @remark + * This API is only available in System Session. + * This API doesn't check whether the callee application is executed successfully. + */ +int aul_launch_app_async_for_uid(const char *appid, bundle *kb, uid_t uid); + #ifdef __cplusplus } #endif diff --git a/include/aul_cmd.h b/include/aul_cmd.h index 709a572..63ce4ba 100644 --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -83,6 +83,7 @@ enum app_cmd { APP_ALL_RUNNING_INFO, APP_SET_APP_CONTROL_DEFAULT_APP, APP_UNSET_APP_CONTROL_DEFAULT_APP, + APP_START_ASYNC, APP_CMD_MAX }; diff --git a/src/launch.c b/src/launch.c index 25845c6..401dade 100644 --- a/src/launch.c +++ b/src/launch.c @@ -205,6 +205,23 @@ static int __send_cmd_for_uid_opt(int pid, uid_t uid, int cmd, bundle *kb, int o return res; } +static int __send_cmd_async_for_uid_opt(int pid, uid_t uid, + int cmd, bundle *kb, int opt) +{ + int res; + + res = aul_sock_send_bundle_async(pid, uid, cmd, kb, + opt | AUL_SOCK_NOREPLY); + if (res > 0) { + close(res); + res = 0; + } else { + res = __get_aul_error(res); + } + + return res; +} + /** * @brief encode kb and send it to 'pid' * @param[in] pid receiver's pid @@ -226,6 +243,12 @@ API int app_send_cmd_with_queue_for_uid(int pid, uid_t uid, int cmd, bundle *kb) return __send_cmd_for_uid_opt(pid, uid, cmd, kb, AUL_SOCK_QUEUE); } +API int app_send_cmd_with_queue_noreply_for_uid(int pid, uid_t uid, + int cmd, bundle *kb) +{ + return __send_cmd_async_for_uid_opt(pid, uid, cmd, kb, AUL_SOCK_QUEUE); +} + API int app_send_cmd_with_noreply(int pid, int cmd, bundle *kb) { int res; @@ -355,6 +378,7 @@ int app_request_to_launchpad_with_fd(int cmd, const char *appid, bundle *kb, int switch (cmd) { case APP_START: case APP_START_RES: + case APP_START_ASYNC: b = bundle_dup(kb); ret = __app_launch_local(b); break; @@ -403,7 +427,11 @@ int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid bundle_add(kb, AUL_K_APPID, appid); __set_stime(kb); - ret = app_send_cmd_with_queue_for_uid(AUL_UTIL_PID, uid, cmd, kb); + + if (cmd == APP_START_ASYNC) + ret = app_send_cmd_with_queue_noreply_for_uid(AUL_UTIL_PID, uid, cmd, kb); + else + ret = app_send_cmd_with_queue_for_uid(AUL_UTIL_PID, uid, cmd, kb); _D("launch request result : %d", ret); if (ret == AUL_R_LOCAL) { @@ -412,6 +440,7 @@ int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid switch (cmd) { case APP_START: case APP_START_RES: + case APP_START_ASYNC: b = bundle_dup(kb); ret = __app_launch_local(b); break; @@ -487,6 +516,7 @@ int aul_sock_handler(int fd) switch (pkt->cmd) { case APP_START: /* run in callee */ case APP_START_RES: + case APP_START_ASYNC: app_start(kbundle); break; @@ -983,3 +1013,28 @@ API int aul_app_register_pid(const char *appid, int pid) return ret; } + +API int aul_launch_app_async(const char *appid, bundle *kb) +{ + int ret; + + if (appid == NULL) + return AUL_R_EINVAL; + + ret = app_request_to_launchpad(APP_START_ASYNC, appid, kb); + return ret; +} + +API int aul_launch_app_async_for_uid(const char *appid, bundle *kb, uid_t uid) +{ + int ret; + char buf[MAX_PID_STR_BUFSZ]; + + if (appid == NULL) + return AUL_R_EINVAL; + snprintf(buf, sizeof(buf), "%d", uid); + bundle_add(kb, AUL_K_TARGET_UID, buf); + + ret = app_request_to_launchpad_for_uid(APP_START_ASYNC, appid, kb, uid); + return ret; +} diff --git a/tool/aul_test.c b/tool/aul_test.c index 15badd7..1b73e98 100644 --- a/tool/aul_test.c +++ b/tool/aul_test.c @@ -466,6 +466,47 @@ static int update_running_list() return 0; } +int launch_async_test() +{ + static int num = 0; + int ret = 0; + bundle *kb = NULL; + + kb = create_internal_bundle(3); + if (kb == NULL) + return -1; + + printf("[aul_launch_app_async %d test] %s \n", num++, gargv[2]); + + ret = aul_launch_app_async(gargv[2], kb); + + if (kb) { + bundle_free(kb); + kb = NULL; + } + return ret; +} + +int launch_async_test_for_uid() +{ + static int num = 0; + int ret = 0; + bundle *kb = NULL; + + kb = create_internal_bundle(3); + if (kb == NULL) + return -1; + + printf("[aul_launch_app_async_for_uid %d test] %s \n", num++, gargv[2]); + + ret = aul_launch_app_async_for_uid(gargv[2], kb, atoi(gargv[3])); + + if (kb) { + bundle_free(kb); + kb = NULL; + } + return ret; +} /* static int set_pkg_func() @@ -624,6 +665,10 @@ static test_func_t test_func[] = { "[usage] get_status_pid "}, {"get_pid", get_pid, "aul_app_get_pid test", "[usage] get_pid "}, + {"launch_async", launch_async_test, "aul_launch_app_async test", + "[usage] launch_async ..."}, + {"launch_async_for_uid", launch_async_test_for_uid, "aul_launch_app_async_for_uid test", + "[usage] launch_async_for_uid ..."}, }; int callfunc(char *testname)