From 96adf6f4fd7a68d6780a0cc6245cd60c5fad16b5 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Fri, 28 Oct 2016 21:40:19 +0900 Subject: [PATCH] Fix foreground app check logic via focus info Change-Id: Iba5dbadf9d658e741ede8c70c41ecad192d1c452 --- CMakeLists.txt | 4 ++-- client/vc_widget.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ packaging/voice-control.spec | 1 + server/vcd_server.c | 6 +++--- 4 files changed, 50 insertions(+), 5 deletions(-) mode change 100755 => 100644 client/vc_widget.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 38fc3c6..add3b74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,12 +42,12 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") INCLUDE(FindPkgConfig) IF("${_TV_PRODUCT}" STREQUAL "TRUE") pkg_check_modules(pkgs REQUIRED - aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager + aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wayland capi-network-bluetooth capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libtzplatform-config libxml-2.0 sqlite3 vconf #msfapi ) ELSE() pkg_check_modules(pkgs REQUIRED - aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager + aul capi-appfw-application capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wayland capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libtzplatform-config libxml-2.0 sqlite3 vconf ) ENDIF() diff --git a/client/vc_widget.c b/client/vc_widget.c old mode 100755 new mode 100644 index e7a9ed1..6714f40 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#include +#include #include "vc_cmd_db.h" #include "vc_command.h" #include "vc_config_mgr.h" @@ -220,6 +222,33 @@ int vc_widget_deinitialize() return VC_ERROR_NONE; } +static Eina_Bool __focus_changed_cb(void *data, int type, void *event) +{ + SLOG(LOG_DEBUG, TAG_VCW, "===== Focus changed"); + + int ret; + if (ECORE_WL_EVENT_FOCUS_IN == type) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Set foreground"); + ret = vc_widget_dbus_set_foreground(getpid(), true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground (true) : %d", ret); + } + } else if (ECORE_WL_EVENT_FOCUS_OUT == type) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Set background"); + ret = vc_widget_dbus_set_foreground(getpid(), false); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground (false) : %d", ret); + } + } else { + SLOG(LOG_DEBUG, TAG_VCW, "===== type(%d) is NOT valid", type); + } + + SLOG(LOG_DEBUG, TAG_VCW, "====="); + SLOG(LOG_DEBUG, TAG_VCW, ""); + + return ECORE_CALLBACK_RENEW; +} + static Eina_Bool __vc_widget_connect_daemon(void *data) { /* Send hello */ @@ -257,6 +286,21 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) vc_widget_client_set_service_state(g_vc_w, (vc_service_state_e)service_state); + ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + + char appid[255] = {'\0',}; + aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); + + int status = aul_app_get_status(appid); + if (status == STATUS_FOCUS) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Set foreground"); + ret = vc_widget_dbus_set_foreground(getpid(), true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground (true) : %d", ret); + } + } + vc_widget_client_set_state(g_vc_w, VC_STATE_READY); ecore_timer_add(0, __vc_widget_notify_state_changed, g_vc_w); diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 8e185dd..321fa0e 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -24,6 +24,7 @@ BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ecore-wayland) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(json-glib-1.0) BuildRequires: pkgconfig(libtzplatform-config) diff --git a/server/vcd_server.c b/server/vcd_server.c index 632eb4f..2baf934 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1525,7 +1525,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready"); return VCD_ERROR_INVALID_STATE; } - if (-1 != vcd_client_manager_get_pid()) { + if (-1 == vcd_client_manager_get_pid()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } @@ -1578,7 +1578,7 @@ int vcd_server_mgr_stop() SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not recording"); return VCD_ERROR_INVALID_STATE; } - if (-1 != vcd_client_manager_get_pid()) { + if (-1 == vcd_client_manager_get_pid()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } @@ -1607,7 +1607,7 @@ int vcd_server_mgr_cancel() SLOG(LOG_WARN, TAG_VCD, "[Server ERROR] Current state is not recording or processing"); return VCD_ERROR_INVALID_STATE; } - if (-1 != vcd_client_manager_get_pid()) { + if (-1 == vcd_client_manager_get_pid()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } -- 2.7.4