Add voice control elm initialization 55/162655/3
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 5 Dec 2017 00:10:09 +0000 (09:10 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 5 Dec 2017 00:46:02 +0000 (09:46 +0900)
Change-Id: I037d8eda4f049cb1aa6468c453477dcc7bf16ca5
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
CMakeLists.txt
packaging/launchpad.spec
src/launchpad_loader.c

index 1e1b618..aedaa17 100755 (executable)
@@ -33,6 +33,7 @@ PKG_CHECK_MODULES(${this_target_loader} REQUIRED
        vconf
        buxton2
        libsystemd
+       voice-control-elm
        )
 
 FOREACH(flag ${${this_target_loader}_CFLAGS})
index 4b767f1..a80ab6b 100644 (file)
@@ -24,6 +24,7 @@ BuildRequires:  pkgconfig(ttrace)
 BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(libcap)
 BuildRequires:  pkgconfig(tanchor)
+BuildRequires:  pkgconfig(voice-control-elm)
 
 Requires(post): /sbin/ldconfig
 Requires(post): /usr/bin/systemctl
index 6ec1d36..6ad6284 100644 (file)
@@ -26,6 +26,8 @@
 #include <Elementary.h>
 #include <bundle_internal.h>
 #include <vconf.h>
+#include <voice_control_elm.h>
+#include <voice_control_elm_private.h>
 
 #include "launchpad_common.h"
 #include "launchpad.h"
@@ -48,6 +50,7 @@ static Evas_Object *__win;
 static Evas_Object *__bg;
 static Evas_Object *__conform;
 static int __type;
+static bool __vc_elm_initialized;
 
 enum loader_type {
        TYPE_COMMON,
@@ -141,6 +144,46 @@ static void __fini_window(void)
        }
 }
 
+static void __vc_vtauto_changed_cb(keynode_t *key, void *data)
+{
+       const char *name;
+       int vt_automode;
+
+       name = vconf_keynode_get_name(key);
+       if (!name || strcmp(name, VCONFKEY_VC_VOICE_TOUCH_AUTOMODE) != 0)
+               return;
+
+       vt_automode = vconf_keynode_get_bool(key);
+       if (vt_automode) {
+               if (!__vc_elm_initialized) {
+                       vc_elm_initialize();
+                       __vc_elm_initialized = true;
+               }
+               vc_elm_set_auto_register_mode(2, 0);
+       } else {
+               vc_elm_deinitialize();
+               __vc_elm_initialized = false;
+       }
+}
+
+static void __vc_elm_init(void)
+{
+       int vt_automode = 0;
+
+       vconf_notify_key_changed(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE,
+                       __vc_vtauto_changed_cb, NULL);
+       vconf_get_bool(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, &vt_automode);
+       if (vt_automode) {
+               if (!__vc_elm_initialized) {
+                       vc_elm_initialize();
+                       __vc_elm_initialized = true;
+               }
+               vc_elm_set_auto_register_mode(2, 0);
+       }
+
+       setenv("VC_ELM_INIT", "1", 1);
+}
+
 static void __preload_lib(bundle *b)
 {
        void *handle = NULL;
@@ -215,6 +258,8 @@ static void __loader_create_cb(bundle *extra, int type, void *user_data)
                break;
        }
 
+       __vc_elm_init();
+
        ret = vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &__sys_hwacc);
        if (ret != VCONF_OK) {
                _E("Failed to get vconf int: %s",
@@ -351,6 +396,7 @@ do_exec:
                        setenv("LD_LIBRARY_PATH", libdir, 1);
                free(libdir);
                unsetenv("AUL_LOADER_INIT");
+               unsetenv("VC_ELM_INIT");
                if (execv(argv[LOADER_ARG_PATH], argv) < 0) {
                        SECURE_LOGE("execv() failed for file: \"%s\", " \
                                "error: %d (%s)", argv[LOADER_ARG_PATH], errno,