output_modality : add output modality voice touch 77/281577/1
authorulgal-park <ulgal.park@samsung.com>
Mon, 5 Sep 2022 05:16:37 +0000 (14:16 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Tue, 20 Sep 2022 04:20:23 +0000 (13:20 +0900)
Change-Id: Icc34123eed47d36220e40d37d95a1a59388b0026

packaging/mmi-manager.spec
src/mmimgr/meson.build
src/mmimgr/mmi-common.h
src/mmimgr/mmi-core.c
src/mmimgr/output_modality/TouchModule.cpp [new file with mode: 0644]
src/mmimgr/output_modality/TouchModule.h [new file with mode: 0644]
src/mmimgr/output_modality/mmi_output_modality.cpp [new file with mode: 0644]
src/mmimgr/output_modality/mmi_output_modality.h [new file with mode: 0644]

index 57c3de9..ff4cafe 100644 (file)
@@ -27,6 +27,8 @@ BuildRequires:        pkgconfig(opencv)
 BuildRequires: pkgconfig(gstreamer-1.0)
 BuildRequires: pkgconfig(gstreamer-base-1.0)
 BuildRequires: pkgconfig(gstreamer-app-1.0)
+BuildRequires: pkgconfig(libaurum)
+BuildRequires: pkgconfig(capi-system-info)
 
 #Build dependencies for tests
 BuildRequires: pkgconfig(gmock)
index 56622bf..306c793 100644 (file)
@@ -35,7 +35,11 @@ mmimgr_srcs = [
        'iu/CommandManager.cpp',
        'iu/CommandManager.h',
        'iu/json_provider.cpp',
-       'iu/json_provider.h'
+       'iu/json_provider.h',
+       'output_modality/mmi_output_modality.cpp',
+       'output_modality/mmi_output_modality.h',
+       'output_modality/TouchModule.cpp',
+       'output_modality/TouchModule.h',
        ]
 
 install_headers(
@@ -57,6 +61,8 @@ rpc_port_dep = dependency('rpc-port')
 json_glib_dep = dependency('json-glib-1.0')
 libtzplatform_config_dep = dependency('libtzplatform-config')
 xkbcommon_dep = dependency('xkbcommon', method : 'pkg-config')
+aurum_dep = dependency('libaurum', method : 'pkg-config')
+system_info_dep = dependency('capi-system-info', method : 'pkg-config')
 
 mmimgr_deps = [
        ecore_dep,
@@ -67,7 +73,10 @@ mmimgr_deps = [
        rpc_port_dep,
        json_glib_dep,
        libtzplatform_config_dep,
-       xkbcommon_dep]
+       xkbcommon_dep,
+       aurum_dep,
+       system_info_dep
+       ]
 
 mmimgr_include_dirs = include_directories('.')
 
index 75c2b4f..69f4e29 100644 (file)
@@ -149,6 +149,12 @@ typedef enum mmi_event_state_change_type
        MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE
 } mmi_event_state_change_type;
 
+typedef enum mmi_voice_touch_mode
+{
+       MMI_VOICE_TOUCH_MODE_TOOLTIP,
+       MMI_VOICE_TOUCH_MODE_GRID
+} mmi_voice_touch_mode;
+
 typedef struct
 {
        int type;
@@ -281,6 +287,15 @@ typedef struct
        GList *list;  // clickable_item
 } mmi_provider_event_screen_analyzer;
 
+typedef struct
+{
+       int mode;// tooltip, grid
+       int timestamp;
+       const char *object_id;
+       int coord_x;
+       int coord_y;
+} mmi_output_modality_voice_touch;
+
 typedef unsigned long long ull;
 
 typedef enum mmi_state
index efb515c..7a72e58 100644 (file)
@@ -194,6 +194,9 @@ static void __init_event_handler()
 int mmi_core_init()
 {
        _I("Initialize MMI core module");
+
+       output_modality_initialize();
+
        int ret = MMI_IU_ERROR_NONE;
        ret = mmi_iu_init();
        if (ret != MMI_IU_ERROR_NONE) {
@@ -223,6 +226,8 @@ int mmi_core_shutdown()
        _I("Shutdown MMI core module");
        __shutdown_event_handler();
 
+       output_modality_shutdown();
+
        int ret = mmi_iu_shutdown();
        return ret;
 }
diff --git a/src/mmimgr/output_modality/TouchModule.cpp b/src/mmimgr/output_modality/TouchModule.cpp
new file mode 100644 (file)
index 0000000..451e541
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *               http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+#include <Aurum.h>
+#include <string>
+#include <memory>
+#include <system_info.h>
+
+#include "mmi-manager-dbg.h"
+#include "TouchModule.h"
+
+#define TIZEN_PROFILE_TV (get_tizen_profile() == _PROFILE_TV)
+#define TIZEN_PROFILE_COMMON (get_tizen_profile() == _PROFILE_COMMON)
+
+typedef enum {
+       _PROFILE_UNKNOWN = 0,
+       _PROFILE_MOBILE = 0x1,
+       _PROFILE_WEARABLE = 0x2,
+       _PROFILE_TV = 0x4,
+       _PROFILE_IVI = 0x8,
+       _PROFILE_COMMON = 0x10,
+} tizen_profile_e;
+
+static tizen_profile_e get_tizen_profile()
+{
+       tizen_profile_e profile;
+       char *profileName = NULL;
+
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       switch (*profileName) {
+       case 't':
+       case 'T':
+               profile = _PROFILE_TV;
+               break;
+       case 'm':
+       case 'M':
+               profile = _PROFILE_MOBILE;
+               break;
+       default:
+               profile = _PROFILE_COMMON;
+       }
+
+       free(profileName);
+       return profile;
+}
+
+TouchModule::TouchModule()
+{
+       Aurum::AccessibleWatcher::getInstance();
+}
+
+TouchModule::~TouchModule()
+{
+
+}
+
+bool TouchModule::ClickByObjectId(std::string objectId)
+{
+       LOGD("execute by object id = %s", objectId.c_str());
+       std::shared_ptr<Aurum::UiDevice> device = Aurum::UiDevice::getInstance();
+       auto sel = std::make_shared<Aurum::UiSelector>();
+       bool ret = false;
+
+       sel->id(objectId);
+       std::shared_ptr<Aurum::UiObject> found = device->findObject(sel);
+
+       if (nullptr == found) {
+               return false;
+       }
+
+       LOGD("click object = %s", objectId.c_str());
+       found->getAccessibleNode()->print(1,1);
+       if (TIZEN_PROFILE_TV) {
+               found->setFocus();
+               std::string input_text("Return");
+               ret = device->pressKeyCode(input_text, Aurum::KeyRequestType::PRESS);
+               LOGD("press ret = %d", ret);
+
+               ret = device->pressKeyCode(input_text, Aurum::KeyRequestType::RELEASE);
+               LOGD("release ret = %d", ret);
+               LOGD("clicked keyname result = %d", ret);
+       } else {
+               found->click();
+               ret = true;
+       }
+       return ret;
+}
+
+bool TouchModule::ClickByCoordinate(int x, int y)
+{
+       LOGD("execute by coordinate = %d, %d", x, y);
+       std::shared_ptr<Aurum::UiDevice> device = Aurum::UiDevice::getInstance();
+       bool ret = false;
+       ret = device->click(x,y);
+       LOGD("clicked, ret = %d", ret);
+       return ret;
+}
\ No newline at end of file
diff --git a/src/mmimgr/output_modality/TouchModule.h b/src/mmimgr/output_modality/TouchModule.h
new file mode 100644 (file)
index 0000000..fa86c39
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *               http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+
+#ifndef __TOUCH_MODULE_H__
+#define __TOUCH_MODULE_H__
+
+#include <unistd.h>
+#include <string>
+
+class TouchModule
+{
+public:
+       TouchModule();
+       virtual ~TouchModule();
+
+       bool ClickByObjectId(std::string key);
+       bool ClickByCoordinate(int x, int y);
+};
+
+#endif /* __TOUCH_MODULE_H__ */
\ No newline at end of file
diff --git a/src/mmimgr/output_modality/mmi_output_modality.cpp b/src/mmimgr/output_modality/mmi_output_modality.cpp
new file mode 100644 (file)
index 0000000..880d068
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *               http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+
+#include <string>
+
+#include "mmi-common.h"
+#include "TouchModule.h"
+#include "mmi-manager-dbg.h"
+#include "mmi_output_modality.h"
+
+static TouchModule *g_touch_module = nullptr;
+
+EXPORT_API void output_modality_initialize()
+{
+       LOGD("initialize output modality");
+       g_touch_module = new TouchModule();
+}
+
+EXPORT_API void output_modality_shutdown()
+{
+       LOGD("shutdown output modality");
+       if (g_touch_module) {
+               delete g_touch_module;
+               g_touch_module = NULL;
+       }
+}
+
+EXPORT_API int output_modality_voice_touch(mmi_output_modality_voice_touch modality)
+{
+       mmi_voice_touch_mode mode = (mmi_voice_touch_mode)modality.mode;
+       int ret = 0;
+
+       if (MMI_VOICE_TOUCH_MODE_TOOLTIP == mode) {
+               LOGD("voice touch by tooltip");
+               std::string objID = std::string(modality.object_id, strlen(modality.object_id));
+               ret = g_touch_module->ClickByObjectId(objID);
+       } else if (MMI_VOICE_TOUCH_MODE_GRID == mode) {
+               LOGD("voice touch by grid");
+               ret = g_touch_module->ClickByCoordinate(modality.coord_x, modality.coord_y);
+       } else {
+               return 0;
+       }
+       LOGD("voice touch done");
+
+       return ret;
+}
diff --git a/src/mmimgr/output_modality/mmi_output_modality.h b/src/mmimgr/output_modality/mmi_output_modality.h
new file mode 100644 (file)
index 0000000..135635a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *               http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+#ifndef __MMI_OUTPUT_MODALITY_H__
+#define __MMI_OUTPUT_MODALITY_H__
+
+#include "mmi-common.h"
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Initialize MMI Output Modality Manager
+ */
+void output_modality_initialize();
+
+
+/**
+ * @brief Shutdown MMI Output Modality Manager
+ */
+void output_modality_shutdown();
+
+/**
+ * @brief Act MMI Output Modality Voice Touch
+ *
+ * @return int 1 on success, 0 on fail
+ */
+int output_modality_voice_touch(mmi_output_modality_voice_touch modality);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MMI_OUTPUT_MODALITY_H__ */
\ No newline at end of file