Save launching appid only when ACTIVATION flag is set
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 24 Jul 2019 06:26:03 +0000 (15:26 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 26 Aug 2019 10:56:44 +0000 (19:56 +0900)
Change-Id: I869ebe8edcfc4be0721275d3a398d0e7470bc21f

inc/multi_assistant_service.h
src/multi_assistant_service.c
src/multi_assistant_service_plugin.c

index 7f55bc8..0e0c51c 100644 (file)
@@ -75,7 +75,11 @@ int mas_set_current_client_by_appid(const char *appid);
 
 int mas_launch_client_by_wakeup_word(const char *wakeup_word);
 
-int mas_launch_client_by_appid(const char *appid);
+typedef enum {
+    CLIENT_LAUNCH_MODE_ACTIVATION,
+    CLIENT_LAUNCH_MODE_PRELAUNCH,
+} CLIENT_LAUNCH_MODE;
+int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode);
 
 int mas_process_voice_key_event(bool pressed);
 
index 21889fa..d945d5e 100644 (file)
@@ -401,7 +401,7 @@ int mas_ui_client_change_assistant(const char* appid)
        int pid = mas_get_client_pid_by_appid(appid);
        if (pid != -1) {
                /* Bring MA client to foreground - is there a better way instead of launching? */
-               mas_launch_client_by_appid(appid);
+               mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
                masc_dbus_active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
                MAS_LOGD("MA Client with appid %s exists, requesting speech data", (appid ? appid : "NULL"));
                /*
@@ -420,7 +420,7 @@ int mas_ui_client_change_assistant(const char* appid)
                                0 < strlen(g_maclient_info[loop].appid) &&
                                0 < strlen(g_maclient_info[loop].wakeup_word[0])) {
                                if (strncmp(appid, g_maclient_info[loop].appid, MAX_APPID_LEN) == 0) {
-                                       mas_launch_client_by_appid(g_maclient_info[loop].appid);
+                                       mas_launch_client_by_appid(g_maclient_info[loop].appid, CLIENT_LAUNCH_MODE_ACTIVATION);
                                }
                        }
                }
@@ -794,7 +794,7 @@ int mas_set_current_client_by_appid(const char *appid)
        return ret;
 }
 
-int mas_launch_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;
@@ -830,7 +830,7 @@ int mas_launch_client_by_appid(const char *appid)
        }
        app_control_destroy (app_control);
 
-       if (APP_CONTROL_ERROR_NONE == ret) {
+       if (APP_CONTROL_ERROR_NONE == ret && 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 &&
@@ -850,7 +850,7 @@ int mas_launch_client_by_appid(const char *appid)
 int mas_launch_client_by_wakeup_word(const char *wakeup_word)
 {
        const char *appid = mas_get_client_appid_by_wakeup_word(wakeup_word);
-       return mas_launch_client_by_appid(appid);
+       return mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
 }
 
 
index e8b0c74..9a4e38b 100644 (file)
@@ -110,11 +110,11 @@ Eina_Bool __launch_assistant_by_wakeup_appid_timer(char* appid)
        if ((pid = mas_get_client_pid_by_appid(appid)) != -1) {
                masc_dbus_active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
                /* Bring MA client to foreground - is there a better way instead of launching? */
-               mas_launch_client_by_appid(appid);
+               mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
        } else {
                // Appropriate MA Client not available, trying to launch new one
                MAS_LOGD("MA Client with appid %s does not exist, launching client", appid);
-               mas_launch_client_by_appid(appid);
+               mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
        }
 
        if (appid) free(appid);