From 27f50529716444a5a67197aa84905a2fc321a471 Mon Sep 17 00:00:00 2001 From: Sungwook Park Date: Wed, 19 Aug 2020 20:14:16 +0900 Subject: [PATCH 01/16] Remove unused code Change-Id: I794bd8c96e37c752fe30ca2130d10387726a6434 Signed-off-by: Sungwook Park --- client/gesture_client_dbus.c | 23 ----------------------- engine/gesture_engine_dbus.c | 27 --------------------------- server/gestured_dbus.c | 6 ------ 3 files changed, 56 deletions(-) diff --git a/client/gesture_client_dbus.c b/client/gesture_client_dbus.c index 91b139d..ce5eec6 100644 --- a/client/gesture_client_dbus.c +++ b/client/gesture_client_dbus.c @@ -25,8 +25,6 @@ #define LOG_TAG "GESTURE_CLIENT_DBUS" static int is_server_started = 0; -static hand_gesture_recognition_cb g_callback; -static hand_gesture_data_h g_gesture_data; static hand_gesture_handtype_e g_hand_type = HAND_GESTURE_LEFT_HAND; static hand_gesture_workmode_e g_work_mode = HAND_GESTURE_WORK_MODE_ONE_WAY; @@ -36,12 +34,6 @@ static int g_sensitivity = 1; static char *g_engine_app_id; static char *g_engine_name; -static void _free_gesture_data(hand_gesture_data_h gesture_data) -{ - free(gesture_data); - gesture_data = NULL; -} - static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) { LOGD("name : %s, name_owner : %s", name, name_owner); @@ -124,16 +116,6 @@ static void _handle_gesture_cb(GDBusConnection *connection, g_free(printmsg); LOGD("[event = %d] [gesture_type = %d] [ltype = %d] [levent = %d] [lcount = %d]", event, gesture_type, ltype, levent, lcount); #endif - if (g_gesture_data == NULL){ - LOGD("Can't send the result to Client because g_gesture_data is NULL"); - return; - } - LOGD("address = %p", g_gesture_data); - g_gesture_data->gesture_type = ltype; - g_gesture_data->event = levent; - g_gesture_data->detected_Count = lcount; - -// g_callback(gesture_type, g_gesture_data, 0, HAND_GESTURE_ERROR_NONE, user_data); if (_handle->recog_cb) { LOGD("[CLIENT DBUS] Send recognition result. gesture_type(%d)", gesture_type); _handle->recog_cb(_handle, gesture_type, 0, HAND_GESTURE_ERROR_NONE, _handle->recog_user_data); @@ -552,8 +534,6 @@ int gesture_client_dbus_start_recognition(GDBusConnection *gdbus_connection, han { LOGD("gesture_client_dbus_start_recognition start"); LOGD("client busname: %s", g_dbus_connection_get_unique_name(gdbus_connection)); - g_callback = callback; - g_gesture_data = gesture_data; GVariant *body = NULL; body = g_variant_new("(iiiii)", gesture_type, g_hand_type, g_work_mode, g_option, g_sensitivity); @@ -572,9 +552,6 @@ int gesture_client_dbus_stop_recognition(GDBusConnection *gdbus_connection) GDBusMessage *reply = NULL; GVariant *body = NULL; - /* free for gesture data struct */ - _free_gesture_data(g_gesture_data); - body = g_variant_new("()"); ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_STOP_RECOGNITION); if (ret != HAND_GESTURE_ERROR_NONE) diff --git a/engine/gesture_engine_dbus.c b/engine/gesture_engine_dbus.c index f9d6199..c0aa267 100644 --- a/engine/gesture_engine_dbus.c +++ b/engine/gesture_engine_dbus.c @@ -486,34 +486,7 @@ int gesture_engine_dbus_main_start(GDBusConnection *gdbus_connection, gesture_en body = g_variant_new("(i)", 100); ret = gdbus_send_message_with_async(gdbus_connection, body, GESTURE_ENGINE_MSG_MAIN_START); -#if 0 - GError *err = NULL; - if (!g_dbus_connection_emit_signal(gdbus_connection, - GESTURE_DBUS_NAME, - GESTURE_OBJECT_PATH, - GESTURE_INTERFACE_NAME, - "psw_test", - body, - &err)) { - if (err != NULL) { - LOGE("Failed to send dbus message : %s", err->message); - g_error_free(err); - } - return GESTURE_ENGINE_ERROR_NONE; - } - - GDBusProxy *ap; - g_dbus_proxy_new (gdbus_connection, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - GESTURE_DBUS_NAME, /* name */ - GESTURE_OBJECT_PATH, /* object path */ - GESTURE_INTERFACE_NAME, /* interface name */ - NULL, /* GCancellable */ - (GAsyncReadyCallback) proxy_new_cb, - &ap); -#endif if (body) g_variant_unref(body); diff --git a/server/gestured_dbus.c b/server/gestured_dbus.c index b696ca3..88f7c5b 100644 --- a/server/gestured_dbus.c +++ b/server/gestured_dbus.c @@ -430,9 +430,6 @@ static void _gestured_client_dbus_method_call_handler(GDBusConnection *conn, con LOGD("[GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO] called"); ret = gestured_engine_send_engine_get_info(parameters, &reply_body, sender); } - else if (g_strcmp0(method_name, "psw_test") == 0) { - LOGD("[psw_test] called"); - } if (ret == GESTURED_ERROR_NONE) { LOGD("method_call successful, method_name : %s", method_name); @@ -526,9 +523,6 @@ int gestured_register_dbus_interface(void) " " " " - " " - " " - " " " " " "; -- 2.7.4 From 13881d6b9843cdd6feb9ac2459fd47de57ce5336 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 19 Aug 2020 15:19:34 +0900 Subject: [PATCH 02/16] [ACR-1585][gesture][Fix descriptions in header files] - Fix dbus policy issue Change-Id: Iff9779e0a3e03e6aeda036b640c713f6eb24d113 Signed-off-by: sooyeon.kim --- doc/uix_gesture_doc.h | 2 +- include/gesture.h | 32 +++++++++++++++++++++----------- include/gesture_common.h | 2 +- packaging/capi-ui-gesture.conf | 14 ++++++-------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/doc/uix_gesture_doc.h b/doc/uix_gesture_doc.h index 042d0dd..54a528e 100644 --- a/doc/uix_gesture_doc.h +++ b/doc/uix_gesture_doc.h @@ -40,7 +40,7 @@ * * @section CAPI_UIX_GESTURE_MODULE_FEATURE Related Features * This API is related with the following features:
- * - http://tizen.org/feature/sensor.gesture_recognition
+ * - %http://tizen.org/feature/sensor.gesture_recognition
* It is recommended to design feature related codes in your application for reliability.
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.
* To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
diff --git a/include/gesture.h b/include/gesture.h index 6b4f13e..1171bd0 100644 --- a/include/gesture.h +++ b/include/gesture.h @@ -41,6 +41,11 @@ typedef struct hand_gesture_s *hand_gesture_h; /** * @brief Called when a gesture is detected. + * @details Following error codes can be delivered: \n + * #HAND_GESTURE_ERROR_NONE, \n + * #HAND_GESTURE_ERROR_NOT_SUPPORTED, \n + * #HAND_GESTURE_ERROR_INVALID_PARAMETER, \n + * #HAND_GESTURE_ERROR_OPERATION_FAILED * * @since_tizen @if WEARABLE 6.0 @endif * @remarks The @a handle is managed by the platform and will be released when hand_gesture_destroy() is called. @@ -48,11 +53,11 @@ typedef struct hand_gesture_s *hand_gesture_h; * @param[in] handle A gesture handle * @param[in] gesture A gesture type detected * @param[in] timestamp The time when the gesture is detected. Epoch time in seconds. - * @param[in] error An error value. It can be one of the following error values:@n - * #HAND_GESTURE_ERROR_NONE, if the operation succeeded.@n - * #HAND_GESTURE_ERROR_NOT_SUPPORTED, if the gesture is not supported in the current profile.@n - * #HAND_GESTURE_ERROR_OPERATION_FAILED, if the operation failed because of a system error.@n - * #HAND_GESTURE_ERROR_PERMISSION_DENIED, if the application has no permission to use this. + * @param[in] error An error value. It can be one of the following error values: \n + * #HAND_GESTURE_ERROR_NONE, if the operation succeeded.\n + * #HAND_GESTURE_ERROR_NOT_SUPPORTED, if the gesture is not supported on the device.\n + * #HAND_GESTURE_ERROR_INVALID_PARAMETER, if the parameter is invalid. \n + * #HAND_GESTURE_ERROR_OPERATION_FAILED, if the operation failed because of a system error. * @param[in] user_data The user data is passed to hand_gesture_start_recognition() * * @see hand_gesture_start_recognition() @@ -61,6 +66,11 @@ typedef void(* hand_gesture_recognition_cb)(hand_gesture_h handle, hand_gesture_ /** * @brief Called when an error is occurred. + * @details Following error codes can be delivered: \n + * #HAND_GESTURE_ERROR_INVALID_PARAMETER, \n + * #HAND_GESTURE_ERROR_INVALID_OPERATION, \n + * #HAND_GESTURE_ERROR_OUT_OF_MEMORY, \n + * #HAND_GESTURE_ERROR_OPERATION_FAILED * * @since_tizen @if WEARABLE 6.0 @endif * @remarks The @a handle is the same object for which the callback was set. @@ -68,10 +78,10 @@ typedef void(* hand_gesture_recognition_cb)(hand_gesture_h handle, hand_gesture_ * The @a msg is managed by the platform and will be released when invoking this callback function is finished. * * @param[in] handle A gesture handle - * @param[in] error An error value. It can be one of the following error values: @n - * #HAND_GESTURE_ERROR_INVALID_PARAMETER, - * #HAND_GESTURE_ERROR_INVALID_OPERATION, - * #HAND_GESTURE_ERROR_OUT_OF_MEMORY, + * @param[in] error An error value. It can be one of the following error values: \n + * #HAND_GESTURE_ERROR_INVALID_PARAMETER, \n + * #HAND_GESTURE_ERROR_INVALID_OPERATION, \n + * #HAND_GESTURE_ERROR_OUT_OF_MEMORY, \n * #HAND_GESTURE_ERROR_OPERATION_FAILED * @param[in] msg An error message from gesture engine service * @param[in] user_data The user data is passed to hand_gesture_set_error_cb() @@ -83,13 +93,13 @@ typedef void(* hand_gesture_error_cb)(hand_gesture_h handle, hand_gesture_error_ /** * @brief Checks whether a gesture is supported or not. - * @details Check if the given gesture type is supported in the current device. + * @details Check if the given gesture type is supported on the device. * * @since_tizen @if WEARABLE 6.0 @endif * * @param[in] handle A gesture handle * @param[in] gesture A gesture type to be checked - * @param[out] supported @c true if the gesture is recognizable in the current device,@n + * @param[out] supported @c true if the gesture is recognizable on the device,\n * @c false otherwise * * @return @c 0 if the @c gesture is supported, otherwise a negative error value diff --git a/include/gesture_common.h b/include/gesture_common.h index 0aaf39a..a8954c6 100644 --- a/include/gesture_common.h +++ b/include/gesture_common.h @@ -51,11 +51,11 @@ typedef struct hand_gesture_data_s* hand_gesture_data_h; */ typedef enum { HAND_GESTURE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + HAND_GESTURE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ HAND_GESTURE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */ HAND_GESTURE_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Function not implemented */ HAND_GESTURE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ HAND_GESTURE_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ - HAND_GESTURE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ HAND_GESTURE_ERROR_ALREADY_STARTED = TIZEN_ERROR_GESTURE | 0x01, /**< Recognition is already started */ HAND_GESTURE_ERROR_NOT_STARTED = TIZEN_ERROR_GESTURE | 0x02, /**< Recognition is not started */ HAND_GESTURE_ERROR_OPERATION_FAILED = TIZEN_ERROR_GESTURE | 0x04, /**< Operation failed because of a system error */ diff --git a/packaging/capi-ui-gesture.conf b/packaging/capi-ui-gesture.conf index d48278d..2514f02 100644 --- a/packaging/capi-ui-gesture.conf +++ b/packaging/capi-ui-gesture.conf @@ -1,17 +1,15 @@ - - - - - + + + - - + + - \ No newline at end of file + -- 2.7.4 From 56a365855b2963be83b84c553597e2d05be3fe68 Mon Sep 17 00:00:00 2001 From: Sungwook Park Date: Thu, 20 Aug 2020 21:49:59 +0900 Subject: [PATCH 03/16] change install directory of service file Change-Id: Id30e0c1eedf1505c8cbe338bae912cb080ac23a6 Signed-off-by: Sungwook Park --- packaging/capi-ui-gesture.spec | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packaging/capi-ui-gesture.spec b/packaging/capi-ui-gesture.spec index 2be8bf7..7fb84c2 100644 --- a/packaging/capi-ui-gesture.spec +++ b/packaging/capi-ui-gesture.spec @@ -77,9 +77,8 @@ find . -name '*.gcno' -exec cp '{}' gcov-obj ';' rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants +mkdir -p %{buildroot}%{_prefix}/lib/systemd/system install -m 0644 %SOURCE1 %{buildroot}%{_unitdir}/capi-ui-gesture.service -%install_service multi-user.target.wants capi-ui-gesture.service mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services install -m 0644 %SOURCE2 %{buildroot}%{_datadir}/dbus-1/system-services/org.tizen.gesture.server.service @@ -106,7 +105,6 @@ cp %{SOURCE3} %{buildroot}/etc/dbus-1/system.d/capi-ui-gesture.conf %{_libdir}/lib*.so %attr(0755,ui_fw,ui_fw) %{_bindir}/gesture-server %attr(0644,root,root) %{_unitdir}/capi-ui-gesture.service -%attr(0644,root,root) %{_unitdir}/multi-user.target.wants/capi-ui-gesture.service %attr(0644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.gesture.server.service %config %{_sysconfdir}/dbus-1/system.d/capi-ui-gesture.conf -- 2.7.4 From 7f8c9108299772eb510e8f2470bdf81b48fd3e66 Mon Sep 17 00:00:00 2001 From: Sungwook Park Date: Tue, 25 Aug 2020 13:57:57 +0900 Subject: [PATCH 04/16] Remove unused file Change-Id: I13d5f61a0326bb325aeba0473f61de4c88a1deb5 Signed-off-by: Sungwook Park --- CMakeLists.txt | 4 ++-- client/CMakeLists.txt | 1 - client/GestureSensor.c | 56 -------------------------------------------------- client/GestureSensor.h | 48 ------------------------------------------- client/gesture.c | 1 - client/gesture_main.h | 1 - 6 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 client/GestureSensor.c delete mode 100644 client/GestureSensor.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0872c9c..5ccea7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,8 @@ pkg_check_modules(pkgs REQUIRED cynara-session capi-appfw-app-common capi-appfw-app-control - capi-appfw-app-manager - capi-appfw-package-manager + capi-appfw-app-manager + capi-appfw-package-manager dbus-1 capi-system-info aul diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index ebc91f2..c2a5176 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,6 +1,5 @@ SET(SRCS gesture.c - GestureSensor.c gesture_client_dbus.c ) diff --git a/client/GestureSensor.c b/client/GestureSensor.c deleted file mode 100644 index 9f4818b..0000000 --- a/client/GestureSensor.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. - * - * 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 "GestureSensor.h" - - - -bool setGesture(hand_gesture_type_e type) -{ - return true; -} - -void setPowerSave(bool ps) -{ - -} - -void setCallback(hand_gesture_recognition_cb cb) -{ - -} - -void setUserData(void* data) -{ - -} - -bool start() -{ - return true; -} - -bool stop() -{ - return true; -} - -bool isSensorSupported(hand_gesture_type_e type) -{ - return true; -} - diff --git a/client/GestureSensor.h b/client/GestureSensor.h deleted file mode 100644 index c092532..0000000 --- a/client/GestureSensor.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. - * - * 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 __GESTURE_SENSOR_H__ -#define __GESTURE_SENSOR_H__ - -#include "gesture_main.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -bool setGesture(hand_gesture_type_e type); -void setPowerSave(bool ps); -void setCallback(hand_gesture_recognition_cb cb); -void setUserData(void* data); - -bool start(); -bool stop(); - -bool isSensorSupported(hand_gesture_type_e type); - -hand_gesture_type_e __gestureType; -hand_gesture_recognition_cb __callback; -void *__userData; - - -#ifdef __cplusplus -} -#endif - -#endif /* __GESTURE_SENSOR_H__ */ - diff --git a/client/gesture.c b/client/gesture.c index 96fe1be..df6ae46 100644 --- a/client/gesture.c +++ b/client/gesture.c @@ -304,7 +304,6 @@ EXPORT_API int hand_gesture_stop_recognition(hand_gesture_h handle) CHECK_GESTURE_FEATURE(); ASSERT_NOT_NULL(handle); - IF_FAIL_RETURN(stop(), HAND_GESTURE_ERROR_NOT_STARTED); int ret = HAND_GESTURE_ERROR_NONE; ret = gesture_client_dbus_stop_recognition(handle->gdbus_connection); diff --git a/client/gesture_main.h b/client/gesture_main.h index c35f331..4688228 100644 --- a/client/gesture_main.h +++ b/client/gesture_main.h @@ -20,7 +20,6 @@ #include #include #include "gesture.h" -#include #ifdef __cplusplus -- 2.7.4 From decd5d812343bd03855955b33bcd287995b77e63 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Mon, 24 Aug 2020 15:43:22 +0900 Subject: [PATCH 05/16] Move privilege checker to gesture-server Change-Id: I013b3509f39f47ca776262a3eeb0e178f406ee6f Signed-off-by: sooyeon.kim --- client/gesture.c | 43 ++++++++++++----- client/gesture_client_dbus.c | 24 ++++++---- client/gesture_client_dbus.h | 2 +- client/gesture_main.h | 3 ++ engine/gesture_engine_dbus.c | 2 +- manager/gestured_client_manager.cpp | 3 +- manager/gestured_client_manager.h | 1 + server/gestured_dbus.c | 95 ++++++++++++++++++++++++++++++++++++- 8 files changed, 149 insertions(+), 24 deletions(-) diff --git a/client/gesture.c b/client/gesture.c index df6ae46..17065d1 100644 --- a/client/gesture.c +++ b/client/gesture.c @@ -51,26 +51,35 @@ static int _cynara_initialize() return ret; } -static int _check_privilege(const char *uid, const char *privilege) +static char * _get_smack_label() { - int ret; FILE *fp = NULL; char label_path[1024] = "/proc/self/attr/current"; - char smack_label[1024] = {'\0',}; - - if (!p_cynara) { - return -1; - } + static char smack_label[1024] = {'\0',}; fp = fopen(label_path, "r"); if (fp != NULL) { - ret = fread(smack_label, 1, sizeof(smack_label), fp); + int ret = fread(smack_label, 1, sizeof(smack_label), fp); if (ret <= 0) LOGE("Failed to fread"); fclose(fp); } + return smack_label; +} + +static int _check_privilege(const char *uid, const char *privilege) +{ + int ret; + char smack_label[1024] = {'\0',}; + + if (!p_cynara) { + return -1; + } + + strcpy(smack_label, _get_smack_label()); + pid_t pid = getpid(); char *session = cynara_session_from_pid(pid); ret = cynara_check(p_cynara, smack_label, session, uid, privilege); @@ -93,7 +102,8 @@ static void _cynara_deinitialize() p_cynara = NULL; } -static int _gesture_check_privilege() { +static int _gesture_check_privilege() +{ char uid[16]; int ret = HAND_GESTURE_ERROR_NONE; @@ -130,22 +140,31 @@ EXPORT_API int hand_gesture_create(hand_gesture_h *handle) if (!_struct) return HAND_GESTURE_ERROR_OUT_OF_MEMORY; + /* get uid and smack label */ + snprintf(_struct->uid, 16, "%d", getuid()); + + strcpy(_struct->smack_label, _get_smack_label()); + + LOGI("uid(%s), smack(%s)", _struct->uid, _struct->smack_label); + ret = gesture_client_dbus_init(&_struct->gdbus_connection, &_struct->server_watcher_id, - &_struct->monitor_id, &_struct->server_monitor_id, GESTURE_CLIENT_LIB_GESTURE, (void *)_struct); + &_struct->monitor_id, &_struct->server_monitor_id, GESTURE_CLIENT_LIB_GESTURE, _struct->uid, _struct->smack_label, (void *)_struct); if (ret != HAND_GESTURE_ERROR_NONE) { LOGE("Failed to initialize dbus : %d", ret); free(_struct); return HAND_GESTURE_ERROR_OPERATION_FAILED; } - *handle = _struct; - ret = gesture_client_dbus_initialize_engine(_struct->gdbus_connection); if (ret != HAND_GESTURE_ERROR_NONE) { LOGE("Failed to initialize engine dbus : %d", ret); + free(_struct); return HAND_GESTURE_ERROR_OPERATION_FAILED; } + *handle = _struct; + + return HAND_GESTURE_ERROR_NONE; } diff --git a/client/gesture_client_dbus.c b/client/gesture_client_dbus.c index ce5eec6..532ac88 100644 --- a/client/gesture_client_dbus.c +++ b/client/gesture_client_dbus.c @@ -34,6 +34,7 @@ static int g_sensitivity = 1; static char *g_engine_app_id; static char *g_engine_name; + static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) { LOGD("name : %s, name_owner : %s", name, name_owner); @@ -338,19 +339,22 @@ static int gdbus_send_message_with_async(GDBusConnection *gdbus_connection, GVar return ret; } -static int _monitor_register(GDBusConnection *gdbus_connection) +static int _monitor_register(GDBusConnection *gdbus_connection, const char *uid, const char *smack_label) { int ret; GDBusMessage *reply = NULL; GVariant *client_body = NULL; char appid[1024] = {0, }; - ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); + int pid = getpid(); + ret = aul_app_get_appid_bypid(pid, appid, sizeof(appid)); if (ret != 0) { LOGE("aul_app_get_appid_bypid() failed : %d", ret); } - client_body = g_variant_new("(iis)", 11, GESTURE_CLIENT_LIB_GESTURE, appid); + LOGI("[INFO] appid(%s), pid(%d), uid(%s), smack_label(%s)", appid, pid, uid, smack_label); + + client_body = g_variant_new("(iisiss)", 11, GESTURE_CLIENT_LIB_GESTURE, appid, pid, uid, smack_label); ret = gdbus_send_message_with_sync(gdbus_connection, client_body, &reply, GESTURE_MSG_SERVICE_REGISTER); if (reply) @@ -373,8 +377,12 @@ static void _on_name_appeared(GDBusConnection *connection, const gchar *name_owner, gpointer user_data) { - if (is_server_started == 0) - _monitor_register(connection); + struct hand_gesture_s *_struct = user_data; + + if (is_server_started == 0) { + LOGI("uid(%s), smack_label(%s)", _struct->uid, _struct->smack_label); + _monitor_register(connection, _struct->uid, _struct->smack_label); + } } static void _on_name_vanished(GDBusConnection *connection, @@ -385,7 +393,7 @@ static void _on_name_vanished(GDBusConnection *connection, } int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id, - int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, void *data) + int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, const char *uid, const char *smack_label, void *data) { LOGD("gesture_client_dbus_init start"); @@ -403,7 +411,7 @@ int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_w return ret; } - ret = _monitor_register(*gdbus_connection); + ret = _monitor_register(*gdbus_connection, uid, smack_label); if (ret != HAND_GESTURE_ERROR_NONE) { LOGE("_monitor_register() failed : %d", ret); return ret; @@ -416,7 +424,7 @@ int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_w G_BUS_NAME_WATCHER_FLAGS_NONE, _on_name_appeared, _on_name_vanished, - NULL, + data, NULL); if (*server_monitor_id == 0) { g_dbus_connection_signal_unsubscribe(*gdbus_connection, *monitor_id); diff --git a/client/gesture_client_dbus.h b/client/gesture_client_dbus.h index b3666be..0ae8bdc 100644 --- a/client/gesture_client_dbus.h +++ b/client/gesture_client_dbus.h @@ -31,7 +31,7 @@ extern "C" { #endif -int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id, int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, void *data); +int gesture_client_dbus_init(GDBusConnection **gdbus_connection, guint *server_watcher_id, int *monitor_id, int *server_monitor_id, CLIENT_LIB lib, const char *uid, const char *smack_label, void *data); int gesture_client_dbus_shutdown(GDBusConnection *gdbus_connection, int *server_monitor_id, int *monitor_id); int gesture_client_dbus_initialize_engine(GDBusConnection *gdbus_connection); int gesture_client_dbus_deinitialize_engine(GDBusConnection *gdbus_connection); diff --git a/client/gesture_main.h b/client/gesture_main.h index 4688228..04f0480 100644 --- a/client/gesture_main.h +++ b/client/gesture_main.h @@ -33,6 +33,9 @@ struct hand_gesture_s { int monitor_id; int server_monitor_id; + char uid[16]; + char smack_label[1024]; + hand_gesture_recognition_cb recog_cb; void* recog_user_data; hand_gesture_error_cb error_cb; diff --git a/engine/gesture_engine_dbus.c b/engine/gesture_engine_dbus.c index c0aa267..3eeb674 100644 --- a/engine/gesture_engine_dbus.c +++ b/engine/gesture_engine_dbus.c @@ -367,7 +367,7 @@ static int _monitor_register(GDBusConnection *gdbus_connection) return GESTURE_ENGINE_ERROR_OPERATION_FAILED; } - engine_body = g_variant_new("(iis)", 22, GESTURE_CLIENT_LIB_ENGINE, appid); + engine_body = g_variant_new("(iisiss)", 22, GESTURE_CLIENT_LIB_ENGINE, appid, getpid(), "NULL", "NULL"); ret = gdbus_send_message_with_sync(gdbus_connection, engine_body, &reply, GESTURE_MSG_SERVICE_REGISTER); if (reply) diff --git a/manager/gestured_client_manager.cpp b/manager/gestured_client_manager.cpp index 970f080..04930a4 100644 --- a/manager/gestured_client_manager.cpp +++ b/manager/gestured_client_manager.cpp @@ -31,7 +31,7 @@ gesture_manager_client_s* GestureManagerClientCreate(const char* pkg_name) client = NULL; return NULL; } - + client->gestureType = -1; client->requestTypeCount = -1; client->clientLib = GESTURE_CLIENT_LIB_NONE; @@ -41,6 +41,7 @@ gesture_manager_client_s* GestureManagerClientCreate(const char* pkg_name) client->gdbus_connection = NULL; client->state = CLIENT_STATE_NONE; client->response_cb = NULL; + client->is_permitted = false; return client; } diff --git a/manager/gestured_client_manager.h b/manager/gestured_client_manager.h index 35238b6..66b6b14 100644 --- a/manager/gestured_client_manager.h +++ b/manager/gestured_client_manager.h @@ -31,6 +31,7 @@ typedef struct { GDBusConnection *gdbus_connection; gesture_manager_client_state_e state; hand_gesture_recognition_cb *response_cb; + bool is_permitted; } gesture_manager_client_s; gesture_manager_client_s* GestureManagerClientCreate(const char* pkg_name); diff --git a/server/gestured_dbus.c b/server/gestured_dbus.c index 88f7c5b..20a956e 100644 --- a/server/gestured_dbus.c +++ b/server/gestured_dbus.c @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include #include "gestured_dbus.h" #include "gestured_error.h" @@ -43,10 +46,68 @@ static GDBusConnection *_gdbus_connection; static const char *_client_bus_name; static const char *_engine_bus_name; + static bool __is_engine_installed(const char* appid); static bool __is_engine_launched(const char* appid); +static cynara *p_cynara = NULL; +static int _cynara_initialize() +{ + int ret = cynara_initialize(&p_cynara, NULL); + if (ret != CYNARA_API_SUCCESS) + LOGE("Failed to cynara initialize"); + + return ret; +} + +static int _check_privilege(const char *uid, const int pid, const char *label, const char *privilege) +{ + int ret; + + if (!p_cynara) { + return -1; + } + + char *session = cynara_session_from_pid(pid); + ret = cynara_check(p_cynara, label, session, uid, privilege); + if (session) + free(session); + if (ret != CYNARA_API_ACCESS_ALLOWED) { + LOGE("Access denied. The result of cynara_check() : %d.", ret); + return -1; + } + + return 0; +} + +static void _cynara_deinitialize() +{ + if (p_cynara) + cynara_finish(p_cynara); + + p_cynara = NULL; +} + +static int _gesture_check_privilege(const char *uid, const int pid, const char *label) +{ + int ret = GESTURED_ERROR_NONE; + + if (_cynara_initialize() != CYNARA_API_SUCCESS) + return GESTURED_ERROR_PERMISSION_DENIED; + + if (_check_privilege(uid, pid, label, GESTURE_PRIVILEGE_APPLAUNCH) < 0) { + LOGE("Permission is denied"); + ret = GESTURED_ERROR_PERMISSION_DENIED; + } + + _cynara_deinitialize(); + + return ret; +} + + + int gestured_server_register(GVariant *parameters, GVariant **reply_body, const gchar *sender, GBusNameAppearedCallback name_appeared_handler, GBusNameVanishedCallback name_vanished_handler, GHashTable **monitoring_hash) { @@ -57,14 +118,20 @@ int gestured_server_register(GVariant *parameters, GVariant **reply_body, const uid_t request_uid = 0; CLIENT_LIB clientLib; char *pkgName = NULL; + int client_pid = 0; + char *client_uid = NULL; + char *client_smack_label = NULL; if (bus_name == NULL) return GESTURED_ERROR_IO_ERROR; - g_variant_get(parameters, "(iis)", &request_uid, &clientLib, &pkgName); + g_variant_get(parameters, "(iisiss)", &request_uid, &clientLib, &pkgName, &client_pid, &client_uid, &client_smack_label); LOGD("gestured_server_register > request_uid: %d", request_uid); LOGD("gestured_server_register > clientLib: %d", clientLib); LOGD("gestured_server_register > pkgName: %s", pkgName); + LOGD("gestured_server_register > client_pid: %d", client_pid); + LOGD("gestured_server_register > client_uid: %s", (NULL == client_uid) ? "NULL" : client_uid); + LOGD("gestured_server_register > client_smack_label: %s", (NULL == client_smack_label) ? "NULL" : client_smack_label); if (clientLib == GESTURE_CLIENT_LIB_ENGINE) { _engine_bus_name = g_strdup(bus_name); @@ -73,6 +140,15 @@ int gestured_server_register(GVariant *parameters, GVariant **reply_body, const } if (clientLib == GESTURE_CLIENT_LIB_GESTURE) { + /* check privilege */ + if (GESTURED_ERROR_NONE != _gesture_check_privilege(client_uid, client_pid, client_smack_label)) { + LOGE("[ERROR] Permission denied"); + + return GESTURED_ERROR_PERMISSION_DENIED; + } else { + LOGI("[INFO] Permission allowed"); + } + /* launch engine process if engine is not running */ bool is_launched = __is_engine_launched("org.tizen.gesture-engine-default"); if (false == is_launched) { @@ -96,6 +172,7 @@ int gestured_server_register(GVariant *parameters, GVariant **reply_body, const LOGE("Fail to create a new client"); return GESTURED_ERROR_OPERATION_FAILED; } + client->is_permitted = true; client->clientLib = clientLib; client->request_uid = request_uid; client->gdbus_bus_name = strdup(bus_name); @@ -118,6 +195,7 @@ int gestured_server_register(GVariant *parameters, GVariant **reply_body, const LOGE("Failed to add client to GestureManager"); return GESTURED_ERROR_OPERATION_FAILED; } + LOGD("GestureManager Client count = %d", GestureManagerClientNums()); } else if (clientLib == GESTURE_CLIENT_LIB_ENGINE) { /* Check this engine is already registerd to server or not */ @@ -466,6 +544,9 @@ int gestured_register_dbus_interface(void) " " " " " " + " " + " " + " " " " " " @@ -558,6 +639,18 @@ int gestured_client_initialize_engine(GVariant *parameters, GVariant **reply_bod return GESTURED_ERROR_INVALID_PARAMETER; } + /* check privilege */ + gesture_manager_client_s *client = GestureManagerClientGetWithBusName(sender); + if (!client) { + LOGE("failed to GestureManagerClientGet"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + if (false == client->is_permitted) { + LOGE("[ERROR] Permission denied"); + return GESTURED_ERROR_PERMISSION_DENIED; + } + ret = gestured_send_dbus_message(parameters, sender, cmd, GESTURE_CLIENT_LIB_ENGINE); if (ret != GESTURED_ERROR_NONE) LOGE("Failed to start to engine"); -- 2.7.4 From b1eee2124d3e634449c79ae26e8e2ba728c49622 Mon Sep 17 00:00:00 2001 From: Sungwook Park Date: Fri, 28 Aug 2020 14:46:33 +0900 Subject: [PATCH 06/16] Fix issue that detected by static analysis tool Change-Id: I5144129783cfb8acf6f654ea8e2730c4ce6ccc93 Signed-off-by: Sungwook Park --- client/gesture.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/gesture.c b/client/gesture.c index 17065d1..f333dea 100644 --- a/client/gesture.c +++ b/client/gesture.c @@ -77,8 +77,8 @@ static int _check_privilege(const char *uid, const char *privilege) if (!p_cynara) { return -1; } - - strcpy(smack_label, _get_smack_label()); + char * sl = _get_smack_label(); + memcpy(smack_label, sl, strlen(sl) + 1); pid_t pid = getpid(); char *session = cynara_session_from_pid(pid); @@ -143,7 +143,8 @@ EXPORT_API int hand_gesture_create(hand_gesture_h *handle) /* get uid and smack label */ snprintf(_struct->uid, 16, "%d", getuid()); - strcpy(_struct->smack_label, _get_smack_label()); + char *sl = _get_smack_label(); + memcpy(_struct->smack_label, sl, strlen(sl) + 1); LOGI("uid(%s), smack(%s)", _struct->uid, _struct->smack_label); -- 2.7.4 From a81b00b30707820c9f3d1e1fb59268409958469b Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 1 Sep 2020 14:37:29 +0900 Subject: [PATCH 07/16] Add line coverage options Change-Id: I658f93c800d2823f4e83a8c84ee220baeb04324e Signed-off-by: sooyeon.kim --- client/gesture.c | 12 ++++++------ packaging/capi-ui-gesture.spec | 10 ++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/client/gesture.c b/client/gesture.c index f333dea..84d291d 100644 --- a/client/gesture.c +++ b/client/gesture.c @@ -213,7 +213,7 @@ EXPORT_API int hand_gesture_is_supported_type(hand_gesture_h handle, hand_gestur return HAND_GESTURE_ERROR_NONE; } - +//LCOV_EXCL_START EXPORT_API int hand_gesture_set_handtype(hand_gesture_h handle, hand_gesture_handtype_e hand_type) { LOGD("hand_gesture_set_handtype"); @@ -249,7 +249,7 @@ EXPORT_API int hand_gesture_set_workmode(hand_gesture_h handle, hand_gesture_wor return ret; } - +//LCOV_EXCL_STOP EXPORT_API int hand_gesture_set_option(hand_gesture_h handle, hand_gesture_option_e option) { LOGD("hand_gesture_set_option"); @@ -267,7 +267,7 @@ EXPORT_API int hand_gesture_set_option(hand_gesture_h handle, hand_gesture_optio return ret; } - +//LCOV_EXCL_START EXPORT_API int hand_gesture_set_sensitivity(hand_gesture_h handle, int sensitivity) { LOGD("hand_gesture_set_sensitivity"); @@ -285,7 +285,7 @@ EXPORT_API int hand_gesture_set_sensitivity(hand_gesture_h handle, int sensitivi return ret; } - +//LCOV_EXCL_STOP EXPORT_API int hand_gesture_start_recognition(hand_gesture_h handle, hand_gesture_type_e gesture_type, hand_gesture_recognition_cb callback, void *user_data) { LOGD("hand_gesture_start_recognition"); @@ -338,7 +338,7 @@ EXPORT_API int hand_gesture_stop_recognition(hand_gesture_h handle) return HAND_GESTURE_ERROR_NONE; } - +//LCOV_EXCL_START EXPORT_API int hand_gesture_get_event(const hand_gesture_data_h data, hand_gesture_event_e *event) { CHECK_GESTURE_FEATURE(); @@ -349,7 +349,7 @@ EXPORT_API int hand_gesture_get_event(const hand_gesture_data_h data, hand_gestu return HAND_GESTURE_ERROR_NONE; } - +//LCOV_EXCL_STOP EXPORT_API int hand_gesture_get_engine_info(hand_gesture_h handle, char** engine_app_id, char** engine_name) { LOGD("[engineInfo] hand_gesture_get_engine_info"); diff --git a/packaging/capi-ui-gesture.spec b/packaging/capi-ui-gesture.spec index 7fb84c2..7aa6b55 100644 --- a/packaging/capi-ui-gesture.spec +++ b/packaging/capi-ui-gesture.spec @@ -28,6 +28,11 @@ Requires(post): /sbin/ldconfig Requires(post): dbus Requires(postun): /sbin/ldconfig +%if 0%{?gcov:1} +BuildRequires: lcov +BuildRequires: zip +%endif + %description Gesture client library and daemon @@ -91,6 +96,11 @@ mkdir -p %{buildroot}%{_datadir}/gcov/obj install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %endif +#%if 0%{?gcov:1} +#lcov -c --ignore-errors graph --no-external -q -d . -o gcov.info +#genhtml gcov.info +#%endif + mkdir -p %{buildroot}/etc/dbus-1/system.d/ cp %{SOURCE3} %{buildroot}/etc/dbus-1/system.d/capi-ui-gesture.conf -- 2.7.4 From 8a30d4e2d0910de34f6a756c5390992a1bfa18a2 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 25 Aug 2020 19:40:39 +0900 Subject: [PATCH 08/16] Refactor gdbus interface of gesture FW This patch includes these changes. - Extract gdbus interface definition xml from source code to .xml file. - Create invocation manager class to manager gdbus method call session. - Synchronize API behavior(hand_gesture_is_supported_type, hand_gesture_get_engine_info). Change-Id: Ied0b8a766d4b07634b31f6dc9f5325d057471936 Signed-off-by: Suyeon Hwang --- CMakeLists.txt | 2 + capi-ui-gesture-gdbus.xml | 65 ++++++++ client/gesture.c | 1 + client/gesture_client_dbus.c | 43 +++++- engine/gesture_engine_dbus.c | 52 +++++-- include/gesture_defs.h | 7 +- manager/gestured_invocation_manager.cpp | 71 +++++++++ manager/gestured_invocation_manager.h | 20 +++ packaging/capi-ui-gesture.spec | 1 + server/CMakeLists.txt | 1 + server/gestured_dbus.c | 260 ++++++++++++++++++++------------ server/gestured_dbus.h | 8 +- 12 files changed, 418 insertions(+), 113 deletions(-) create mode 100644 capi-ui-gesture-gdbus.xml create mode 100644 manager/gestured_invocation_manager.cpp create mode 100644 manager/gestured_invocation_manager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ccea7d..c3e0afd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,3 +46,5 @@ ADD_SUBDIRECTORY(client) ## Gesture manager ## #ADD_SUBDIRECTORY(manager) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/capi-ui-gesture-gdbus.xml DESTINATION ${TZ_SYS_RO_SHARE}/gesture) diff --git a/capi-ui-gesture-gdbus.xml b/capi-ui-gesture-gdbus.xml new file mode 100644 index 0000000..4adff75 --- /dev/null +++ b/capi-ui-gesture-gdbus.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/client/gesture.c b/client/gesture.c index f333dea..3872631 100644 --- a/client/gesture.c +++ b/client/gesture.c @@ -201,6 +201,7 @@ EXPORT_API int hand_gesture_is_supported_type(hand_gesture_h handle, hand_gestur LOGD("hand_gesture_is_supported_type"); CHECK_GESTURE_FEATURE(); + ASSERT_NOT_NULL(handle); ASSERT_NOT_NULL(supported); int ret; diff --git a/client/gesture_client_dbus.c b/client/gesture_client_dbus.c index 532ac88..0c58dad 100644 --- a/client/gesture_client_dbus.c +++ b/client/gesture_client_dbus.c @@ -623,10 +623,21 @@ int gesture_client_dbus_is_support_gesture_type(GDBusConnection *gdbus_connectio GDBusMessage *reply = NULL; GVariant *body = NULL; - body = g_variant_new("()"); + body = g_variant_new("(i)", gesture); ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_IS_SUPPORT_GESTURE_TYPE); - if (ret != HAND_GESTURE_ERROR_NONE) + if (ret != HAND_GESTURE_ERROR_NONE || NULL == reply) { LOGE("failed to is_supported_gesture_type"); + } else { + LOGD("Check reply from server"); + GVariant *reply_body = g_dbus_message_get_body(reply); + if (NULL == reply_body) { + LOGE("There is no return value"); + ret = HAND_GESTURE_ERROR_OPERATION_FAILED; + } else { + g_variant_get(reply_body, "(b)", supported); + LOGD("supported(%d)", *supported); + } + } if (body) g_variant_unref(body); @@ -643,13 +654,35 @@ int gesture_client_dbus_get_engine_info(GDBusConnection *gdbus_connection, char* int ret; GDBusMessage *reply = NULL; GVariant *body = NULL; - g_engine_app_id = *engine_app_id; - g_engine_name = *engine_name; body = g_variant_new("()"); ret = gdbus_send_message_with_sync(gdbus_connection, body, &reply, GESTURE_CLIENT_MSG_ENGINE_GET_INFO); if (ret != HAND_GESTURE_ERROR_NONE) - LOGE("failed to engine_get_info"); + LOGE("Fail to send message"); + + GVariant *reply_body = g_dbus_message_get_body(reply); + if (NULL == reply_body) { + LOGE("There is no return value"); + ret = HAND_GESTURE_ERROR_OPERATION_FAILED; + } else { + g_variant_get(reply_body, "(ss)", engine_app_id, engine_name); + if (NULL == engine_app_id || NULL == engine_name) { + LOGE("Fail to get engine info"); + ret = HAND_GESTURE_ERROR_OPERATION_FAILED; + } else { + if (NULL != g_engine_app_id) { + free(g_engine_app_id); + } + + if (NULL != g_engine_name) { + free(g_engine_name); + } + + g_engine_app_id = *engine_app_id; + g_engine_name = *engine_name; + LOGD("APP ID(%s), Name(%s)", *engine_app_id, *engine_name); + } + } if (body) g_variant_unref(body); diff --git a/engine/gesture_engine_dbus.c b/engine/gesture_engine_dbus.c index 3eeb674..a0ec977 100644 --- a/engine/gesture_engine_dbus.c +++ b/engine/gesture_engine_dbus.c @@ -29,6 +29,8 @@ static int is_server_started = 0; static gesture_engine_request_callback_s g_basic_engine_callback; static GDBusConnection *mgdbus_connection; +static int gdbus_send_message_with_async(GDBusConnection *gdbus_connection, GVariant *body, char *cmd); + static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) { LOGD("name : %s, name_owner : %s", name, name_owner); @@ -150,16 +152,46 @@ static void _handle_gesture_engine_cb(GDBusConnection *connection, } else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE) == 0) { LOGD("[GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE] called"); - int gesture_type = 1; - bool isSupported = false; - g_variant_get(parameters, "(i)", &gesture_type); - g_basic_engine_callback.is_support_gesture_type(gesture_type, &isSupported); - } - else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_ENGINE_GET_INFO) == 0) { - LOGD("[GESTURE_ENGINE_SIGNAL_ENGINE_GET_INFO] called"); - char *engine_app_id; - char *engine_name; + int id = 0; + int gesture_type = 0; + g_variant_get(parameters, "(ii)", &id, &gesture_type); + LOGD("Invocation ID(%d), Gesture Type(%d)", id, gesture_type); + + bool is_supported = false; + g_basic_engine_callback.is_support_gesture_type(gesture_type, &is_supported); + GVariant* body = g_variant_new("(ib)", id, is_supported); + if (NULL == body) { + LOGE("Fail to create body"); + return; + } + + LOGD("send message variant. ID(%d), Is supported(%d)", id, is_supported); + gdbus_send_message_with_async(connection, body, GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE); + g_variant_unref(body); + } + else if (g_strcmp0(signal_name, GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO) == 0) { + LOGD("[GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO] called"); + int id = 0; + g_variant_get(parameters, "(i)", &id); + LOGD("Invocation ID(%d)", id); + + char *engine_app_id = NULL; + char *engine_name = NULL; g_basic_engine_callback.get_info(&engine_app_id, &engine_name); + if (NULL == engine_app_id || NULL == engine_name) { + LOGE("Fail to get engine information"); + return; + } + + GVariant* body = g_variant_new("(iss)", id, engine_app_id, engine_name); + if (NULL == body) { + LOGE("Fail to create body"); + return; + } + + LOGD("send message variant. APP ID(%s), Name(%s)", engine_app_id, engine_name); + gdbus_send_message_with_async(connection, body, GESTURE_ENGINE_MSG_GET_ENGINE_INFO); + g_variant_unref(body); } } @@ -595,7 +627,7 @@ int gesture_engine_dbus_send_engine_get_info(GDBusConnection *gdbus_connection, GVariant *body = NULL; body = g_variant_new("(ss)", engine_app_id, engine_name); - ret = gdbus_send_message_with_sync(mgdbus_connection, body, &reply, GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO); + ret = gdbus_send_message_with_sync(mgdbus_connection, body, &reply, GESTURE_ENGINE_MSG_GET_ENGINE_INFO); if (ret != GESTURE_ENGINE_ERROR_NONE) { LOGE("Fail to send result data to daemon"); } diff --git a/include/gesture_defs.h b/include/gesture_defs.h index d08beca..613e697 100644 --- a/include/gesture_defs.h +++ b/include/gesture_defs.h @@ -27,6 +27,8 @@ extern "C" { #define HAPI __attribute__((visibility("hidden"))) +#define GESTURE_SHARED_RESOURCE_PATH tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "gesture") + #define DBUS_NAME "org.freedesktop.DBus" #define DBUS_OBJECT_PATH "/org/freedesktop/DBus" #define DBUS_INTERFACE_NAME "org.freedesktop.DBus" @@ -56,7 +58,8 @@ extern "C" { #define GESTURE_ENGINE_MSG_SEND_RESULT "gesture_engine_send_result" #define GESTURE_ENGINE_MSG_SEND_ERROR "gesture_engine_send_error" #define GESTURE_ENGINE_MSG_SEND_MOTION_STATUS "gesture_engine_send_motion_status" -#define GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO "gesture_engine_send_engine_get_info" +#define GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE "gesture_engine_is_support_gesture_type" +#define GESTURE_ENGINE_MSG_GET_ENGINE_INFO "gesture_engine_get_engine_info" #define GESTURE_ENGINE_SIGNAL_ENGINE_INITIALIZE "engine_initialize" #define GESTURE_ENGINE_SIGNAL_ENGINE_DEINITIALIZE "engine_deinitialize" @@ -65,7 +68,7 @@ extern "C" { #define GESTURE_ENGINE_SIGNAL_FOREACH_RESULT_TIME "engine_foreach_result_time" #define GESTURE_ENGINE_SIGNAL_FOREACH_SUPPORTED_TYPE "engine_foreach_supported_type" #define GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE "engine_is_support_gesture_type" -#define GESTURE_ENGINE_SIGNAL_ENGINE_GET_INFO "engine_get_info" +#define GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO "engine_get_engine_info" #define GESTURE_PRIVILEGE_APPLAUNCH "http://tizen.org/privilege/appmanager.launch" #define GESTURE_FEATURE_GESTURE "tizen.org/feature/sensor.gesture_recognition" diff --git a/manager/gestured_invocation_manager.cpp b/manager/gestured_invocation_manager.cpp new file mode 100644 index 0000000..7f1cd14 --- /dev/null +++ b/manager/gestured_invocation_manager.cpp @@ -0,0 +1,71 @@ +#include +#include + +#include + +#include "gestured_invocation_manager.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "GESTURE_INVOCATION" + +static const int MAX_INVOCATION_ID = 1000000; + +static std::map g_invocation_map; +static int g_last_id = -1; + +int gestureInvocationManagerInit() +{ + LOGD("Initialize invocation manager"); + g_last_id = -1; + g_invocation_map.clear(); + + return 0; +} + +int gestureInvocationManagerAdd(GDBusMethodInvocation* invocation) +{ + if (NULL == invocation) { + LOGE("Invalid parameter"); + return -1; + } + + LOGD("Add new invocation handle"); + bool findId = false; + for (int i = g_last_id + 1; i != g_last_id; i = (i + 1) % MAX_INVOCATION_ID) { + if (g_invocation_map.find(i) == g_invocation_map.end()) { + g_last_id = i; + findId = true; + break; + } + } + + if (!findId) { + LOGE("Invocation map is full"); + return -1; + } + + g_invocation_map.insert({g_last_id, invocation}); + + return g_last_id; +} + +GDBusMethodInvocation* gestureInvocationManagerGet(int invocation_id) +{ + LOGD("Find invocation handle. ID(%d)", invocation_id); + auto iter = g_invocation_map.find(invocation_id); + if (iter == g_invocation_map.end()) { + LOGE("There is no handle"); + return nullptr; + } + + return iter->second; +} + +bool gestureInvocationManagerRemove(int invocation_id) +{ + LOGD("Remove invocation handle. ID(%d)", invocation_id); + g_invocation_map.erase(invocation_id); + return true; +} \ No newline at end of file diff --git a/manager/gestured_invocation_manager.h b/manager/gestured_invocation_manager.h new file mode 100644 index 0000000..32c3458 --- /dev/null +++ b/manager/gestured_invocation_manager.h @@ -0,0 +1,20 @@ +#ifndef __GESTURED_INVOCATION_MANAGER_H__ +#define __GESTURED_INVOCATION_MANAGER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int gestureInvocationManagerInit(); +int gestureInvocationManagerAdd(GDBusMethodInvocation* invocation); +GDBusMethodInvocation* gestureInvocationManagerGet(int invocation_id); +bool gestureInvocationManagerRemove(int invocation_id); + +#ifdef __cplusplus +} +#endif + +#endif /* __GESTURED_INVOCATION_MANAGER_H__ */ + diff --git a/packaging/capi-ui-gesture.spec b/packaging/capi-ui-gesture.spec index 7fb84c2..2bae1f2 100644 --- a/packaging/capi-ui-gesture.spec +++ b/packaging/capi-ui-gesture.spec @@ -104,6 +104,7 @@ cp %{SOURCE3} %{buildroot}/etc/dbus-1/system.d/capi-ui-gesture.conf %license LICENSE %{_libdir}/lib*.so %attr(0755,ui_fw,ui_fw) %{_bindir}/gesture-server +%attr(0644,root,root) %{_datadir}/gesture/capi-ui-gesture-gdbus.xml %attr(0644,root,root) %{_unitdir}/capi-ui-gesture.service %attr(0644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.gesture.server.service %config %{_sysconfdir}/dbus-1/system.d/capi-ui-gesture.conf diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index c41307a..d79d081 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -4,6 +4,7 @@ SET(SRCS gestured_dbus.c ../manager/gestured_client_manager.cpp ../manager/gestured_engine_manager.cpp + ../manager/gestured_invocation_manager.cpp ) FOREACH(flag ${pkgs_CFLAGS}) diff --git a/server/gestured_dbus.c b/server/gestured_dbus.c index 20a956e..0673c4d 100644 --- a/server/gestured_dbus.c +++ b/server/gestured_dbus.c @@ -30,6 +30,7 @@ #include "gesture_defs.h" #include "gestured_client_manager.h" #include "gestured_engine_manager.h" +#include "gestured_invocation_manager.h" #ifdef LOG_TAG #undef LOG_TAG @@ -300,6 +301,8 @@ int gestured_server_register_dbus_interface(char *introspection_xml, GDBusInterf goto cleanup; } + gestureInvocationManagerInit(); + return GESTURED_ERROR_NONE; cleanup: @@ -448,6 +451,7 @@ static void _gestured_client_dbus_method_call_handler(GDBusConnection *conn, con GVariant *reply_body = NULL; int ret = GESTURED_ERROR_NONE; + bool delay_response = false; if (g_strcmp0(method_name, GESTURE_MSG_SERVICE_REGISTER) == 0) { LOGD("[GESTURE_MSG_SERVICE_REGISTER] called"); @@ -481,11 +485,13 @@ static void _gestured_client_dbus_method_call_handler(GDBusConnection *conn, con } else if (g_strcmp0(method_name, GESTURE_CLIENT_MSG_IS_SUPPORT_GESTURE_TYPE) == 0) { LOGD("[GESTURE_CLIENT_MSG_IS_SUPPORT_GESTURE_TYPE] called"); - ret = gestured_client_is_support_gesture_type(parameters, &reply_body, sender); + ret = gestured_client_is_support_gesture_type(parameters, &reply_body, sender, invocation); + delay_response = true; } else if (g_strcmp0(method_name, GESTURE_CLIENT_MSG_ENGINE_GET_INFO) == 0) { LOGD("[GESTURE_CLIENT_MSG_ENGINE_GET_INFO] called"); - ret = gestured_client_engine_get_info(parameters, &reply_body, sender); + ret = gestured_client_get_engine_info(parameters, &reply_body, sender, invocation); + delay_response = true; } /* from engine */ @@ -504,24 +510,32 @@ static void _gestured_client_dbus_method_call_handler(GDBusConnection *conn, con else if (g_strcmp0(method_name, GESTURE_ENGINE_MSG_MAIN_START) == 0) { LOGD("[GESTURE_ENGINE_MSG_MAIN_START] called"); } - else if (g_strcmp0(method_name, GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO) == 0) { - LOGD("[GESTURE_ENGINE_MSG_SEND_ENGINE_GET_INFO] called"); - ret = gestured_engine_send_engine_get_info(parameters, &reply_body, sender); + else if (g_strcmp0(method_name, GESTURE_ENGINE_MSG_GET_ENGINE_INFO) == 0) { + LOGD("[GESTURE_ENGINE_MSG_GET_ENGINE_INFO] called"); + int id = -1; + char* app_id = NULL; + char* name = NULL; + + g_variant_get(parameters, "(iss)", &id, &app_id, &name); + ret = gestured_reply_get_engine_info(id, app_id, name); } + else if (g_strcmp0(method_name, GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE) == 0) { + LOGD("[GESTURE_ENGINE_MSG_IS_SUPPORT_GESTURE_TYPE] called"); + int id = -1; + bool is_supported = false; - if (ret == GESTURED_ERROR_NONE) { - LOGD("method_call successful, method_name : %s", method_name); -#if 0 - if (reply_body != NULL) { - gchar *printmsg = g_variant_print(reply_body, true); - LOGD("<<>> : %s", printmsg); - g_free(printmsg); + g_variant_get(parameters, "(ib)", &id, &is_supported); + ret = gestured_reply_is_support_gesture_type(id, is_supported); + } + + if (false == delay_response) { + if (ret == GESTURED_ERROR_NONE) { + LOGD("method_call successful, method_name : %s", method_name); + g_dbus_method_invocation_return_value(invocation, reply_body); + } else { + LOGE("method_call failed, method_name : %s", method_name); + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, ret, "gesture error"); } -#endif - g_dbus_method_invocation_return_value(invocation, reply_body); - } else { - LOGE("method_call failed, method_name : %s", method_name); - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, ret, "gesture error"); } if (reply_body) @@ -537,77 +551,48 @@ static const GDBusInterfaceVTable _gesture_interface_vtable = { int gestured_register_dbus_interface(void) { LOGD("gestured_register_dbus_interface"); - static gchar introspection_xml[] = - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - - " " - " " - - " " - " " - " " - " " - " " - " " - " " - - " " - " " - - " " - " " - - " " - " " - - " " - " " - - " " - " " - - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - - " " - " " - " " - - " " - " " - " " - - " " - " " - " " - " " - - " " - " "; - - return gestured_server_register_dbus_interface(introspection_xml, _gesture_interface_vtable); + + FILE* xml_file = NULL; + char xml_file_path[256] = {'\0', }; + char* introspection_xml = NULL; + int size = 0; + int ret = 0; + + snprintf(xml_file_path, strlen(GESTURE_SHARED_RESOURCE_PATH) + 27, "%s/capi-ui-gesture-gdbus.xml", GESTURE_SHARED_RESOURCE_PATH); + ret = access(xml_file_path, R_OK); + if (0 != ret) { + LOGE("Introspection file is not exist. path(%s)", xml_file_path); + return GESTURED_ERROR_OPERATION_FAILED; + } + + xml_file = fopen(xml_file_path, "r"); + if (NULL == xml_file) { + LOGE("Fail to open introspection file"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + fseek(xml_file, 0, SEEK_END); + size = ftell(xml_file); + rewind(xml_file); + + introspection_xml = (char*)calloc(sizeof(char), size); + if (NULL == introspection_xml) { + LOGE("Fail to allocate memory"); + return GESTURED_ERROR_OUT_OF_MEMORY; + } + + ret = fread(introspection_xml, 1, size, xml_file); + if (ret != size) { + LOGE("Error is occured reading file"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + ret = gestured_server_register_dbus_interface(introspection_xml, _gesture_interface_vtable); + + fclose(xml_file); + free(introspection_xml); + + return ret; } int gestured_dbus_init(void) @@ -750,7 +735,7 @@ int gestured_client_foreach_supported_type(GVariant *parameters, GVariant **repl return ret; } -int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **reply_body, const char *sender) +int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **reply_body, const char *sender, GDBusMethodInvocation* invocation) { int ret = GESTURED_ERROR_NONE; char *cmd = GESTURE_ENGINE_SIGNAL_IS_SUPPORT_GESTURE_TYPE; @@ -760,26 +745,55 @@ int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **rep return GESTURED_ERROR_INVALID_PARAMETER; } - ret = gestured_send_dbus_message(parameters, sender, cmd, GESTURE_CLIENT_LIB_ENGINE); + int id = gestureInvocationManagerAdd(invocation); + if (0 > id) { + LOGE("Fail to store invocation"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + int gesture_type = 0; + g_variant_get(parameters, "(i)", &gesture_type); + + LOGD("invocation id (%d), gesture type(%d)", id, gesture_type); + GVariant* body = g_variant_new("(ii)", id, gesture_type); + if (NULL == body) { + LOGE("Fail to create body"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + ret = gestured_send_dbus_message(body, sender, cmd, GESTURE_CLIENT_LIB_ENGINE); if (ret != GESTURED_ERROR_NONE) LOGE("Failed to start to engine"); return ret; } -int gestured_client_engine_get_info(GVariant *parameters, GVariant **reply_body, const char *sender) +int gestured_client_get_engine_info(GVariant *parameters, GVariant **reply_body, const char *sender, GDBusMethodInvocation* invocation) { - LOGD("[engineInfo] gestured_client_engine_get_info : sendor [%s]", sender); + LOGD("[engineInfo] gestured_client_get_engine_info : sendor [%s]", sender); int ret = GESTURED_ERROR_NONE; - char *cmd = GESTURE_ENGINE_SIGNAL_ENGINE_GET_INFO; + char *cmd = GESTURE_ENGINE_SIGNAL_GET_ENGINE_INFO; if (parameters == NULL) { LOGE("failed to get parameters"); return GESTURED_ERROR_INVALID_PARAMETER; } - ret = gestured_send_dbus_message(parameters, sender, cmd, GESTURE_CLIENT_LIB_ENGINE); + int id = gestureInvocationManagerAdd(invocation); + if (0 > id) { + LOGE("Fail to store invocation"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + LOGD("invocation ID (%d)", id); + GVariant* body = g_variant_new("(i)", id); + if (NULL == body) { + LOGE("Fail to create body"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + ret = gestured_send_dbus_message(body, sender, cmd, GESTURE_CLIENT_LIB_ENGINE); if (ret != GESTURED_ERROR_NONE) LOGE("Failed to start to engine"); @@ -835,6 +849,64 @@ int gestured_engine_send_engine_get_info(GVariant *parameters, GVariant **reply_ return ret; } +int gestured_reply_is_support_gesture_type(int invocation_id, bool is_supported) +{ + GDBusMethodInvocation *invocation = gestureInvocationManagerGet(invocation_id); + if (NULL == invocation) { + LOGE("Invalid invocation ID"); + return GESTURED_ERROR_INVALID_PARAMETER; + } + gestureInvocationManagerRemove(invocation_id); + + GVariant *reply_body = g_variant_new("(b)", is_supported); + if (NULL == reply_body) { + LOGE("Fail to create reply_body"); + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, GESTURED_ERROR_OPERATION_FAILED, "Fail to create return value"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + LOGD("Invocation ID(%d), IsSupport(%d)", invocation_id, is_supported); + + g_dbus_method_invocation_return_value(invocation, reply_body); + g_variant_unref(reply_body); + reply_body = NULL; + + return GESTURED_ERROR_NONE; +} + + +int gestured_reply_get_engine_info(int invocation_id, char* engine_app_id, char* engine_name) +{ + GDBusMethodInvocation *invocation = gestureInvocationManagerGet(invocation_id); + if (NULL == invocation) { + LOGE("Invalid invocation ID"); + return GESTURED_ERROR_INVALID_PARAMETER; + } + gestureInvocationManagerRemove(invocation_id); + + if (NULL == engine_app_id || NULL == engine_name) { + LOGE("Invalid parameter"); + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, GESTURED_ERROR_INVALID_PARAMETER, "Invalid parameter"); + return GESTURED_ERROR_INVALID_PARAMETER; + } + + GVariant *reply_body = g_variant_new("(ss)", engine_app_id, engine_name); + if (NULL == reply_body) { + LOGE("Fail to create reply_body"); + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, GESTURED_ERROR_OPERATION_FAILED, "Fail to create return value"); + return GESTURED_ERROR_OPERATION_FAILED; + } + + LOGD("Invocation ID(%d), APP ID(%s), Name(%s)", invocation_id, engine_app_id, engine_name); + + g_dbus_method_invocation_return_value(invocation, reply_body); + g_variant_unref(reply_body); + reply_body = NULL; + + return GESTURED_ERROR_NONE; +} + + static void __response_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) { LOGD("app_control launch result : %d", result); diff --git a/server/gestured_dbus.h b/server/gestured_dbus.h index 03d5452..5ccda23 100644 --- a/server/gestured_dbus.h +++ b/server/gestured_dbus.h @@ -50,8 +50,8 @@ int gestured_client_start_recognition(GVariant *parameters, GVariant **reply_bod int gestured_client_stop_recognition(GVariant *parameters, GVariant **reply_body, const char *sender); int gestured_client_foreach_result_time(GVariant *parameters, GVariant **reply_body, const char *sender); int gestured_client_foreach_supported_type(GVariant *parameters, GVariant **reply_body, const char *sender); -int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **reply_body, const char *sender); -int gestured_client_engine_get_info(GVariant *parameters, GVariant **reply_body, const char *sender); +int gestured_client_is_support_gesture_type(GVariant *parameters, GVariant **reply_body, const char *sender, GDBusMethodInvocation* invocation); +int gestured_client_get_engine_info(GVariant *parameters, GVariant **reply_body, const char *sender, GDBusMethodInvocation* invocation); /* engine side function : engine -> daemon */ int gestured_engine_send_result(GVariant *parameters, GVariant **reply_body, const char *sender); @@ -59,6 +59,10 @@ int gestured_engine_send_error(GVariant *parameters, GVariant **reply_body, cons int gestured_engine_send_motion_status(GVariant *parameters, GVariant **reply_body, const char *sender); int gestured_engine_send_engine_get_info(GVariant *parameters, GVariant **reply_body, const char *sender); +/* daemon side function : daemon -> client */ +int gestured_reply_is_support_gesture_type(int invocation_id, bool is_supported); +int gestured_reply_get_engine_info(int invocation_id, char* engine_app_id, char* engine_name); + int __launch_engine_service_app(char *appid); -- 2.7.4 From 2999c59c26206da977f72713bcd9d406142893cd Mon Sep 17 00:00:00 2001 From: Sungwook Park Date: Wed, 2 Sep 2020 10:31:00 +0900 Subject: [PATCH 09/16] Update pacakge version to 1.0.0 Change-Id: I63454e0930e954c9dccd064fca31df463274dbf2 Signed-off-by: Sungwook Park --- CMakeLists.txt | 2 +- packaging/capi-ui-gesture.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ccea7d..ab48ba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(capi-ui-gesture) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 0.2.56) +SET(VERSION 1.0.0) ADD_DEFINITIONS("-Werror") diff --git a/packaging/capi-ui-gesture.spec b/packaging/capi-ui-gesture.spec index 7aa6b55..3602853 100644 --- a/packaging/capi-ui-gesture.spec +++ b/packaging/capi-ui-gesture.spec @@ -1,6 +1,6 @@ Name: capi-ui-gesture Summary: Gesture client library and daemon -Version: 0.0.1 +Version: 1.0.0 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 -- 2.7.4 From 2f4877623f987376f1ad60066f3b5a56c0dd028b Mon Sep 17 00:00:00 2001 From: Sungwook Park Date: Thu, 3 Sep 2020 13:57:24 +0900 Subject: [PATCH 10/16] Update package version to 1.0.1 Change-Id: Ie3074383982d5d8bbbc45055b368527fcd22ee81 Signed-off-by: Sungwook Park --- CMakeLists.txt | 2 +- packaging/capi-ui-gesture.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c2503c..b901ff7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(capi-ui-gesture) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.0.0) +SET(VERSION 1.60.1) ADD_DEFINITIONS("-Werror") diff --git a/packaging/capi-ui-gesture.spec b/packaging/capi-ui-gesture.spec index e02b581..0ce80e3 100644 --- a/packaging/capi-ui-gesture.spec +++ b/packaging/capi-ui-gesture.spec @@ -1,6 +1,6 @@ Name: capi-ui-gesture Summary: Gesture client library and daemon -Version: 1.0.0 +Version: 1.60.1 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 -- 2.7.4 From 6cb0b897cdc7d62c6a7157497250268cd15e4fe4 Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Tue, 15 Sep 2020 10:25:47 +0900 Subject: [PATCH 11/16] Fix defects detected by static analysis tool Change-Id: Ieac1cab7fc72b545d78792425166dc03e5cba4d4 --- server/gestured_dbus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/gestured_dbus.c b/server/gestured_dbus.c index 0673c4d..86026d0 100644 --- a/server/gestured_dbus.c +++ b/server/gestured_dbus.c @@ -578,12 +578,15 @@ int gestured_register_dbus_interface(void) introspection_xml = (char*)calloc(sizeof(char), size); if (NULL == introspection_xml) { LOGE("Fail to allocate memory"); + fclose(xml_file); return GESTURED_ERROR_OUT_OF_MEMORY; } ret = fread(introspection_xml, 1, size, xml_file); if (ret != size) { LOGE("Error is occured reading file"); + fclose(xml_file); + free(introspection_xml); return GESTURED_ERROR_OPERATION_FAILED; } -- 2.7.4 From 02da4169f431b734461fa8ecff4d4dc061b7d16e Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Tue, 15 Sep 2020 10:47:00 +0900 Subject: [PATCH 12/16] Change length of copy when snprintf is called Change-Id: I3e91edaa02d236bcd0234e65f0bb63477298a95f --- server/gestured_dbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gestured_dbus.c b/server/gestured_dbus.c index 86026d0..f33ef15 100644 --- a/server/gestured_dbus.c +++ b/server/gestured_dbus.c @@ -558,7 +558,7 @@ int gestured_register_dbus_interface(void) int size = 0; int ret = 0; - snprintf(xml_file_path, strlen(GESTURE_SHARED_RESOURCE_PATH) + 27, "%s/capi-ui-gesture-gdbus.xml", GESTURE_SHARED_RESOURCE_PATH); + snprintf(xml_file_path, 256, "%s/capi-ui-gesture-gdbus.xml", GESTURE_SHARED_RESOURCE_PATH); ret = access(xml_file_path, R_OK); if (0 != ret) { LOGE("Introspection file is not exist. path(%s)", xml_file_path); -- 2.7.4 From 69c6c3ae08e22c711998c73f005b4c0b9539367c Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Fri, 21 May 2021 14:36:48 +0900 Subject: [PATCH 13/16] Fix coverity issue * Remove unnecessary null checkers * Add a checker of the integer range Change-Id: Ide9a5b13762a4da296f6b87e33bdbc76ccc8d857 Signed-off-by: sooyeon.kim --- client/gesture.c | 4 ---- server/gestured_dbus.c | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/gesture.c b/client/gesture.c index abed09d..236dfcc 100644 --- a/client/gesture.c +++ b/client/gesture.c @@ -129,8 +129,6 @@ EXPORT_API int hand_gesture_create(hand_gesture_h *handle) ASSERT_NOT_NULL(handle); int ret; - if (!handle) - return HAND_GESTURE_ERROR_INVALID_PARAMETER; if (_gesture_check_privilege() != HAND_GESTURE_ERROR_NONE) return HAND_GESTURE_ERROR_PERMISSION_DENIED; @@ -177,8 +175,6 @@ EXPORT_API int hand_gesture_destroy(hand_gesture_h handle) ASSERT_NOT_NULL(handle); int ret; - if (!handle) - return HAND_GESTURE_ERROR_INVALID_PARAMETER; LOGD("handle : %p", handle); ret = gesture_client_dbus_shutdown(handle->gdbus_connection, &handle->server_monitor_id, &handle->monitor_id); diff --git a/server/gestured_dbus.c b/server/gestured_dbus.c index f33ef15..10f5922 100644 --- a/server/gestured_dbus.c +++ b/server/gestured_dbus.c @@ -573,6 +573,11 @@ int gestured_register_dbus_interface(void) fseek(xml_file, 0, SEEK_END); size = ftell(xml_file); + if (0 >= size) { + LOGE("Fail to get xml file"); + fclose(xml_file); + return GESTURED_ERROR_OPERATION_FAILED; + } rewind(xml_file); introspection_xml = (char*)calloc(sizeof(char), size); -- 2.7.4 From 988a55d4a32fe3d716ced12632472a2c1fda725f Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 21 May 2021 15:58:25 +0900 Subject: [PATCH 14/16] Remove memory allocation code for unused memory Change-Id: I60260283272a1472bbc41da36e172d6f71b57b49 Signed-off-by: Suyeon Hwang --- client/gesture.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/gesture.c b/client/gesture.c index abed09d..fa58fc0 100644 --- a/client/gesture.c +++ b/client/gesture.c @@ -306,12 +306,13 @@ EXPORT_API int hand_gesture_start_recognition(hand_gesture_h handle, hand_gestur handle->recog_cb = callback; handle->recog_user_data = user_data; - hand_gesture_data_h gesture_data = (hand_gesture_data_h)calloc(1, sizeof(struct hand_gesture_data_s)); - if (!gesture_data) { - return HAND_GESTURE_ERROR_OUT_OF_MEMORY; - } + // TODO: analysis the purpose of this data. + // hand_gesture_data_h gesture_data = (hand_gesture_data_h)calloc(1, sizeof(struct hand_gesture_data_s)); + // if (!gesture_data) { + // return HAND_GESTURE_ERROR_OUT_OF_MEMORY; + // } - ret = gesture_client_dbus_start_recognition(handle->gdbus_connection, gesture_type, gesture_data, callback); + ret = gesture_client_dbus_start_recognition(handle->gdbus_connection, gesture_type, NULL, callback); if (ret != HAND_GESTURE_ERROR_NONE) { LOGE("Failed to start recoginition : %d", ret); return HAND_GESTURE_ERROR_OPERATION_FAILED; -- 2.7.4 From afb1d80a1d439e8a43651fd4b985fed6ef2074f2 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 8 Jul 2021 17:50:32 +0900 Subject: [PATCH 15/16] Move header into proper file Change-Id: I1bc2ba700c2c515d16762fcaa14dc69315fe50b0 Signed-off-by: sooyeon --- client/gesture.c | 1 + include/gesture_common.h | 1 - include/gesture_common_internal.h | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/client/gesture.c b/client/gesture.c index 0e4a1b0..c7f177f 100644 --- a/client/gesture.c +++ b/client/gesture.c @@ -27,6 +27,7 @@ #include "gesture_common_internal.h" #include "gesture_main.h" #include "gesture_client_dbus.h" +#include "gesture_data_info.h" #ifdef LOG_TAG diff --git a/include/gesture_common.h b/include/gesture_common.h index a8954c6..a909343 100644 --- a/include/gesture_common.h +++ b/include/gesture_common.h @@ -18,7 +18,6 @@ #define __TIZEN_UIX_GESTURE_COMMON_H__ #include -#include #ifdef __cplusplus extern "C" { diff --git a/include/gesture_common_internal.h b/include/gesture_common_internal.h index 6b42c07..992010f 100644 --- a/include/gesture_common_internal.h +++ b/include/gesture_common_internal.h @@ -18,7 +18,6 @@ #define __TIZEN_UIX_GESTURE_COMMON_INTERNAL_H__ #include -#include #ifdef __cplusplus extern "C" { -- 2.7.4 From 59f62cb39bf53e5e91ed76638730fd83c80b8f71 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 15 Dec 2021 21:17:26 +0900 Subject: [PATCH 16/16] Move glib header outside extern C Change-Id: Idc43c5455c6925a0816975ecb56e56854a43b5df Signed-off-by: sooyeon --- manager/gestured_client_manager.h | 6 +++--- manager/gestured_engine_manager.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manager/gestured_client_manager.h b/manager/gestured_client_manager.h index 66b6b14..35b7ce9 100644 --- a/manager/gestured_client_manager.h +++ b/manager/gestured_client_manager.h @@ -2,14 +2,14 @@ #define __GESTURED_CLIENT_MANAGER_H__ +#include +#include +#include #ifdef __cplusplus extern "C" { #endif -#include -#include -#include #include "gesture.h" #include "gesture_defs.h" #include "gestured_error.h" diff --git a/manager/gestured_engine_manager.h b/manager/gestured_engine_manager.h index e6cc51b..fb4373d 100644 --- a/manager/gestured_engine_manager.h +++ b/manager/gestured_engine_manager.h @@ -2,13 +2,13 @@ #define __GESTURED_ENGINE_MANAGER_H__ +#include +#include #ifdef __cplusplus extern "C" { #endif -#include -#include #include "gesture_engine.h" #include "gesture_defs.h" #include "gestured_error.h" -- 2.7.4