summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2018-05-11 11:21:49 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2018-05-11 11:27:03 +0900
commit2959f30fcabc050cc7a9256a7443e4235ac3bd07 (patch)
treefa45ca13ed9962c09ed0d8a48769d134f6cb0314
parent08b00933c5a23c314b13ddd5fa273e3edca4ec40 (diff)
downloadlaunchpad-2959f30fcabc050cc7a9256a7443e4235ac3bd07.tar.gz
launchpad-2959f30fcabc050cc7a9256a7443e4235ac3bd07.tar.bz2
launchpad-2959f30fcabc050cc7a9256a7443e4235ac3bd07.zip
Remove voice-control-elm dependency
Some devices don't support voice-control-elm library. The launchpad-loader calls dlopen() to use voice-control-elm APIs. Change-Id: I082f56a67bce519d6a1c15cb0a446683293d46e9 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rwxr-xr-xCMakeLists.txt1
-rw-r--r--packaging/launchpad.spec1
-rw-r--r--src/launchpad_loader.c79
3 files changed, 72 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1fbed8a..709a6e9 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,7 +33,6 @@ PKG_CHECK_MODULES(${this_target_loader} REQUIRED
vconf
buxton2
libsystemd
- voice-control-elm
gio-2.0
)
diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec
index 9c591c8..85bf389 100644
--- a/packaging/launchpad.spec
+++ b/packaging/launchpad.spec
@@ -24,7 +24,6 @@ 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
diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c
index 8e75181..0bc44c9 100644
--- a/src/launchpad_loader.c
+++ b/src/launchpad_loader.c
@@ -26,8 +26,6 @@
#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"
@@ -38,6 +36,8 @@
#define LOADER_TYPE_HW "hw-loader"
#define LOADER_TYPE_SW "sw-loader"
+#define PATH_LIB_VC_ELM "/usr/lib/libvc-elm.so.0"
+
extern bundle *launchpad_loader_get_bundle(void);
static Ecore_Fd_Handler *__fd_handler;
@@ -50,7 +50,13 @@ static Evas_Object *__win;
static Evas_Object *__bg;
static Evas_Object *__conform;
static int __type;
+
static bool __vc_elm_initialized;
+static void *__vc_elm_handle;
+static int (*__vc_elm_initialize)(void);
+static int (*__vc_elm_deinitialize)(void);
+static int (*__vc_elm_set_auto_register_mode)(int, int);
+
enum loader_type {
TYPE_COMMON,
@@ -144,6 +150,60 @@ static void __fini_window(void)
}
}
+static void __unload_vc_elm(void)
+{
+ if (!__vc_elm_handle)
+ return;
+
+ __vc_elm_initialize = NULL;
+ __vc_elm_deinitialize = NULL;
+ __vc_elm_set_auto_register_mode = NULL;
+
+ dlclose(__vc_elm_handle);
+ __vc_elm_handle = NULL;
+}
+
+static int __load_vc_elm(void)
+{
+ if (__vc_elm_handle)
+ return 0;
+
+ if (access(PATH_LIB_VC_ELM, F_OK) != 0) {
+ _W("Failed to access %s", PATH_LIB_VC_ELM);
+ return -1;
+ }
+
+ __vc_elm_handle = dlopen(PATH_LIB_VC_ELM, RTLD_LAZY | RTLD_GLOBAL);
+ if (!__vc_elm_handle) {
+ _E("Failed to open %s", PATH_LIB_VC_ELM);
+ return -1;
+ }
+
+ __vc_elm_initialize = dlsym(__vc_elm_handle, "vc_elm_initialize");
+ if (!__vc_elm_initialize) {
+ _E("Failed to load vc_elm_initialize");
+ __unload_vc_elm();
+ return -1;
+ }
+
+ __vc_elm_deinitialize = dlsym(__vc_elm_handle, "vc_elm_deinitialize");
+ if (!__vc_elm_deinitialize) {
+ _E("Failed to load vc_elm_deinitialize");
+ __unload_vc_elm();
+ return -1;
+ }
+
+ __vc_elm_set_auto_register_mode = dlsym(__vc_elm_handle,
+ "vc_elm_set_auto_register_mode");
+ if (!__vc_elm_set_auto_register_mode) {
+ _E("Failed to load vc_elm_set_auto_register_mode");
+ __unload_vc_elm();
+ return -1;
+ }
+
+ return 0;
+}
+
static void __vc_vtauto_changed_cb(keynode_t *key, void *data)
{
const char *name;
@@ -156,12 +216,12 @@ static void __vc_vtauto_changed_cb(keynode_t *key, void *data)
vt_automode = vconf_keynode_get_bool(key);
if (vt_automode) {
if (!__vc_elm_initialized) {
- vc_elm_initialize();
+ __vc_elm_initialize();
__vc_elm_initialized = true;
}
- vc_elm_set_auto_register_mode(2, 0);
+ __vc_elm_set_auto_register_mode(2, 0);
} else {
- vc_elm_deinitialize();
+ __vc_elm_deinitialize();
__vc_elm_initialized = false;
}
}
@@ -169,16 +229,21 @@ static void __vc_vtauto_changed_cb(keynode_t *key, void *data)
static void __vc_elm_init(void)
{
int vt_automode = 0;
+ int r;
+
+ r = __load_vc_elm();
+ if (r < 0)
+ return;
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_initialize();
__vc_elm_initialized = true;
}
- vc_elm_set_auto_register_mode(2, 0);
+ __vc_elm_set_auto_register_mode(2, 0);
}
setenv("VC_ELM_INIT", "1", 1);