Change app launch method to guarantee the async behavior 93/309093/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Thu, 4 Apr 2024 12:39:57 +0000 (21:39 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Fri, 12 Apr 2024 12:46:55 +0000 (21:46 +0900)
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

src/application_manager_aul.cpp

index 3061c2cd88cfa0840ad74c8782727ea8200afe47..00f920dcf1f6054a6c90cb4adb645ed40b0fbb9c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <aul.h>
 #include <aul_svc.h>
+#include <app_control.h>
 
 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
+}