Run voice assistants in background when PRELAUNCH'ing
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 26 Aug 2019 10:53:25 +0000 (19:53 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 27 Aug 2019 02:28:15 +0000 (11:28 +0900)
Change-Id: I7100f8135214334c5479f92ec169bd21edd2ea81

src/multi_assistant_service.c

index 0f6511a..847d122 100644 (file)
@@ -812,41 +812,34 @@ int mas_set_current_client_by_appid(const char *appid)
 
 int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode)
 {
-       app_control_h app_control;
-       int ret = 0;
-
        if (NULL == appid || 0 == strlen(appid)) {
                MAS_LOGE("appid invalid, failed launching MA Client");
                return -1;
        }
 
-       ret = app_control_create(&app_control);
-       if (APP_CONTROL_ERROR_NONE != ret) {
-               MAS_LOGW("app_control_create returned %08x", ret);
-               return -1;
-       }
-
-       ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
-       if (APP_CONTROL_ERROR_NONE != ret) {
-               MAS_LOGW("app_control_set_operation returned %08x", ret);
-               app_control_destroy(app_control);
+       bundle *b = NULL;
+       b = bundle_create();
+       if (NULL == b) {
+               MAS_LOGE("Failed creating bundle for aul operation");
                return -1;
        }
 
-       ret = app_control_set_app_id(app_control, appid);
-       if (APP_CONTROL_ERROR_NONE != ret) {
-               MAS_LOGW("app_control_set_app_id returned %08x", ret);
-               app_control_destroy(app_control);
-               return -1;
+       int result;
+       if (CLIENT_LAUNCH_MODE_PRELAUNCH == launch_mode) {
+               result = aul_svc_set_background_launch(b, TRUE);
+               if (result < AUL_R_OK) {
+                       MAS_LOGE("ERROR : aul_svc_set_background_launch failed. app_id [%s] bundle[%p] result[%d : %s]",
+                               appid, b, result, get_error_message(result));
+               }
        }
 
-       ret = app_control_send_launch_request(app_control, NULL, NULL);
-       if (APP_CONTROL_ERROR_NONE != ret) {
-               MAS_LOGW ("app_control_send_launch_request returned %08x, app_id=%s", ret, appid);
+       result = aul_launch_app(appid, b);
+       if (result < AUL_R_OK) {
+               MAS_LOGE("ERROR : aul_launch_app failed. app_id [%s] bundle[%p] result[%d : %s]",
+                       appid, b, result, get_error_message(result));
        }
-       app_control_destroy (app_control);
 
-       if (APP_CONTROL_ERROR_NONE == ret && CLIENT_LAUNCH_MODE_ACTIVATION == launch_mode) {
+       if (CLIENT_LAUNCH_MODE_ACTIVATION == launch_mode) {
                bool found = false;
                for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
                        if (g_maclient_info[loop].used &&
@@ -860,7 +853,10 @@ int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode
                MAS_LOGD("g_wakeup_maclient_appid : %s, %d", g_wakeup_maclient_appid, found);
        }
 
-       return ret;
+       if (b) bundle_free(b);
+       b = NULL;
+
+       return result;
 }
 
 int mas_launch_client_by_wakeup_word(const char *wakeup_word)