From: Ji-hoon Lee Date: Thu, 4 Apr 2024 12:39:57 +0000 (+0900) Subject: Change app launch method to guarantee the async behavior X-Git-Tag: accepted/tizen/unified/20240604.015351~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=53ce1c40a467cb6c3dbb16a452d068236376fb83;p=platform%2Fcore%2Fuifw%2Fmulti-assistant-service.git Change app launch method to guarantee the async behavior Since it is said that previous api aul_launch_app_async() function blocks if AMD does not respond promptly, change the launch method to use the function app_control_send_launch_request_async() instead. Change-Id: Ia38d816b1bf8f6752b922d253ce0171000ab7fd1 --- diff --git a/src/application_manager_aul.cpp b/src/application_manager_aul.cpp index 3061c2c..00f920d 100644 --- a/src/application_manager_aul.cpp +++ b/src/application_manager_aul.cpp @@ -22,6 +22,7 @@ #include #include +#include CApplicationManagerAul::CApplicationManagerAul() { @@ -90,32 +91,37 @@ bool CApplicationManagerAul::bring_app_to_foreground(const std::string& appid) return ret; } +static void result_cb(app_control_h request, app_control_error_e result, void *user_data) { + MAS_LOGI("App Control Error : %d", result); +} + +static void reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) { + MAS_LOGI("App Control Result : %d", result); +} + bool CApplicationManagerAul::launch_app_async(const std::string& appid, bool background) { bool ret = true; - bundle *b = NULL; - b = bundle_create(); - if (NULL == b) { - MAS_LOGE("Failed creating bundle for aul operation"); - return false; + if (background) { + MAS_LOGE("ERROR : Background launch is not currently supported"); } - int result = aul_svc_set_background_launch(b, background); - if (result < AUL_R_OK) { - MAS_LOGE("ERROR : aul_svc_set_background_launch failed. app_id [%s] bundle[%p] result[%d : %s]", - appid.c_str(), b, result, get_error_message(result)); + app_control_h app_control = nullptr; + int result = app_control_create(&app_control); + if (result != APP_CONTROL_ERROR_NONE) { + MAS_LOGE("ERROR : app_control_create failed : %d", result); + return false; } - result = aul_launch_app_async(appid.c_str(), b); - if (result < AUL_R_OK) { - MAS_LOGE("ERROR : aul_launch_app_async failed. app_id [%s] bundle[%p] result[%d : %s]", - appid.c_str(), b, result, get_error_message(result)); + result = app_control_set_app_id(app_control, appid.c_str()); + result = app_control_send_launch_request_async(app_control, result_cb, reply_cb, nullptr); + if (result != APP_CONTROL_ERROR_NONE) { + MAS_LOGE("ERROR : app_control_send_launch_request_async failed. app_id [%s] result[%d : %s]", + appid.c_str(), result, get_error_message(result)); ret = false; } - - if (b) bundle_free(b); - b = NULL; + app_control_destroy(app_control); return ret; } @@ -180,4 +186,4 @@ void CApplicationManagerAul::clear_cache() { mAppIDCache.clear(); mPIDCache.clear(); -} \ No newline at end of file +}