Fix foreground app check logic via focus info 78/94378/2 accepted/tizen/common/20161031.122126 accepted/tizen/ivi/20161101.122827 accepted/tizen/mobile/20161101.122737 accepted/tizen/tv/20161101.122755 accepted/tizen/wearable/20161101.122808 submit/tizen/20161031.102847
authorKwangyoun Kim <ky85.kim@samsung.com>
Fri, 28 Oct 2016 12:40:19 +0000 (21:40 +0900)
committerKwangyoun Kim <ky85.kim@samsung.com>
Fri, 28 Oct 2016 13:31:59 +0000 (22:31 +0900)
Change-Id: Iba5dbadf9d658e741ede8c70c41ecad192d1c452

CMakeLists.txt
client/vc_widget.c [changed mode: 0755->0644]
packaging/voice-control.spec
server/vcd_server.c

index 38fc3c6..add3b74 100644 (file)
@@ -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()
old mode 100755 (executable)
new mode 100644 (file)
index e7a9ed1..6714f40
@@ -14,6 +14,8 @@
 * limitations under the License.
 */
 
+#include <aul.h>
+#include <Ecore_Wayland.h>
 #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);
 
index 8e185dd..321fa0e 100644 (file)
@@ -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)
index 632eb4f..2baf934 100644 (file)
@@ -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;
        }