From: Kwangyoun Kim Date: Mon, 23 Jan 2017 06:58:03 +0000 (+0900) Subject: Add foreground pid check logic X-Git-Tag: accepted/tizen/unified/20170406.054054~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d3acf7119796b3e5fe2730336804d247ad33dfd;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Add foreground pid check logic Change-Id: I62f4d43f5adaf87377d998db4b4dbcc8e6534018 Signed-off-by: Kwangyoun Kim (cherry picked from commit 344f5d21211fca273d25226b0843de51a1d502d5) --- diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 010bde0..9b2a00f 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -1391,3 +1391,80 @@ int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable) return 0; } + +void vcd_client_update_foreground_pid() +{ + int tmp_pid = VC_RUNTIME_INFO_NO_FOREGROUND; + vcd_config_get_foreground(&tmp_pid); + SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", tmp_pid); + + char appid[255] = {'\0',}; + GSList *iter = NULL; + vc_client_info_s *data = NULL; + + int count = g_slist_length(g_client_list); + int i; + + if (0 == count) { + SLOG(LOG_DEBUG, TAG_VCD, "No Client"); + } else { + iter = g_slist_nth(g_client_list, 0); + for (i = 0; i < count; i++) { + if (NULL == iter) + break; + + data = iter->data; + + if (NULL != data) { + SLOG(LOG_DEBUG, TAG_VCD, "[%dth] pid(%d)", i, data->pid); + memset(appid, 0, 255); + aul_app_get_appid_bypid(data->pid, appid, sizeof(appid)); + int status = aul_app_get_status(appid); + if (status == STATUS_FOCUS) { + SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", data->pid); + vcd_config_set_foreground(data->pid, true); + if (tmp_pid != data->pid) { + SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid is different"); + } + return; + } + } + iter = g_slist_next(iter); + } + } + + widget_info_s *widget_data = NULL; + count = g_slist_length(g_widget_list); + + if (0 == count) { + SLOG(LOG_DEBUG, TAG_VCD, "No widget"); + } else { + iter = g_slist_nth(g_widget_list, 0); + for (i = 0; i < count; i++) { + if (NULL == iter) + break; + + widget_data = iter->data; + + if (NULL != widget_data) { + SLOG(LOG_DEBUG, TAG_VCD, "[%dth] pid(%d)", i, widget_data->pid); + memset(appid, 0, 255); + aul_app_get_appid_bypid(widget_data->pid, appid, sizeof(appid)); + int status = aul_app_get_status(appid); + if (status == STATUS_FOCUS) { + SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid (%d)", widget_data->pid); + vcd_config_set_foreground(widget_data->pid, true); + if (tmp_pid != widget_data->pid) { + SLOG(LOG_INFO, TAG_VCD, "[INFO] foreground pid is changed"); + } + return; + } + } + iter = g_slist_next(iter); + } + } + + SLOG(LOG_INFO, TAG_VCD, "[INFO] No foreground"); + vcd_config_set_foreground(VC_RUNTIME_INFO_NO_FOREGROUND, true); + return; +} diff --git a/server/vcd_client_data.h b/server/vcd_client_data.h index d84ba3b..d38a8ba 100644 --- a/server/vcd_client_data.h +++ b/server/vcd_client_data.h @@ -152,6 +152,7 @@ int vcd_client_unset_exclusive_command(int pid); int vcd_client_save_client_info(); +void vcd_client_update_foreground_pid(); /* * widget API */ diff --git a/server/vcd_server.c b/server/vcd_server.c index 9feed7e..00f5792 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1526,11 +1526,12 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive vcd_client_set_recognition_mode(recognition_mode); if (false == exclusive_cmd) { + vcd_client_update_foreground_pid(); /* Notify show tooltip */ if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) { int pid = vcd_client_widget_get_foreground_pid(); if (-1 != pid) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip show and widget command"); + SLOG(LOG_INFO, TAG_VCD, "[Server] Request tooltip show and widget command"); ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); return 0; }