From 7c119579cd43f43a25a883e3ae1e8bf1923ffb83 Mon Sep 17 00:00:00 2001 From: Mu-Woong Date: Sat, 20 Jun 2015 15:54:17 +0900 Subject: [PATCH 01/16] Change include directory path Change-Id: If22eb727ea5505b67412c2b4625442784acc4acc Signed-off-by: Mu-Woong --- CMakeLists.txt | 14 +++++++------- packaging/motion.spec | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f50d5d..21b3e92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ SET(SRCS src/activity/activity.cpp ) -# Dependencies +SET(inc_subdir "context-service") SET(dependency "dlog glib-2.0 capi-base-common capi-system-info sensor") # Target lib (for backward compatibility, the below old naming is used) @@ -45,7 +45,7 @@ SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) # Install INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries) INSTALL( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/motion + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${inc_subdir} FILES_MATCHING PATTERN "*.h" ) @@ -53,15 +53,15 @@ SET(VERSION ${FULLVER}) SET(PC_PREFIX ${CMAKE_INSTALL_PREFIX}) SET(PC_NAME ${target}) SET(PC_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") -SET(PC_INCLUDE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/motion") +SET(PC_INCLUDE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${inc_subdir}") SET(PC_DESCRIPTION "Tizen Native Motion Recognition API") SET(PC_REQUIRED ${dependency}) SET(PC_LDFLAGS -l${target}) -SET(PC_CFLAGS -I\${includedir}/motion) +SET(PC_CFLAGS -I\${includedir}/${inc_subdir}) CONFIGURE_FILE( - motion.pc.in - ${CMAKE_CURRENT_SOURCE_DIR}/motion.pc + ${PROJECT_NAME}.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc @ONLY ) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/motion.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/packaging/motion.spec b/packaging/motion.spec index c5de290..ebad3a4 100644 --- a/packaging/motion.spec +++ b/packaging/motion.spec @@ -51,9 +51,9 @@ rm -rf %{buildroot} %make_install mkdir -p %{buildroot}/usr/share/license -cp LICENSE %{buildroot}/usr/share/license/motion +cp LICENSE %{buildroot}/usr/share/license/%{name} # For backward compatibility -ln -s ./motion.pc %{buildroot}/%{_libdir}/pkgconfig/libcore-context-manager.pc +ln -s ./%{name}.pc %{buildroot}/%{_libdir}/pkgconfig/libcore-context-manager.pc %post /sbin/ldconfig @@ -62,15 +62,15 @@ ln -s ./motion.pc %{buildroot}/%{_libdir}/pkgconfig/libcore-context-manager.pc /sbin/ldconfig %files -%manifest packaging/motion.manifest +%manifest packaging/%{name}.manifest %defattr(-,root,root,-) %{_libdir}/*.so* -/usr/share/license/motion +/usr/share/license/%{name} %package devel Summary: Tizen Native Motion Recognition API (Development) Group: Framework/context -Requires: motion = %{version}-%{release} +Requires: %{name} = %{version}-%{release} %description devel Tizen Native Motion Recognition API (Development) @@ -83,5 +83,5 @@ Tizen Native Motion Recognition API (Development) %files devel %defattr(-,root,root,-) -%{_includedir}/motion/*.h +%{_includedir}/*/*.h %{_libdir}/pkgconfig/*.pc -- 2.34.1 From 81445090ac8d8e00343b94a6a59e6a8ac18f0633 Mon Sep 17 00:00:00 2001 From: Mu-Woong Date: Thu, 17 Sep 2015 13:37:25 +0900 Subject: [PATCH 02/16] Gesture: reorganize the namespace of motion_engine Change-Id: I3b7b99ac7235fb4c2c8bd14e140bc0023d9f2d9e Signed-off-by: Mu-Woong --- include/gesture_recognition.h | 20 ++++++++++---------- src/gesture/gesture.cpp | 22 ++++++++++++---------- src/gesture/motion_engine.cpp | 8 ++++---- src/gesture/motion_engine.h | 12 ++++++------ 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/include/gesture_recognition.h b/include/gesture_recognition.h index e4f2de0..65b3f2a 100644 --- a/include/gesture_recognition.h +++ b/include/gesture_recognition.h @@ -94,18 +94,18 @@ typedef enum { * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - GESTURE_EVENT_NONE = 0, /**< The gesture is not detected */ - GESTURE_EVENT_DETECTED = 1, /**< The gesture is detected */ + GESTURE_EVENT_NONE = 0, /**< Detected nothing */ + GESTURE_EVENT_DETECTED = 1, /**< Detected the gesture */ - GESTURE_SHAKE_DETECTED = 1, /**< Shake gesture is detected */ - GESTURE_SHAKE_FINISHED = 2, /**< Shake gesture finished */ + GESTURE_SHAKE_DETECTED = 1, /**< Shake gesture started */ + GESTURE_SHAKE_FINISHED = 2, /**< Shake gesture stopped */ - GESTURE_SNAP_X_NEGATIVE = 1, /**< -X snap is detected */ - GESTURE_SNAP_X_POSITIVE = 2, /**< +X snap is detected */ - GESTURE_SNAP_Y_NEGATIVE = 3, /**< -Y snap is detected */ - GESTURE_SNAP_Y_POSITIVE = 4, /**< +Y snap is detected */ - GESTURE_SNAP_Z_NEGATIVE = 5, /**< -Z snap is detected */ - GESTURE_SNAP_Z_POSITIVE = 6, /**< +Z snap is detected */ + GESTURE_SNAP_X_NEGATIVE = 1, /**< Detected -X snap */ + GESTURE_SNAP_X_POSITIVE = 2, /**< Detected +X snap */ + GESTURE_SNAP_Y_NEGATIVE = 3, /**< Detected -Y snap */ + GESTURE_SNAP_Y_POSITIVE = 4, /**< Detected +Y snap */ + GESTURE_SNAP_Z_NEGATIVE = 5, /**< Detected -Z snap */ + GESTURE_SNAP_Z_POSITIVE = 6, /**< Detected +Z snap */ } gesture_event_e; /** diff --git a/src/gesture/gesture.cpp b/src/gesture/gesture.cpp index 2c34c85..f609090 100644 --- a/src/gesture/gesture.cpp +++ b/src/gesture/gesture.cpp @@ -25,6 +25,8 @@ #include "motion_engine.h" #include "gesture.h" +using namespace ctx::gesture; + static ctx::handle_map_t<_cx_gesture_h> handle_map; void cx_gesture_deliver_data(int req_id, _cx_gesture_data data, double timestamp, int error) @@ -51,14 +53,14 @@ EXTAPI int gesture_is_supported(gesture_type_e gesture, bool* supported) ASSERT_SUPPORTED(FEATURE_KEY_GESTURE); ASSERT_NULL(supported); - if (!ctx::gesture::me_check_coverage(gesture)) - return GESTURE_ERROR_NONE; + int ret = GESTURE_ERROR_NONE; - int ret = ctx::gesture::me_is_supported(gesture); - if (ret == GESTURE_ERROR_NONE) - *supported = true; + if (motion_engine::check_coverage(gesture)) { + ret = motion_engine::is_supported(gesture); + *supported = (ret == GESTURE_ERROR_NONE); + } - return GESTURE_ERROR_NONE; + return ret; } EXTAPI int gesture_create(gesture_h *handle) @@ -109,8 +111,8 @@ EXTAPI int gesture_start_recognition(gesture_h handle, gesture_type_e gesture, g int ret; - if (ctx::gesture::me_check_coverage(gesture)) { - ret = ctx::gesture::me_start(handle, gesture, option); + if (motion_engine::check_coverage(gesture)) { + ret = motion_engine::start(handle, gesture, option); } else { ret = GESTURE_ERROR_INVALID_PARAMETER; } @@ -128,8 +130,8 @@ EXTAPI int gesture_stop_recognition(gesture_h handle) int ret = GESTURE_ERROR_NOT_STARTED; if (handle_map.find(handle->req_id) != NULL) { - if (ctx::gesture::me_check_coverage(handle->gesture)) - ctx::gesture::me_stop(handle); + if (motion_engine::check_coverage(handle->gesture)) + motion_engine::stop(handle); handle_map.remove(handle->req_id); ret = GESTURE_ERROR_NONE; diff --git a/src/gesture/motion_engine.cpp b/src/gesture/motion_engine.cpp index fb2ae38..1c01997 100644 --- a/src/gesture/motion_engine.cpp +++ b/src/gesture/motion_engine.cpp @@ -159,7 +159,7 @@ static int get_me_option(int mode) return CTX_VALUE_UNDEFINED; } -bool ctx::gesture::me_check_coverage(int motion) +bool ctx::gesture::motion_engine::check_coverage(int motion) { switch (motion) { case GESTURE_SHAKE: @@ -177,7 +177,7 @@ bool ctx::gesture::me_check_coverage(int motion) } } -int ctx::gesture::me_is_supported(int motion) +int ctx::gesture::motion_engine::is_supported(int motion) { int handle = -1, res; int ev_type = get_event_type(motion); @@ -187,7 +187,7 @@ int ctx::gesture::me_is_supported(int motion) return res; } -int ctx::gesture::me_start(_cx_gesture_h *handle, int gesture, int option) +int ctx::gesture::motion_engine::start(_cx_gesture_h *handle, int gesture, int option) { int ev_type = get_event_type(gesture); int me_opt = get_me_option(option); @@ -206,7 +206,7 @@ int ctx::gesture::me_start(_cx_gesture_h *handle, int gesture, int option) return GESTURE_ERROR_NONE; } -int ctx::gesture::me_stop(_cx_gesture_h *handle) +int ctx::gesture::motion_engine::stop(_cx_gesture_h *handle) { LOGI("Stopping MotionEngine Event %d", handle->me_event); diff --git a/src/gesture/motion_engine.h b/src/gesture/motion_engine.h index 82f8003..36f3ec7 100644 --- a/src/gesture/motion_engine.h +++ b/src/gesture/motion_engine.h @@ -23,13 +23,13 @@ #include #include "gesture.h" -namespace ctx { namespace gesture{ +namespace ctx { namespace gesture { namespace motion_engine { - bool me_check_coverage(int gesture); - int me_is_supported(int gesture); - int me_start(_cx_gesture_h *handle, int gesture, int mode); - int me_stop(_cx_gesture_h *handle); + bool check_coverage(int gesture); + int is_supported(int gesture); + int start(_cx_gesture_h *handle, int gesture, int mode); + int stop(_cx_gesture_h *handle); -} } /* namespace ctx::gesture */ +} } } #endif /* End of _CX_GESTURE_MOTION_ENGINE_H_ */ -- 2.34.1 From 46fde31ccebd7f5b69c04d8bfa3b7c7ffc65610d Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Fri, 15 Jan 2016 10:53:51 +0900 Subject: [PATCH 03/16] Fix broken links in doxygen Signed-off-by: Somin Kim (cherry picked from commit 65df40631616e6fc5b5a1726e9402bbf72f04a70) Signed-off-by: Mu-Woong Lee Change-Id: I5247c35e258fa503457a6b994a413440d04f7247 --- doc/activity_recognition_doc.h | 2 +- doc/gesture_recognition_doc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/activity_recognition_doc.h b/doc/activity_recognition_doc.h index ba22e7d..f7c822f 100644 --- a/doc/activity_recognition_doc.h +++ b/doc/activity_recognition_doc.h @@ -121,6 +121,6 @@ * * 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.\n * - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature Element. * */ diff --git a/doc/gesture_recognition_doc.h b/doc/gesture_recognition_doc.h index 3444820..4432482 100644 --- a/doc/gesture_recognition_doc.h +++ b/doc/gesture_recognition_doc.h @@ -144,6 +144,6 @@ * * 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.\n * - * More details on featuring your application can be found from Feature Element. + * More details on featuring your application can be found from Feature Element. * */ -- 2.34.1 From c878386cd5f931496d2d6a25b14763cddcd34807 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 6 Apr 2016 18:58:21 +0900 Subject: [PATCH 04/16] Clean-up build scripts Change-Id: Ie83e9cb07e2cb0c0c7a7c58715c39a561285e69f Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 25 ++++++++-------------- packaging/motion.spec | 50 ++++++++++++++++++++----------------------- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21b3e92..c2049b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,22 +2,14 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(motion) INCLUDE(GNUInstallDirs) +# Target lib (for backward compatibility, the below old naming is used) +SET(target "core-context-manager") + # Source Lists -SET(SRCS - src/shared/ctx_util_misc.cpp - src/shared/ctx_util_sensor.cpp -# Gesture - src/gesture/gesture.cpp - src/gesture/motion_engine.cpp -# Activity - src/activity/activity.cpp -) +FILE(GLOB_RECURSE SRCS src/*.cpp) SET(inc_subdir "context-service") -SET(dependency "dlog glib-2.0 capi-base-common capi-system-info sensor") - -# Target lib (for backward compatibility, the below old naming is used) -SET(target "core-context-manager") +SET(dependency "glib-2.0 dlog capi-base-common capi-system-info sensor") # Options INCLUDE(FindPkgConfig) @@ -26,7 +18,8 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/src/shared ) -ADD_DEFINITIONS(-O2 -Wall -fPIC -fvisibility=hidden -Wl,--as-needed) +ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden) +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section") # Build pkg_check_modules(pkgs REQUIRED ${dependency}) @@ -43,7 +36,7 @@ SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) # Install -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries) +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${inc_subdir} FILES_MATCHING PATTERN "*.h" @@ -51,7 +44,7 @@ INSTALL( SET(VERSION ${FULLVER}) SET(PC_PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(PC_NAME ${target}) +SET(PC_NAME ${PROJECT_NAME}) SET(PC_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") SET(PC_INCLUDE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${inc_subdir}") SET(PC_DESCRIPTION "Tizen Native Motion Recognition API") diff --git a/packaging/motion.spec b/packaging/motion.spec index ebad3a4..d0eb8d8 100644 --- a/packaging/motion.spec +++ b/packaging/motion.spec @@ -1,25 +1,21 @@ Name: motion Summary: Tizen Native Motion Recognition API -Version: 1.1.3 +Version: 1.1.4 Release: 1 -Group: Framework/context +Group: Service/Context License: Apache-2.0 Source0: %{name}-%{version}.tar.gz + BuildRequires: cmake -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(sensor) + Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig -%ifarch %{arm} -%define ARCH arm -%else -%define ARCH i586 -%endif - %description Tizen Native Motion Recognition API @@ -29,21 +25,27 @@ Tizen Native Motion Recognition API %build MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -export CFLAGS+=" -Werror -Wextra -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wswitch-default" -export CXXFLAGS+=" -Werror -Wextra -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wswitch-default -Wnon-virtual-dtor -Wno-c++0x-compat" +export CFLAGS+=" -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-parameter" +export CXXFLAGS+=" -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-parameter" -#export CFLAGS+=" -Wno-array-bounds -Wno-ignored-qualifiers" -export CFLAGS+=" -Wno-unused-parameter -Wno-empty-body" -export CXXFLAGS+=" -Wno-unused-parameter -Wno-empty-body" +export CFLAGS+=" -Wno-empty-body -fomit-frame-pointer -fno-optimize-sibling-calls" +export CXXFLAGS+=" -Wno-empty-body -fomit-frame-pointer -fno-optimize-sibling-calls" -export CFLAGS+=" -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow -fno-common" -export CXXFLAGS+=" -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow" +export CFLAGS+=" -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow" +export CXXFLAGS+=" -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow" -export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE" -export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE" -export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE" +export CFLAGS+=" -fno-common" +export CXXFLAGS+=" -Wnon-virtual-dtor" +export CXXFLAGS+=" -std=c++11 -Wno-c++11-compat" -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCH=%{ARCH} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DPROFILE=%{PROFILE} +#export CFLAGS+=" -Wcast-qual" +#export CXXFLAGS+=" -Wcast-qual" + +#export CFLAGS+=" -DTIZEN_ENGINEER_MODE" +#export CXXFLAGS+=" -DTIZEN_ENGINEER_MODE" +#export FFLAGS+=" -DTIZEN_ENGINEER_MODE" + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} make %{?jobs:-j%jobs} %install @@ -75,12 +77,6 @@ Requires: %{name} = %{version}-%{release} %description devel Tizen Native Motion Recognition API (Development) -%post devel -/sbin/ldconfig - -%postun devel -/sbin/ldconfig - %files devel %defattr(-,root,root,-) %{_includedir}/*/*.h -- 2.34.1 From 53f5370f330abcab2bd046274807b89ead4c4c14 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 7 Apr 2016 16:24:26 +0900 Subject: [PATCH 05/16] Update license agreement Change-Id: I2b434eb62c8fb26235330026c465061b56a03613 Signed-off-by: Mu-Woong Lee --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 5b25701..87979c5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. +Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 @@ -188,7 +188,7 @@ Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + Copyright (c) [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -- 2.34.1 From 81d41ed5e3c00481ceaa74ec2c1203819898644c Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 6 Apr 2016 21:23:43 +0900 Subject: [PATCH 06/16] Re-implement using the latest sensor internal API Change-Id: I46a23aeb008c886c421c155693f48431f41724f7 Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 5 +- packaging/motion.spec | 1 - src/Activity.cpp | 117 ++++++++++ src/ActivityProxy.cpp | 71 ++++++ src/{activity/activity.h => ActivityProxy.h} | 45 ++-- src/Gesture.cpp | 143 ++++++++++++ src/GestureProxy.cpp | 78 +++++++ src/GestureProxy.h | 56 +++++ src/SensorProxy.cpp | 116 ++++++++++ src/SensorProxy.h | 58 +++++ .../ctx_util_sensor.h => TypesInternal.cpp} | 30 +-- src/TypesInternal.h | 89 +++++++ src/activity/activity.cpp | 55 ----- src/gesture/gesture.cpp | 176 -------------- src/gesture/gesture.h | 48 ---- src/gesture/motion_engine.cpp | 219 ------------------ src/gesture/motion_engine.h | 35 --- src/shared/ctx_error.h | 35 --- src/shared/ctx_types_private.h | 63 ----- src/shared/ctx_util_misc.cpp | 87 ------- src/shared/ctx_util_misc.h | 38 --- src/shared/ctx_util_sensor.cpp | 71 ------ src/shared/handle_map.h | 107 --------- 23 files changed, 776 insertions(+), 967 deletions(-) create mode 100644 src/Activity.cpp create mode 100644 src/ActivityProxy.cpp rename src/{activity/activity.h => ActivityProxy.h} (50%) create mode 100644 src/Gesture.cpp create mode 100644 src/GestureProxy.cpp create mode 100644 src/GestureProxy.h create mode 100644 src/SensorProxy.cpp create mode 100644 src/SensorProxy.h rename src/{shared/ctx_util_sensor.h => TypesInternal.cpp} (54%) create mode 100644 src/TypesInternal.h delete mode 100644 src/activity/activity.cpp delete mode 100644 src/gesture/gesture.cpp delete mode 100644 src/gesture/gesture.h delete mode 100644 src/gesture/motion_engine.cpp delete mode 100644 src/gesture/motion_engine.h delete mode 100644 src/shared/ctx_error.h delete mode 100644 src/shared/ctx_types_private.h delete mode 100644 src/shared/ctx_util_misc.cpp delete mode 100644 src/shared/ctx_util_misc.h delete mode 100644 src/shared/ctx_util_sensor.cpp delete mode 100644 src/shared/handle_map.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c2049b8..d6db33d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ INCLUDE(GNUInstallDirs) SET(target "core-context-manager") # Source Lists -FILE(GLOB_RECURSE SRCS src/*.cpp) +FILE(GLOB SRCS src/*.cpp) SET(inc_subdir "context-service") SET(dependency "glib-2.0 dlog capi-base-common capi-system-info sensor") @@ -15,10 +15,9 @@ SET(dependency "glib-2.0 dlog capi-base-common capi-system-info sensor") INCLUDE(FindPkgConfig) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/src/shared ) -ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden) +ADD_DEFINITIONS(-O2 -Wall -fPIC -flto -fdata-sections -ffunction-sections -fvisibility=hidden) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section") # Build diff --git a/packaging/motion.spec b/packaging/motion.spec index d0eb8d8..694b22e 100644 --- a/packaging/motion.spec +++ b/packaging/motion.spec @@ -36,7 +36,6 @@ export CXXFLAGS+=" -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict export CFLAGS+=" -fno-common" export CXXFLAGS+=" -Wnon-virtual-dtor" -export CXXFLAGS+=" -std=c++11 -Wno-c++11-compat" #export CFLAGS+=" -Wcast-qual" #export CXXFLAGS+=" -Wcast-qual" diff --git a/src/Activity.cpp b/src/Activity.cpp new file mode 100644 index 0000000..46e29a0 --- /dev/null +++ b/src/Activity.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2016 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 +#include "ActivityProxy.h" + +#define FEATURE_ACTIVITY "tizen.org/feature/sensor.activity_recognition" + +#define ACTIVITY_FIRST ACTIVITY_STATIONARY +#define ACTIVITY_LAST ACTIVITY_IN_VEHICLE +#define IS_VALID_ACTIVITY(X) (ACTIVITY_FIRST <= (X) && (X) <= ACTIVITY_LAST) + +using namespace motion; + +struct _activity_handle_s { + ActivityProxy *proxy; +}; + +EXTAPI int activity_is_supported(activity_type_e activity, bool* supported) +{ + if (supported) + *supported = false; + + ASSERT_SUPPORTED(FEATURE_ACTIVITY); + ASSERT_NOT_NULL(supported); + IF_FAIL_RETURN(IS_VALID_ACTIVITY(activity), ERR_INVALID_PARAMETER); + + *supported = ActivityProxy::isSupported(activity); + return ERR_NONE; +} + +EXTAPI int activity_create(activity_h *handle) +{ + ASSERT_SUPPORTED(FEATURE_ACTIVITY); + ASSERT_NOT_NULL(handle); + + _activity_handle_s *hdl = static_cast(malloc(sizeof(_activity_handle_s))); + IF_FAIL_RETURN_TAG(hdl, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); + + hdl->proxy = new(std::nothrow) ActivityProxy(); + if (hdl->proxy == NULL) { + _E("Memory allocation failed"); + free(hdl); + return ERR_OPERATION_FAILED; + } + + *handle = hdl; + return ERR_NONE; +} + +EXTAPI int activity_release(activity_h handle) +{ + ASSERT_SUPPORTED(FEATURE_ACTIVITY); + ASSERT_NOT_NULL(handle); + + delete handle->proxy; + free(handle); + + return ERR_NONE; +} + +EXTAPI int activity_start_recognition(activity_h handle, activity_type_e activity, activity_recognition_cb callback, void *user_data) +{ + ASSERT_SUPPORTED(FEATURE_ACTIVITY); + ASSERT_NOT_NULL(handle); + ASSERT_NOT_NULL(callback); + IF_FAIL_RETURN(IS_VALID_ACTIVITY(activity), ERR_INVALID_PARAMETER); + + if (!handle->proxy->setActivity(activity)) { + return ERR_INVALID_PARAMETER; + } + + handle->proxy->setPowerSave(false); + handle->proxy->setCb(callback); + handle->proxy->setUserData(user_data); + + if (!handle->proxy->start()) { + return ERR_OPERATION_FAILED; + } + + return ERR_NONE; +} + +EXTAPI int activity_stop_recognition(activity_h handle) +{ + ASSERT_SUPPORTED(FEATURE_ACTIVITY); + ASSERT_NOT_NULL(handle); + + handle->proxy->stop(); + + return ERR_NONE; +} + +EXTAPI int activity_get_accuracy(const activity_data_h data, activity_accuracy_e *accuracy) +{ + ASSERT_SUPPORTED(FEATURE_ACTIVITY); + ASSERT_NOT_NULL(data); + ASSERT_NOT_NULL(accuracy); + + *accuracy = static_cast(data->accuracy); + + return ERR_NONE; +} diff --git a/src/ActivityProxy.cpp b/src/ActivityProxy.cpp new file mode 100644 index 0000000..fa8275d --- /dev/null +++ b/src/ActivityProxy.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016 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 +#include "ActivityProxy.h" + +#define ACTIVITY_BIT(X) (0x1 << (int)(X)) +#define ACTIVITY_ENUM(X) ((int)log2f((X))) + +using namespace motion; + +ActivityProxy::ActivityProxy() + : __activityType(static_cast(UNDEFINED)) + , __callback(NULL) +{ +} + +ActivityProxy::~ActivityProxy() +{ +} + +bool ActivityProxy::setActivity(activity_type_e type) +{ + __activityType = type; + setSensor(ACTIVITY_TRACKER_SENSOR); + return true; +} + +void ActivityProxy::setCb(activity_recognition_cb cb) +{ + __callback = cb; +} + +bool ActivityProxy::start() +{ + IF_FAIL_RETURN(SensorProxy::start(), false); + sensord_set_attribute_int(sensorHandle, SENSOR_ATTR_ACTIVITY, ACTIVITY_BIT(__activityType)); + return true; +} + +bool ActivityProxy::isSupported(activity_type_e type) +{ + return SensorProxy::isSupported(ACTIVITY_TRACKER_SENSOR); +} + +void ActivityProxy::onEvent(sensor_data_t *eventData) +{ + _activity_data_s data; + + IF_FAIL_VOID(ACTIVITY_ENUM(eventData->values[0]) == static_cast(__activityType)); + + data.activity = __activityType; + data.accuracy = eventData->accuracy; + + __callback(__activityType, &data, getTime(eventData->timestamp), + static_cast(ERR_NONE), userData); +} diff --git a/src/activity/activity.h b/src/ActivityProxy.h similarity index 50% rename from src/activity/activity.h rename to src/ActivityProxy.h index c802c90..402bd27 100644 --- a/src/activity/activity.h +++ b/src/ActivityProxy.h @@ -1,7 +1,5 @@ /* - * motion - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -17,22 +15,39 @@ * */ -#ifndef _CONTEXT_ACTIVITY_H_ -#define _CONTEXT_ACTIVITY_H_ +#ifndef _MOTION_ACTIVITY_PROXY_H_ +#define _MOTION_ACTIVITY_PROXY_H_ #include +#include "SensorProxy.h" -#define FEATURE_KEY_ACTIVITY "tizen.org/feature/sensor.activity_recognition" - -typedef struct _activity_data_s { +struct _activity_data_s { int activity; int accuracy; -} _cx_activity_data; +}; + +namespace motion { + + class ActivityProxy : public SensorProxy { + public: + ActivityProxy(); + ~ActivityProxy(); + + bool setActivity(activity_type_e type); + void setCb(activity_recognition_cb cb); + + bool start(); + + static bool isSupported(activity_type_e type); + + protected: + void onEvent(sensor_data_t *eventData); + + private: + activity_type_e __activityType; + activity_recognition_cb __callback; + }; -typedef struct _activity_handle_s { - int req_id; - activity_recognition_cb callback; - void *user_data; -} _cx_activity_h; +} -#endif /* End of _CONTEXT_ACTIVITY_PRIVATE_H_ */ +#endif /* _MOTION_ACTIVITY_PROXY_PRIVATE_H_ */ diff --git a/src/Gesture.cpp b/src/Gesture.cpp new file mode 100644 index 0000000..f09d17a --- /dev/null +++ b/src/Gesture.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2016 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 +#include "GestureProxy.h" + +#define FEATURE_GESTURE "tizen.org/feature/sensor.gesture_recognition" + +#define GESTURE_FIRST GESTURE_DOUBLE_TAP +#define GESTURE_LAST GESTURE_WRIST_UP +#define IS_VALID_GESTURE(X) (GESTURE_FIRST <= (X) && (X) <= GESTURE_LAST) + +using namespace motion; + +struct _gesture_handle_s { + GestureProxy *proxy; +}; + +EXTAPI int gesture_is_supported(gesture_type_e gesture, bool* supported) +{ + if (supported) + *supported = false; + + ASSERT_SUPPORTED(FEATURE_GESTURE); + ASSERT_NOT_NULL(supported); + IF_FAIL_RETURN(IS_VALID_GESTURE(gesture), ERR_INVALID_PARAMETER); + + *supported = GestureProxy::isSupported(gesture); + return ERR_NONE; +} + +EXTAPI int gesture_create(gesture_h *handle) +{ + ASSERT_SUPPORTED(FEATURE_GESTURE); + ASSERT_NOT_NULL(handle); + + _gesture_handle_s *hdl = static_cast(malloc(sizeof(_gesture_handle_s))); + IF_FAIL_RETURN_TAG(hdl, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); + + hdl->proxy = new(std::nothrow) GestureProxy(); + if (hdl->proxy == NULL) { + _E("Memory allocation failed"); + free(hdl); + return ERR_OPERATION_FAILED; + } + + *handle = hdl; + return ERR_NONE; +} + +EXTAPI int gesture_release(gesture_h handle) +{ + ASSERT_SUPPORTED(FEATURE_GESTURE); + ASSERT_NOT_NULL(handle); + + delete handle->proxy; + free(handle); + + return ERR_NONE; +} + +EXTAPI int gesture_start_recognition(gesture_h handle, gesture_type_e gesture, gesture_option_e option, gesture_recognition_cb callback, void *user_data) +{ + ASSERT_SUPPORTED(FEATURE_GESTURE); + ASSERT_NOT_NULL(handle); + ASSERT_NOT_NULL(callback); + IF_FAIL_RETURN(IS_VALID_GESTURE(gesture), ERR_INVALID_PARAMETER); + + if (!handle->proxy->setGesture(gesture)) { + return ERR_INVALID_PARAMETER; + } + + if (option == GESTURE_OPTION_DEFAULT) { + handle->proxy->setPowerSave(true); + } else if (option == GESTURE_OPTION_ALWAYS_ON) { + handle->proxy->setPowerSave(false); + } else { + return ERR_INVALID_PARAMETER; + } + + handle->proxy->setCb(callback); + handle->proxy->setUserData(user_data); + + if (!handle->proxy->start()) { + return ERR_OPERATION_FAILED; + } + + return ERR_NONE; +} + +EXTAPI int gesture_stop_recognition(gesture_h handle) +{ + ASSERT_SUPPORTED(FEATURE_GESTURE); + ASSERT_NOT_NULL(handle); + + handle->proxy->stop(); + + return ERR_NONE; +} + +EXTAPI int gesture_get_event(const gesture_data_h data, gesture_event_e *event) +{ + ASSERT_SUPPORTED(FEATURE_GESTURE); + ASSERT_NOT_NULL(data); + ASSERT_NOT_NULL(event); + + if (data->gesture == GESTURE_TILT) + return GESTURE_ERROR_NOT_SUPPORTED; + + *event = static_cast(data->event); + + return ERR_NONE; +} + +EXTAPI int gesture_get_tilt(const gesture_data_h data, int *x, int *y) +{ + ASSERT_SUPPORTED(FEATURE_GESTURE); + ASSERT_NOT_NULL(data); + ASSERT_NOT_NULL(x); + ASSERT_NOT_NULL(y); + + if (data->gesture != GESTURE_TILT) + return ERR_NOT_SUPPORTED; + + *x = data->tilt_x; + *y = data->tilt_y; + + return ERR_NONE; +} diff --git a/src/GestureProxy.cpp b/src/GestureProxy.cpp new file mode 100644 index 0000000..474e968 --- /dev/null +++ b/src/GestureProxy.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016 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 "GestureProxy.h" + +using namespace motion; + +GestureProxy::GestureProxy() + : __gestureType(static_cast(UNDEFINED)) + , __callback(NULL) +{ +} + +GestureProxy::~GestureProxy() +{ +} + +bool GestureProxy::setGesture(gesture_type_e type) +{ + sensor_type_t sensor = __toSensor(type); + IF_FAIL_RETURN(sensor != UNKNOWN_SENSOR, false); + + __gestureType = type; + setSensor(sensor); + return true; +} + +void GestureProxy::setCb(gesture_recognition_cb cb) +{ + __callback = cb; +} + +bool GestureProxy::isSupported(gesture_type_e type) +{ + sensor_type_t sensor = __toSensor(type); + IF_FAIL_RETURN(sensor != UNKNOWN_SENSOR, false); + + return SensorProxy::isSupported(sensor); +} + +void GestureProxy::onEvent(sensor_data_t *eventData) +{ + _gesture_data_s data; + data.gesture = __gestureType; + + /* TODO: This is the default form. + For each sensor, this part needs to adapt accordingly */ + data.event = static_cast(eventData->values[0]); + + __callback(__gestureType, &data, getTime(eventData->timestamp), + static_cast(ERR_NONE), userData); +} + +sensor_type_t GestureProxy::__toSensor(gesture_type_e type) +{ + switch (type) { + case GESTURE_PICK_UP: + return GESTURE_MOVEMENT_SENSOR; + case GESTURE_WRIST_UP: + return GESTURE_WRIST_UP_SENSOR; + default: + return UNKNOWN_SENSOR; + } +} diff --git a/src/GestureProxy.h b/src/GestureProxy.h new file mode 100644 index 0000000..9f1951e --- /dev/null +++ b/src/GestureProxy.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016 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 _MOTION_GESTURE_PROXY_H_ +#define _MOTION_GESTURE_PROXY_H_ + +#include +#include "SensorProxy.h" + +struct _gesture_data_s { + int gesture; + int event; + int tilt_x; + int tilt_y; +}; + +namespace motion { + + class GestureProxy : public SensorProxy { + public: + GestureProxy(); + ~GestureProxy(); + + bool setGesture(gesture_type_e type); + void setCb(gesture_recognition_cb cb); + + static bool isSupported(gesture_type_e type); + + protected: + void onEvent(sensor_data_t *eventData); + + private: + gesture_type_e __gestureType; + gesture_recognition_cb __callback; + + static sensor_type_t __toSensor(gesture_type_e type); + }; + +} + +#endif /* _MOTION_GESTURE_PROXY_H_ */ + diff --git a/src/SensorProxy.cpp b/src/SensorProxy.cpp new file mode 100644 index 0000000..551c8f7 --- /dev/null +++ b/src/SensorProxy.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2016 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 +#include +#include "SensorProxy.h" + +#define SENSOR_EVENT(X) (((int)(X) << 16) | 0x01) + +using namespace motion; + +SensorProxy::SensorProxy() + : sensorHandle(-1) + , running(false) + , sensorType(UNKNOWN_SENSOR) + , powerSave(true) + , userData(NULL) +{ +} + +SensorProxy::~SensorProxy() +{ + stop(); +} + +void SensorProxy::setSensor(sensor_type_t type) +{ + sensorType = type; +} + +void SensorProxy::setPowerSave(bool ps) +{ + powerSave = ps; +} + +void SensorProxy::setUserData(void *data) +{ + userData = data; +} + +bool SensorProxy::start() +{ + sensor_t sensor = sensord_get_sensor(sensorType); + IF_FAIL_RETURN_TAG(sensor, false, _E, "Getting sensor failed"); + + sensorHandle = sensord_connect(sensor); + IF_FAIL_RETURN_TAG(sensorHandle >= 0, false, _E, "Connection failed"); + + if (!sensord_register_event(sensorHandle, SENSOR_EVENT(sensorType), 0, 0, __eventCb, this)) { + _E("Event registration failed"); + sensord_disconnect(sensorHandle); + sensorHandle = -1; + return false; + } + + if (!sensord_start(sensorHandle, powerSave ? SENSOR_OPTION_DEFAULT : SENSOR_OPTION_ALWAYS_ON)) { + _E("Starting failed"); + sensord_unregister_event(sensorHandle, SENSOR_EVENT(sensorType)); + sensord_disconnect(sensorHandle); + sensorHandle = -1; + return false; + } + + return true; +} + +void SensorProxy::stop() +{ + IF_FAIL_VOID(sensorHandle >= 0); + + sensord_stop(sensorHandle); + sensord_unregister_event(sensorHandle, SENSOR_EVENT(sensorType)); + sensord_disconnect(sensorHandle); + sensorHandle = -1; +} + +double SensorProxy::getTime(unsigned long long monotonic) +{ + struct timespec ts; + struct timeval tv; + double timeDiff; + double timestamp; + + clock_gettime(CLOCK_MONOTONIC, &ts); + timeDiff = (ts.tv_sec * 1000000000.0 + ts.tv_nsec) / 1000000.0 - monotonic / 1000.0; + + gettimeofday(&tv, NULL); + timestamp = tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0 - timeDiff; + return timestamp; +} + +bool SensorProxy::isSupported(sensor_type_t type) +{ + sensor_t sensor = sensord_get_sensor(type); + return (sensor != NULL); +} + +void SensorProxy::__eventCb(sensor_t sensor, unsigned int eventType, sensor_data_t *eventData, void *cbData) +{ + SensorProxy *instance = static_cast(cbData); + instance->onEvent(eventData); +} diff --git a/src/SensorProxy.h b/src/SensorProxy.h new file mode 100644 index 0000000..0f0d01e --- /dev/null +++ b/src/SensorProxy.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016 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 _MOTION_SENSOR_PROXY_H_ +#define _MOTION_SENSOR_PROXY_H_ + +#include +#include "TypesInternal.h" + +namespace motion { + + class SensorProxy { + public: + SensorProxy(); + virtual ~SensorProxy(); + + void setSensor(sensor_type_t type); + void setPowerSave(bool ps); + void setUserData(void *data); + + void stop(); + + virtual bool start(); + + protected: + int sensorHandle; + bool running; + sensor_type_t sensorType; + bool powerSave; + void *userData; + + double getTime(unsigned long long monotonic); + + static bool isSupported(sensor_type_t type); + + virtual void onEvent(sensor_data_t *eventData) = 0; + + private: + static void __eventCb(sensor_t sensor, unsigned int eventType, sensor_data_t *eventData, void *cbData); + }; + +} + +#endif /* _MOTION_SENSOR_PROXY_H_ */ diff --git a/src/shared/ctx_util_sensor.h b/src/TypesInternal.cpp similarity index 54% rename from src/shared/ctx_util_sensor.h rename to src/TypesInternal.cpp index 70a8ded..2a7a755 100644 --- a/src/shared/ctx_util_sensor.h +++ b/src/TypesInternal.cpp @@ -1,7 +1,5 @@ /* - * motion - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -17,17 +15,21 @@ * */ -#ifndef __CONTEXT_UTIL_SENSOR_H__ -#define __CONTEXT_UTIL_SENSOR_H__ - -#include - -namespace ctx { namespace sensor { - - int connect(int *handle, sensor_type_t sensor, unsigned int event, int option, sensor_cb_t cb, void *user_data); - void disconnect(int *handle, sensor_type_t sensor, unsigned int event); +#include +#include "TypesInternal.h" -} } /* namespace ctx::sensor */ +int motion::isSupported(const char *feature) +{ + bool supported = false; + int ret = system_info_get_platform_bool(feature, &supported); -#endif /* __CONTEXT_UTIL_SENSOR_H__ */ + if (ret == ERR_NONE && !supported) { + _W("Not Supported: %s", feature); + return ERR_NOT_SUPPORTED; + } else if (ret != ERR_NONE) { + _E("Getting system info failed: %#x", ret); + return ERR_OPERATION_FAILED; + } + return ERR_NONE; +} diff --git a/src/TypesInternal.h b/src/TypesInternal.h new file mode 100644 index 0000000..bde7980 --- /dev/null +++ b/src/TypesInternal.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2016 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 _MOTION_TYPES_INTERNAL_H_ +#define _MOTION_TYPES_INTERNAL_H_ + +#include +#include + +#define EXTAPI __attribute__ ((visibility("default"))) + +#define UNDEFINED -1 + +#define ERR_NONE TIZEN_ERROR_NONE +#define ERR_INVALID_PARAMETER TIZEN_ERROR_INVALID_PARAMETER +#define ERR_INVALID_OPERATION TIZEN_ERROR_INVALID_OPERATION +#define ERR_OUT_OF_MEMORY TIZEN_ERROR_OUT_OF_MEMORY +#define ERR_PERMISSION_DENIED TIZEN_ERROR_PERMISSION_DENIED +#define ERR_NOT_SUPPORTED TIZEN_ERROR_NOT_SUPPORTED +#define ERR_NO_DATA TIZEN_ERROR_NO_DATA +#define ERR_ALREADY_STARTED (TIZEN_ERROR_CONTEXT | 0x01) +#define ERR_NOT_STARTED (TIZEN_ERROR_CONTEXT | 0x02) +#define ERR_OUT_OF_RANGE (TIZEN_ERROR_CONTEXT | 0x03) +#define ERR_OPERATION_FAILED (TIZEN_ERROR_CONTEXT | 0x04) +#define ERR_RULE_ENABLED (TIZEN_ERROR_CONTEXT | 0x05) +#define ERR_RULE_NOT_ENABLED (TIZEN_ERROR_CONTEXT | 0x06) +#define ERR_INVALID_RULE (TIZEN_ERROR_CONTEXT | 0x07) +#define ERR_RULE_NOT_EXIST (TIZEN_ERROR_CONTEXT | 0x08) +#define ERR_INVALID_DATA ERR_INVALID_RULE +#define ERR_DATA_EXIST (TIZEN_ERROR_CONTEXT | 0X09) + +/* Logging and Error Handling */ +#define _I SLOGI +#define _D SLOGD +#define _W SLOGW +#define _E SLOGE +#define _SI SECURE_SLOGI +#define _SD SECURE_SLOGD +#define _SW SECURE_LOGW +#define _SE SECURE_SLOGE + +#define IF_FAIL_RETURN_TAG(cond, ret, tag, fmt, arg...) \ + do { if (!(cond)) { tag(fmt, ##arg); return ret; } } while (0) + +#define IF_FAIL_RETURN(cond, ret) \ + do { if (!(cond)) { return ret; } } while (0) + +#define IF_FAIL_VOID_TAG(cond, tag, fmt, arg...) \ + do { if (!(cond)) { tag(fmt, ##arg); return; } } while (0) + +#define IF_FAIL_VOID(cond) \ + do { if (!(cond)) { return; } } while (0) + +#define IF_FAIL_CATCH_TAG(cond, tag, fmt, arg...) \ + do { if (!(cond)) { tag(fmt, ##arg); goto CATCH; } } while (0) + +#define IF_FAIL_CATCH(cond) \ + do { if (!(cond)) { goto CATCH; } } while (0) + +#define IS_FAILED(X) ((X) != ERR_NONE) + +#define ASSERT_ALLOC(X) IF_FAIL_RETURN_TAG(X, ERR_OUT_OF_MEMORY, _E, "Memory allocation failed") +#define ASSERT_NOT_NULL(X) IF_FAIL_RETURN_TAG(X, ERR_INVALID_PARAMETER, _E, "Parameter null") + +#define ASSERT_SUPPORTED(feature) \ + do { \ + int __result = motion::isSupported(feature); \ + if (__result != ERR_NONE) return __result; \ + } while (0) + +namespace motion { + int isSupported(const char *feature); +} + +#endif /* _MOTION_TYPES_INTERNAL_H_ */ diff --git a/src/activity/activity.cpp b/src/activity/activity.cpp deleted file mode 100644 index 020a1cf..0000000 --- a/src/activity/activity.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 -#include -#include "activity.h" - -EXTAPI int activity_is_supported(activity_type_e activity, bool* supported) -{ - if (supported) - *supported = false; - - return CERR_NOT_SUPPORTED; -} - -EXTAPI int activity_create(activity_h *handle) -{ - return CERR_NOT_SUPPORTED; -} - -EXTAPI int activity_release(activity_h handle) -{ - return CERR_NOT_SUPPORTED; -} - -EXTAPI int activity_start_recognition(activity_h handle, activity_type_e activity, activity_recognition_cb callback, void *user_data) -{ - return CERR_NOT_SUPPORTED; -} - -EXTAPI int activity_stop_recognition(activity_h handle) -{ - return CERR_NOT_SUPPORTED; -} - -EXTAPI int activity_get_accuracy(const activity_data_h data, activity_accuracy_e *accuracy) -{ - return CERR_NOT_SUPPORTED; -} diff --git a/src/gesture/gesture.cpp b/src/gesture/gesture.cpp deleted file mode 100644 index f609090..0000000 --- a/src/gesture/gesture.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 -#include -#include -#include -#include -#include "motion_engine.h" -#include "gesture.h" - -using namespace ctx::gesture; - -static ctx::handle_map_t<_cx_gesture_h> handle_map; - -void cx_gesture_deliver_data(int req_id, _cx_gesture_data data, double timestamp, int error) -{ - _cx_gesture_h *handle = NULL; - - handle = handle_map.get_copy(req_id); - try_return_void_tag(handle, LOGD, "No matching handle found"); - - if (handle->callback) { - data.gesture = handle->gesture; - handle->callback(static_cast(data.gesture), &data, - timestamp, static_cast(error), handle->user_data); - } - - free(handle); -} - -EXTAPI int gesture_is_supported(gesture_type_e gesture, bool* supported) -{ - if (supported) - *supported = false; - - ASSERT_SUPPORTED(FEATURE_KEY_GESTURE); - ASSERT_NULL(supported); - - int ret = GESTURE_ERROR_NONE; - - if (motion_engine::check_coverage(gesture)) { - ret = motion_engine::is_supported(gesture); - *supported = (ret == GESTURE_ERROR_NONE); - } - - return ret; -} - -EXTAPI int gesture_create(gesture_h *handle) -{ - ASSERT_SUPPORTED(FEATURE_KEY_GESTURE); - ASSERT_HANDLE; - - *handle = static_cast(malloc(sizeof(_cx_gesture_h))); - ASSERT_ALLOC(*handle); - - (*handle)->req_id = CTX_VALUE_UNDEFINED; - (*handle)->gesture = CTX_VALUE_UNDEFINED; - (*handle)->callback = NULL; - (*handle)->user_data = NULL; - - (*handle)->me_handle = CTX_VALUE_UNDEFINED; - (*handle)->me_event = CTX_VALUE_UNDEFINED; - - return GESTURE_ERROR_NONE; -} - -EXTAPI int gesture_release(gesture_h handle) -{ - ASSERT_SUPPORTED(FEATURE_KEY_GESTURE); - ASSERT_HANDLE; - gesture_stop_recognition(handle); - free(handle); - return GESTURE_ERROR_NONE; -} - -EXTAPI int gesture_start_recognition(gesture_h handle, gesture_type_e gesture, gesture_option_e option, gesture_recognition_cb callback, void *user_data) -{ - ASSERT_SUPPORTED(FEATURE_KEY_GESTURE); - if (gesture == GESTURE_WRIST_UP) { - ASSERT_SUPPORTED(FEATURE_KEY_WRISTUP); - } - ASSERT_HANDLE; - ASSERT_NULL(callback); - - if (handle_map.find(handle->req_id) != NULL) { - LOGW("The handle is being used"); - return GESTURE_ERROR_ALREADY_STARTED; - } - - handle->gesture = gesture; - handle->user_data = user_data; - handle->callback = callback; - - int ret; - - if (motion_engine::check_coverage(gesture)) { - ret = motion_engine::start(handle, gesture, option); - } else { - ret = GESTURE_ERROR_INVALID_PARAMETER; - } - - if (ret == GESTURE_ERROR_NONE) - handle_map.insert(handle->req_id, handle); - - return ret; -} - -EXTAPI int gesture_stop_recognition(gesture_h handle) -{ - ASSERT_SUPPORTED(FEATURE_KEY_GESTURE); - ASSERT_HANDLE; - int ret = GESTURE_ERROR_NOT_STARTED; - - if (handle_map.find(handle->req_id) != NULL) { - if (motion_engine::check_coverage(handle->gesture)) - motion_engine::stop(handle); - - handle_map.remove(handle->req_id); - ret = GESTURE_ERROR_NONE; - } - - handle->req_id = CTX_VALUE_UNDEFINED; - handle->gesture = CTX_VALUE_UNDEFINED; - handle->callback = NULL; - handle->user_data = NULL; - - return ret; -} - -EXTAPI int gesture_get_event(const gesture_data_h data, gesture_event_e *event) -{ - ASSERT_SUPPORTED(FEATURE_KEY_GESTURE); - ASSERT_NULL(data); - ASSERT_NULL(event); - - if (data->gesture == GESTURE_TILT) - return GESTURE_ERROR_NOT_SUPPORTED; - - *event = static_cast(data->event); - - return GESTURE_ERROR_NONE; -} - -EXTAPI int gesture_get_tilt(const gesture_data_h data, int *x, int *y) -{ - ASSERT_SUPPORTED(FEATURE_KEY_GESTURE); - ASSERT_NULL(data); - ASSERT_NULL(x); - ASSERT_NULL(y); - - if (data->gesture != GESTURE_TILT) - return GESTURE_ERROR_NOT_SUPPORTED; - - *x = data->tilt_x; - *y = data->tilt_y; - - return GESTURE_ERROR_NONE; -} diff --git a/src/gesture/gesture.h b/src/gesture/gesture.h deleted file mode 100644 index d2dde88..0000000 --- a/src/gesture/gesture.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 _CONTEXT_GESTURE_H_ -#define _CONTEXT_GESTURE_H_ - -#include - -#define FEATURE_KEY_GESTURE "tizen.org/feature/sensor.gesture_recognition" -#define FEATURE_KEY_WRISTUP "tizen.org/feature/sensor.wrist_up" - -typedef struct _gesture_data_s { - int gesture; - int event; - int tilt_x; - int tilt_y; -} _cx_gesture_data; - -typedef struct _gesture_handle_s { - int req_id; - int gesture; - gesture_recognition_cb callback; - void *user_data; - - int me_handle; // Handle for motion-engine in sensor-fw - int me_event; // Event enum for motion-engine in sensor-fw - -} _cx_gesture_h; - -void cx_gesture_deliver_data(int req_id, _cx_gesture_data data, double timestamp, int error); - -#endif /* End of _CONTEXT_GESTURE_PRIVATE_H_ */ diff --git a/src/gesture/motion_engine.cpp b/src/gesture/motion_engine.cpp deleted file mode 100644 index 1c01997..0000000 --- a/src/gesture/motion_engine.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 -#include -#include -#include -#include "gesture.h" -#include "motion_engine.h" - -static int convert_shake_data(int value) -{ - switch (value) { - case MOTION_ENGIEN_SHAKE_NONE: - return GESTURE_EVENT_NONE; - - case MOTION_ENGIEN_SHAKE_DETECTION: - case MOTION_ENGIEN_SHAKE_CONTINUING: - return GESTURE_SHAKE_DETECTED; - - case MOTION_ENGIEN_SHAKE_FINISH: - case MOTION_ENGINE_SHAKE_BREAK: - return GESTURE_SHAKE_FINISHED; - - default: - return CTX_VALUE_UNDEFINED; - } -} - -static int convert_face_down_data(int value) -{ - switch (value) { - case MOTION_ENGIEN_TOP_TO_BOTTOM_NONE: - return GESTURE_EVENT_NONE; - - case MOTION_ENGIEN_TOP_TO_BOTTOM_DETECTION: - return GESTURE_EVENT_DETECTED; - - default: - return CTX_VALUE_UNDEFINED; - } -} - -static void me_sensor_event_extract_int(unsigned int event_type, sensor_data_t *event_data, _cx_gesture_data *gesture_data) -{ - gesture_data->event = event_data->values[0]; - - switch (event_type) { - case MOTION_ENGINE_EVENT_SHAKE: - case MOTION_ENGINE_EVENT_SHAKE_ALWAYS_ON: - gesture_data->event = convert_shake_data(gesture_data->event); - return; - - case MOTION_ENGINE_EVENT_TOP_TO_BOTTOM: - gesture_data->event = convert_face_down_data(gesture_data->event); - return; - - default: - return; - } -} - -static void me_sensor_event_extract_tilt(sensor_data_t *event_data, _cx_gesture_data *gesture_data) -{ - try_return_void_tag(event_data->value_count >= 2, LOGW, "Invalid data count (%d)", event_data->value_count); - gesture_data->tilt_x = event_data->values[0]; - gesture_data->tilt_y = event_data->values[1]; -} - -static bool me_sensor_extract_data(unsigned int event_type, sensor_data_t *event_data, _cx_gesture_data *gesture_data) -{ - if (event_type == MOTION_ENGINE_EVENT_TILT) { - me_sensor_event_extract_tilt(event_data, gesture_data); - - } else { - me_sensor_event_extract_int(event_type, event_data, gesture_data); - } - - return true; -} - -static void me_sensor_event_cb(sensor_t sensor, unsigned int sensor_event_type, sensor_data_t *sensor_event_data, void *user_data) -{ - try_return_void(user_data); - - int64_t ts = ctx::time::get_utc(NULL, NULL); - int req_id = *static_cast(user_data); - LOGD("Received data for ReqId %d", req_id); - - _cx_gesture_data data; - - if (!me_sensor_extract_data(sensor_event_type, sensor_event_data, &data)) { - LOGE("Failed to extract motion data from sensor event"); - return; - } - - cx_gesture_deliver_data(req_id, data, ts/1000.0L, GESTURE_ERROR_NONE); -} - -static int get_event_type(int motion) -{ - switch (motion) { - // Mobile Lite Profile - case GESTURE_SHAKE: - return MOTION_ENGINE_EVENT_SHAKE; - - // Mobile Full Profile - case GESTURE_DOUBLE_TAP: - return MOTION_ENGINE_EVENT_DOUBLETAP; - - case GESTURE_MOVE_TO_EAR: - return MOTION_ENGINE_EVENT_DIRECT_CALL; - - case GESTURE_NO_MOVE: - return MOTION_ENGINE_EVENT_NO_MOVE; - - case GESTURE_PICK_UP: - return MOTION_ENGINE_EVENT_SMART_RELAY; - - case GESTURE_SNAP: - return MOTION_ENGINE_EVENT_SNAP; - - case GESTURE_TILT: - return MOTION_ENGINE_EVENT_TILT; - - case GESTURE_TURN_FACE_DOWN: - return MOTION_ENGINE_EVENT_TOP_TO_BOTTOM; - - default: - return CTX_VALUE_UNDEFINED; - } -} - -static int get_me_option(int mode) -{ - if (mode == GESTURE_OPTION_DEFAULT) { - return SENSOR_OPTION_DEFAULT; - - } else if (mode == GESTURE_OPTION_ALWAYS_ON) { - return SENSOR_OPTION_ALWAYS_ON; - } - - return CTX_VALUE_UNDEFINED; -} - -bool ctx::gesture::motion_engine::check_coverage(int motion) -{ - switch (motion) { - case GESTURE_SHAKE: - case GESTURE_DOUBLE_TAP: - case GESTURE_MOVE_TO_EAR: - case GESTURE_NO_MOVE: - case GESTURE_PICK_UP: - case GESTURE_SNAP: - case GESTURE_TILT: - case GESTURE_TURN_FACE_DOWN: - return true; - - default: - return false; - } -} - -int ctx::gesture::motion_engine::is_supported(int motion) -{ - int handle = -1, res; - int ev_type = get_event_type(motion); - res = ctx::sensor::connect(&handle, MOTION_SENSOR, ev_type, SENSOR_OPTION_DEFAULT, me_sensor_event_cb, NULL); - ctx::sensor::disconnect(&handle, MOTION_SENSOR, ev_type); - - return res; -} - -int ctx::gesture::motion_engine::start(_cx_gesture_h *handle, int gesture, int option) -{ - int ev_type = get_event_type(gesture); - int me_opt = get_me_option(option); - - handle->req_id = ctx::generate_rid(); - - try_return_result(me_opt != CTX_VALUE_UNDEFINED, GESTURE_ERROR_INVALID_PARAMETER); - - int res = ctx::sensor::connect(&handle->me_handle, MOTION_SENSOR, ev_type, me_opt, me_sensor_event_cb, &(handle->req_id)); - try_return_result(!IS_FAILED(res), res); - - LOGI("Started MotionEngine Event %d (Gesture %d)", ev_type, gesture); - - handle->me_event = ev_type; - - return GESTURE_ERROR_NONE; -} - -int ctx::gesture::motion_engine::stop(_cx_gesture_h *handle) -{ - LOGI("Stopping MotionEngine Event %d", handle->me_event); - - ctx::sensor::disconnect(&handle->me_handle, MOTION_SENSOR, handle->me_event); - - handle->me_handle = CTX_VALUE_UNDEFINED; - handle->me_event = CTX_VALUE_UNDEFINED; - - return GESTURE_ERROR_NONE; -} diff --git a/src/gesture/motion_engine.h b/src/gesture/motion_engine.h deleted file mode 100644 index 36f3ec7..0000000 --- a/src/gesture/motion_engine.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 _CX_GESTURE_MOTION_ENGINE_H_ -#define _CX_GESTURE_MOTION_ENGINE_H_ - -#include -#include "gesture.h" - -namespace ctx { namespace gesture { namespace motion_engine { - - bool check_coverage(int gesture); - int is_supported(int gesture); - int start(_cx_gesture_h *handle, int gesture, int mode); - int stop(_cx_gesture_h *handle); - -} } } - -#endif /* End of _CX_GESTURE_MOTION_ENGINE_H_ */ diff --git a/src/shared/ctx_error.h b/src/shared/ctx_error.h deleted file mode 100644 index 4fca642..0000000 --- a/src/shared/ctx_error.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 __TIZEN_CONTEXT_ERROR_H__ -#define __TIZEN_CONTEXT_ERROR_H__ - -#include - -#define CERR_NONE TIZEN_ERROR_NONE /* Successful */ -#define CERR_INVALID_PARAMETER TIZEN_ERROR_INVALID_PARAMETER /* Invalid function parameter */ -#define CERR_INVALID_OPERATION TIZEN_ERROR_INVALID_OPERATION /* Function not implemented */ -#define CERR_OUT_OF_MEMORY TIZEN_ERROR_OUT_OF_MEMORY /* Out of memory */ -#define CERR_PERMISSION_DENIED TIZEN_ERROR_PERMISSION_DENIED /* Permission denied */ -#define CERR_NOT_SUPPORTED TIZEN_ERROR_NOT_SUPPORTED /* Not supported */ -#define CERR_ALREADY_STARTED (TIZEN_ERROR_CONTEXT | 0x01) /* Already started */ -#define CERR_NOT_STARTED (TIZEN_ERROR_CONTEXT | 0x02) /* Not started */ -#define CERR_OPERATION_FAILED (TIZEN_ERROR_CONTEXT | 0x04) /* Operation failed because of a system error */ - -#endif // __TIZEN_CONTEXT_ERROR_H__ diff --git a/src/shared/ctx_types_private.h b/src/shared/ctx_types_private.h deleted file mode 100644 index 570989c..0000000 --- a/src/shared/ctx_types_private.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 __CONTEXT_TYPES_PRIVATE_H__ -#define __CONTEXT_TYPES_PRIVATE_H__ - -#include -#include - -#define EXTAPI __attribute__ ((visibility("default"))) - -#define ASSERT_SUPPORTED(feature) \ - do { \ - int __result = ctx::is_supported(feature); \ - if (__result != CERR_NONE) return __result; \ - } while (0) - -#define try_return_result_tag(cond, ret, tag, fmt, arg...) \ - do { if (!(cond)) { tag(fmt, ##arg); return ret; } } while (0) - -#define try_return_void_tag(cond, tag, fmt, arg...) \ - do { if (!(cond)) { tag(fmt, ##arg); return; } } while (0) - -#define try_catch_tag(cond, tag, fmt, arg...) \ - do { if (!(cond)) { tag(fmt, ##arg); goto CATCH; } } while (0) - -#define try_return_result(cond, ret) \ - do { if (!(cond)) { return ret; } } while (0) - -#define try_return_void(cond) \ - do { if (!(cond)) { return; } } while (0) - -#define try_catch(cond) \ - do { if (!(cond)) { goto CATCH; } } while (0) - -#define assert_invalid_param(cond) \ - do { if (!(cond)) { return CERR_INVALID_PARAMETER; } } while (0) - -#define IS_FAILED(X) ((X) != CERR_NONE) - -#define CTX_VALUE_UNDEFINED -1 - -#define ASSERT_HANDLE try_return_result_tag(handle, CERR_INVALID_PARAMETER, LOGE, "handle cannot be null") -#define ASSERT_ALLOC(X) try_return_result_tag(X, CERR_OPERATION_FAILED, LOGE, "Memory allocation failed") -#define ASSERT_NULL(X) try_return_result_tag(X, CERR_INVALID_PARAMETER, LOGE, "Parameter null") - -#endif /* __CONTEXT_TYPES_PRIVATE_H__ */ diff --git a/src/shared/ctx_util_misc.cpp b/src/shared/ctx_util_misc.cpp deleted file mode 100644 index affa491..0000000 --- a/src/shared/ctx_util_misc.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 -#include -#include -#include -#include -#include -#include -#include "ctx_error.h" -#include "ctx_util_misc.h" - -int ctx::generate_rid() -{ - static GMutex rid_mutex; - static int rid = 0; - int ret = 0; - - g_mutex_lock(&rid_mutex); - - if (++rid < 0) - rid = 1; - - ret = rid; - - g_mutex_unlock(&rid_mutex); - - return ret; -} - -int ctx::is_supported(const char* feature) -{ - bool supported = false; - int ret = system_info_get_platform_bool(feature, &supported); - - if (ret == CERR_NONE && !supported) { - SLOGD("Not Supported: %s", feature); - return CERR_NOT_SUPPORTED; - } else if (ret != CERR_NONE) { - SLOGE("Getting system info failed: %#x", ret); - return CERR_OPERATION_FAILED; - } - - return CERR_NONE; -} - -int64_t ctx::time::get_utc(int64_t* ymd, int64_t* hms) -{ - struct timeval now; - struct tm tm_now; - int64_t timestamp; - int64_t hms_now; - - gettimeofday(&now, NULL); - timestamp = now.tv_sec * 1000LL + now.tv_usec / 1000; - - if (ymd || hms) { - time_t now_sec = now.tv_sec; - gmtime_r(&now_sec, &tm_now); - hms_now = ((tm_now.tm_hour * 60 + tm_now.tm_min) * 60 + tm_now.tm_sec) * 1000LL + now.tv_usec / 1000; - - if (hms) - *hms = hms_now; - - if (ymd) - *ymd = timestamp - hms_now; - } - - return timestamp; -} diff --git a/src/shared/ctx_util_misc.h b/src/shared/ctx_util_misc.h deleted file mode 100644 index e15d207..0000000 --- a/src/shared/ctx_util_misc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 __CONTEXT_UTIL_MISC_H__ -#define __CONTEXT_UTIL_MISC_H__ - -#include - -namespace ctx { - - int generate_rid(void); - int is_supported(const char* feature); - - namespace time { - - int64_t get_utc(int64_t* ymd, int64_t* hms); - - } /* namespace ctx::util */ - -} /* namespace ctx */ - -#endif /* __CONTEXT_UTIL_MISC_H__ */ diff --git a/src/shared/ctx_util_sensor.cpp b/src/shared/ctx_util_sensor.cpp deleted file mode 100644 index 4077fbb..0000000 --- a/src/shared/ctx_util_sensor.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 -#include "ctx_types_private.h" -#include "ctx_util_sensor.h" - -#define NUM_CONNECT_TRIAL 2 - -int ctx::sensor::connect(int *handle, sensor_type_t sensor, unsigned int event, int option, sensor_cb_t cb, void *user_data) -{ - sensor_t sen = sensord_get_sensor(sensor); - - for (int i=0; i < NUM_CONNECT_TRIAL && *handle < 0; ++i) { - LOGD("Trial #%d to connect to Sensor %d", i+1, sensor); - *handle = sensord_connect(sen); - } - - try_return_result_tag(*handle>=0, CERR_NOT_SUPPORTED, SLOGE, "Failed to connect Sensor %d", sensor); - - bool supported = false; - try_return_result_tag(sensord_is_supported_event_type(sen, event, &supported), CERR_OPERATION_FAILED, SLOGE, "sensord_is_supported_event_type() failed"); - try_return_result_tag(supported, CERR_NOT_SUPPORTED, SLOGD, "Sensor Event %d is not supported.", event); - - if (!sensord_register_event(*handle, event, 0, 0, cb, user_data)) { - LOGE("Failed to register Sensor Event %d", event); - sensord_disconnect(*handle); - *handle = -1; - return CERR_NOT_SUPPORTED; - } - - if (!sensord_start(*handle, option)) { - LOGE("Failed to start Sensor %d", sensor); - sensord_unregister_event(*handle, event); - sensord_disconnect(*handle); - *handle = -1; - return CERR_OPERATION_FAILED; - } - - LOGI("Sensor %d (Event %#x) started (Option: %d)", sensor, event, option); - return CERR_NONE; -} - -void ctx::sensor::disconnect(int *handle, sensor_type_t sensor, unsigned int event) -{ - try_return_void(*handle >= 0); - - sensord_unregister_event(*handle, event); - sensord_stop(*handle); - sensord_disconnect(*handle); - - *handle = -1; - - LOGI("Sensor %d (Event %#x) stopped", sensor, event); -} diff --git a/src/shared/handle_map.h b/src/shared/handle_map.h deleted file mode 100644 index 75d9b2b..0000000 --- a/src/shared/handle_map.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * motion - * - * Copyright (c) 2014 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 _CONTEXT_HANDLE_LIST_H_ -#define _CONTEXT_HANDLE_LIST_H_ - -#include -#include -#include "ctx_types_private.h" - -namespace ctx { - -template -class handle_map_t -{ -private: - std::map _map; - GMutex _mutex; - -public: - handle_map_t() {} - ~handle_map_t() {} - - void insert(int rid, _handle_t *h); - void remove(int rid); - - _handle_t* find(int rid); - _handle_t* get_copy(int rid); - -}; /* class handle_map_t */ - -} /* namesapce ctx */ - -template -void ctx::handle_map_t<_handle_t>::insert(int rid, _handle_t *h) -{ - g_mutex_lock(&_mutex); - - _map[rid] = h; - - g_mutex_unlock(&_mutex); -} - -template -void ctx::handle_map_t<_handle_t>::remove(int rid) -{ - g_mutex_lock(&_mutex); - - _map.erase(rid); - - g_mutex_unlock(&_mutex); -} - -template -_handle_t* ctx::handle_map_t<_handle_t>::find(int rid) -{ - _handle_t *h = NULL; - - g_mutex_lock(&_mutex); - - typename std::map::iterator it = _map.find(rid); - if (it != _map.end()) - h = it->second; - - g_mutex_unlock(&_mutex); - - return h; -} - -template -_handle_t* ctx::handle_map_t<_handle_t>::get_copy(int rid) -{ - _handle_t *copy = static_cast<_handle_t*>(malloc(sizeof(_handle_t))); - try_return_result_tag(copy, NULL, LOGE, "Memory allocation failed"); - - g_mutex_lock(&_mutex); - - typename std::map::iterator it = _map.find(rid); - if (it != _map.end()) { - *copy = *(it->second); - } else { - free(copy); - copy = NULL; - } - - g_mutex_unlock(&_mutex); - - return copy; -} - -#endif /* _CONTEXT_HANDLE_LIST_H_ */ -- 2.34.1 From e750923d50ca404ae421bf447a529bc68738a500 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Fri, 8 Apr 2016 16:00:40 +0900 Subject: [PATCH 07/16] Versio 1.2.0 Change-Id: I08e1d14a67a78eb58ab99215d90570b04f8ea7d0 Signed-off-by: Mu-Woong Lee --- packaging/motion.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/motion.spec b/packaging/motion.spec index 694b22e..74986ca 100644 --- a/packaging/motion.spec +++ b/packaging/motion.spec @@ -1,6 +1,6 @@ Name: motion Summary: Tizen Native Motion Recognition API -Version: 1.1.4 +Version: 1.2.0 Release: 1 Group: Service/Context License: Apache-2.0 -- 2.34.1 From 174fbf1caea0a90fe7cee5bfe846b8ee29f44413 Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Wed, 27 Jul 2016 17:43:39 +0900 Subject: [PATCH 08/16] Fix error return logic since refactoring Change-Id: I97c1395a4f531ba113ade58304bd52ee12be7153 Signed-off-by: Somin Kim --- packaging/motion.spec | 2 +- src/Activity.cpp | 2 +- src/Gesture.cpp | 10 +++++----- src/SensorProxy.cpp | 10 +++++++--- src/SensorProxy.h | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packaging/motion.spec b/packaging/motion.spec index 74986ca..0dc8083 100644 --- a/packaging/motion.spec +++ b/packaging/motion.spec @@ -1,6 +1,6 @@ Name: motion Summary: Tizen Native Motion Recognition API -Version: 1.2.0 +Version: 1.2.1 Release: 1 Group: Service/Context License: Apache-2.0 diff --git a/src/Activity.cpp b/src/Activity.cpp index 46e29a0..9f744d3 100644 --- a/src/Activity.cpp +++ b/src/Activity.cpp @@ -100,7 +100,7 @@ EXTAPI int activity_stop_recognition(activity_h handle) ASSERT_SUPPORTED(FEATURE_ACTIVITY); ASSERT_NOT_NULL(handle); - handle->proxy->stop(); + IF_FAIL_RETURN(handle->proxy->stop(), ACTIVITY_ERROR_NOT_STARTED); return ERR_NONE; } diff --git a/src/Gesture.cpp b/src/Gesture.cpp index f09d17a..f699ec6 100644 --- a/src/Gesture.cpp +++ b/src/Gesture.cpp @@ -80,10 +80,6 @@ EXTAPI int gesture_start_recognition(gesture_h handle, gesture_type_e gesture, g ASSERT_NOT_NULL(callback); IF_FAIL_RETURN(IS_VALID_GESTURE(gesture), ERR_INVALID_PARAMETER); - if (!handle->proxy->setGesture(gesture)) { - return ERR_INVALID_PARAMETER; - } - if (option == GESTURE_OPTION_DEFAULT) { handle->proxy->setPowerSave(true); } else if (option == GESTURE_OPTION_ALWAYS_ON) { @@ -92,6 +88,10 @@ EXTAPI int gesture_start_recognition(gesture_h handle, gesture_type_e gesture, g return ERR_INVALID_PARAMETER; } + if (!handle->proxy->setGesture(gesture)) { + return GESTURE_ERROR_NOT_SUPPORTED; + } + handle->proxy->setCb(callback); handle->proxy->setUserData(user_data); @@ -107,7 +107,7 @@ EXTAPI int gesture_stop_recognition(gesture_h handle) ASSERT_SUPPORTED(FEATURE_GESTURE); ASSERT_NOT_NULL(handle); - handle->proxy->stop(); + IF_FAIL_RETURN(handle->proxy->stop(), GESTURE_ERROR_NOT_STARTED); return ERR_NONE; } diff --git a/src/SensorProxy.cpp b/src/SensorProxy.cpp index 551c8f7..a120048 100644 --- a/src/SensorProxy.cpp +++ b/src/SensorProxy.cpp @@ -34,7 +34,7 @@ SensorProxy::SensorProxy() SensorProxy::~SensorProxy() { - stop(); + stop(true); } void SensorProxy::setSensor(sensor_type_t type) @@ -78,14 +78,18 @@ bool SensorProxy::start() return true; } -void SensorProxy::stop() +bool SensorProxy::stop(bool force) { - IF_FAIL_VOID(sensorHandle >= 0); + if (!force) { + IF_FAIL_RETURN(sensorHandle >= 0, false); + } sensord_stop(sensorHandle); sensord_unregister_event(sensorHandle, SENSOR_EVENT(sensorType)); sensord_disconnect(sensorHandle); sensorHandle = -1; + + return true; } double SensorProxy::getTime(unsigned long long monotonic) diff --git a/src/SensorProxy.h b/src/SensorProxy.h index 0f0d01e..9f74cb5 100644 --- a/src/SensorProxy.h +++ b/src/SensorProxy.h @@ -32,7 +32,7 @@ namespace motion { void setPowerSave(bool ps); void setUserData(void *data); - void stop(); + bool stop(bool force = false); virtual bool start(); -- 2.34.1 From c7a8b59fade444624872a5674ad7a4b3718c0abc Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 9 Aug 2016 13:30:44 +0900 Subject: [PATCH 09/16] Refactor to use a single listener instance for all activities Change-Id: If6543085a902afe619469024c2d6d6e9498a326e Signed-off-by: Mu-Woong Lee --- src/Activity.cpp | 23 ++-- src/ActivityProxy.cpp | 71 ---------- src/ActivitySensor.cpp | 142 ++++++++++++++++++++ src/{ActivityProxy.h => ActivitySensor.h} | 28 ++-- src/Gesture.cpp | 26 ++-- src/{GestureProxy.cpp => GestureSensor.cpp} | 51 ++++--- src/{GestureProxy.h => GestureSensor.h} | 33 +++-- src/ISensorListener.h | 31 +++++ src/SensorAdapter.cpp | 133 ++++++++++++++++++ src/{SensorProxy.h => SensorAdapter.h} | 40 +++--- src/SensorProxy.cpp | 120 ----------------- 11 files changed, 421 insertions(+), 277 deletions(-) delete mode 100644 src/ActivityProxy.cpp create mode 100644 src/ActivitySensor.cpp rename src/{ActivityProxy.h => ActivitySensor.h} (64%) rename src/{GestureProxy.cpp => GestureSensor.cpp} (55%) rename src/{GestureProxy.h => GestureSensor.h} (67%) create mode 100644 src/ISensorListener.h create mode 100644 src/SensorAdapter.cpp rename src/{SensorProxy.h => SensorAdapter.h} (64%) delete mode 100644 src/SensorProxy.cpp diff --git a/src/Activity.cpp b/src/Activity.cpp index 9f744d3..a7cf667 100644 --- a/src/Activity.cpp +++ b/src/Activity.cpp @@ -16,7 +16,7 @@ */ #include -#include "ActivityProxy.h" +#include "ActivitySensor.h" #define FEATURE_ACTIVITY "tizen.org/feature/sensor.activity_recognition" @@ -27,7 +27,7 @@ using namespace motion; struct _activity_handle_s { - ActivityProxy *proxy; + ActivitySensor *sensor; }; EXTAPI int activity_is_supported(activity_type_e activity, bool* supported) @@ -39,7 +39,7 @@ EXTAPI int activity_is_supported(activity_type_e activity, bool* supported) ASSERT_NOT_NULL(supported); IF_FAIL_RETURN(IS_VALID_ACTIVITY(activity), ERR_INVALID_PARAMETER); - *supported = ActivityProxy::isSupported(activity); + *supported = ActivitySensor::isSupported(activity); return ERR_NONE; } @@ -51,8 +51,8 @@ EXTAPI int activity_create(activity_h *handle) _activity_handle_s *hdl = static_cast(malloc(sizeof(_activity_handle_s))); IF_FAIL_RETURN_TAG(hdl, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); - hdl->proxy = new(std::nothrow) ActivityProxy(); - if (hdl->proxy == NULL) { + hdl->sensor = new(std::nothrow) ActivitySensor(); + if (hdl->sensor == NULL) { _E("Memory allocation failed"); free(hdl); return ERR_OPERATION_FAILED; @@ -67,7 +67,7 @@ EXTAPI int activity_release(activity_h handle) ASSERT_SUPPORTED(FEATURE_ACTIVITY); ASSERT_NOT_NULL(handle); - delete handle->proxy; + delete handle->sensor; free(handle); return ERR_NONE; @@ -80,15 +80,14 @@ EXTAPI int activity_start_recognition(activity_h handle, activity_type_e activit ASSERT_NOT_NULL(callback); IF_FAIL_RETURN(IS_VALID_ACTIVITY(activity), ERR_INVALID_PARAMETER); - if (!handle->proxy->setActivity(activity)) { + if (!handle->sensor->setActivity(activity)) { return ERR_INVALID_PARAMETER; } - handle->proxy->setPowerSave(false); - handle->proxy->setCb(callback); - handle->proxy->setUserData(user_data); + handle->sensor->setCallback(callback); + handle->sensor->setUserData(user_data); - if (!handle->proxy->start()) { + if (!handle->sensor->start()) { return ERR_OPERATION_FAILED; } @@ -100,7 +99,7 @@ EXTAPI int activity_stop_recognition(activity_h handle) ASSERT_SUPPORTED(FEATURE_ACTIVITY); ASSERT_NOT_NULL(handle); - IF_FAIL_RETURN(handle->proxy->stop(), ACTIVITY_ERROR_NOT_STARTED); + IF_FAIL_RETURN(handle->sensor->stop(), ACTIVITY_ERROR_NOT_STARTED); return ERR_NONE; } diff --git a/src/ActivityProxy.cpp b/src/ActivityProxy.cpp deleted file mode 100644 index fa8275d..0000000 --- a/src/ActivityProxy.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2016 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 -#include "ActivityProxy.h" - -#define ACTIVITY_BIT(X) (0x1 << (int)(X)) -#define ACTIVITY_ENUM(X) ((int)log2f((X))) - -using namespace motion; - -ActivityProxy::ActivityProxy() - : __activityType(static_cast(UNDEFINED)) - , __callback(NULL) -{ -} - -ActivityProxy::~ActivityProxy() -{ -} - -bool ActivityProxy::setActivity(activity_type_e type) -{ - __activityType = type; - setSensor(ACTIVITY_TRACKER_SENSOR); - return true; -} - -void ActivityProxy::setCb(activity_recognition_cb cb) -{ - __callback = cb; -} - -bool ActivityProxy::start() -{ - IF_FAIL_RETURN(SensorProxy::start(), false); - sensord_set_attribute_int(sensorHandle, SENSOR_ATTR_ACTIVITY, ACTIVITY_BIT(__activityType)); - return true; -} - -bool ActivityProxy::isSupported(activity_type_e type) -{ - return SensorProxy::isSupported(ACTIVITY_TRACKER_SENSOR); -} - -void ActivityProxy::onEvent(sensor_data_t *eventData) -{ - _activity_data_s data; - - IF_FAIL_VOID(ACTIVITY_ENUM(eventData->values[0]) == static_cast(__activityType)); - - data.activity = __activityType; - data.accuracy = eventData->accuracy; - - __callback(__activityType, &data, getTime(eventData->timestamp), - static_cast(ERR_NONE), userData); -} diff --git a/src/ActivitySensor.cpp b/src/ActivitySensor.cpp new file mode 100644 index 0000000..d275d5d --- /dev/null +++ b/src/ActivitySensor.cpp @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2016 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 +#include "ActivitySensor.h" + +#define ACTIVITY_BIT(X) (0x1 << (int)(X)) +#define ACTIVITY_ENUM(X) ((int)log2f((X))) + +using namespace motion; + +class ActivityListener : public ISensorListener { +public: + ActivityListener() + { + } + + ~ActivityListener() + { + } + + void onEvent(double timestamp, float* values, int accuracy) + { + ActivitySensor::onEvent(timestamp, values, accuracy); + } +}; + +static ActivityListener __activityListener; + +std::set ActivitySensor::__sensorSet; +SensorAdapter ActivitySensor::__sensorAdapter(&__activityListener); + +ActivitySensor::ActivitySensor() : + __activityType(static_cast(UNDEFINED)), + __callback(NULL), + __userData(NULL), + __started(false) +{ + __sensorAdapter.setSensor(ACTIVITY_TRACKER_SENSOR); + __sensorAdapter.setPowerSave(false); + __sensorSet.insert(this); +} + +ActivitySensor::~ActivitySensor() +{ + stop(); + __sensorSet.erase(this); +} + +bool ActivitySensor::setActivity(activity_type_e type) +{ + __activityType = type; + return true; +} + +void ActivitySensor::setCallback(activity_recognition_cb cb) +{ + __callback = cb; +} + +void ActivitySensor::setUserData(void* data) +{ + __userData = data; +} + +bool ActivitySensor::start() +{ + bool started = false; + int activityFilter = 0; + + for (std::set::iterator iter = __sensorSet.begin(); iter != __sensorSet.end(); ++iter) { + started = started | (*iter)->__started; + if ((*iter)->__started || (*iter) == this) + activityFilter |= ACTIVITY_BIT((*iter)->__activityType); + } + + if (!started) + IF_FAIL_RETURN(__sensorAdapter.start(), false); + + __sensorAdapter.setAttribute(SENSOR_ATTR_ACTIVITY, activityFilter); + + __started = true; + return true; +} + +bool ActivitySensor::stop() +{ + IF_FAIL_RETURN(__started, false); + + bool started = false; + int activityFilter = 0; + + __started = false; + + for (std::set::iterator iter = __sensorSet.begin(); iter != __sensorSet.end(); ++iter) { + started = started | (*iter)->__started; + if ((*iter)->__started) + activityFilter |= ACTIVITY_BIT((*iter)->__activityType); + } + + if (started) + __sensorAdapter.setAttribute(SENSOR_ATTR_ACTIVITY, activityFilter); + else + __sensorAdapter.stop(); + + return true; +} + +bool ActivitySensor::isSupported(activity_type_e type) +{ + return SensorAdapter::isSupported(ACTIVITY_TRACKER_SENSOR); +} + +void ActivitySensor::onEvent(double timestamp, float* values, int accuracy) +{ + _activity_data_s data; + data.activity = ACTIVITY_ENUM(values[0]); + data.accuracy = accuracy; + + for (std::set::iterator iter = __sensorSet.begin(); iter != __sensorSet.end(); ++iter) { + if (!(*iter)->__started) + continue; + if (static_cast((*iter)->__activityType) == data.activity && (*iter)->__callback) { + activity_recognition_cb cb = (*iter)->__callback; + cb((*iter)->__activityType, &data, timestamp, ACTIVITY_ERROR_NONE, (*iter)->__userData); + } + } +} diff --git a/src/ActivityProxy.h b/src/ActivitySensor.h similarity index 64% rename from src/ActivityProxy.h rename to src/ActivitySensor.h index 402bd27..44f1ec6 100644 --- a/src/ActivityProxy.h +++ b/src/ActivitySensor.h @@ -15,11 +15,12 @@ * */ -#ifndef _MOTION_ACTIVITY_PROXY_H_ -#define _MOTION_ACTIVITY_PROXY_H_ +#ifndef __MOTION_ACTIVITY_SENSOR_H__ +#define __MOTION_ACTIVITY_SENSOR_H__ +#include #include -#include "SensorProxy.h" +#include "SensorAdapter.h" struct _activity_data_s { int activity; @@ -28,26 +29,31 @@ struct _activity_data_s { namespace motion { - class ActivityProxy : public SensorProxy { + class ActivitySensor { public: - ActivityProxy(); - ~ActivityProxy(); + ActivitySensor(); + ~ActivitySensor(); bool setActivity(activity_type_e type); - void setCb(activity_recognition_cb cb); + void setCallback(activity_recognition_cb cb); + void setUserData(void* data); bool start(); + bool stop(); static bool isSupported(activity_type_e type); - - protected: - void onEvent(sensor_data_t *eventData); + static void onEvent(double timestamp, float* values, int accuracy); private: activity_type_e __activityType; activity_recognition_cb __callback; + void *__userData; + bool __started; + + static std::set __sensorSet; + static SensorAdapter __sensorAdapter; }; } -#endif /* _MOTION_ACTIVITY_PROXY_PRIVATE_H_ */ +#endif /* __MOTION_ACTIVITY_PROXY_PRIVATE_H__ */ diff --git a/src/Gesture.cpp b/src/Gesture.cpp index f699ec6..bdb4306 100644 --- a/src/Gesture.cpp +++ b/src/Gesture.cpp @@ -16,7 +16,7 @@ */ #include -#include "GestureProxy.h" +#include "GestureSensor.h" #define FEATURE_GESTURE "tizen.org/feature/sensor.gesture_recognition" @@ -27,7 +27,7 @@ using namespace motion; struct _gesture_handle_s { - GestureProxy *proxy; + GestureSensor *sensor; }; EXTAPI int gesture_is_supported(gesture_type_e gesture, bool* supported) @@ -39,7 +39,7 @@ EXTAPI int gesture_is_supported(gesture_type_e gesture, bool* supported) ASSERT_NOT_NULL(supported); IF_FAIL_RETURN(IS_VALID_GESTURE(gesture), ERR_INVALID_PARAMETER); - *supported = GestureProxy::isSupported(gesture); + *supported = GestureSensor::isSupported(gesture); return ERR_NONE; } @@ -51,8 +51,8 @@ EXTAPI int gesture_create(gesture_h *handle) _gesture_handle_s *hdl = static_cast(malloc(sizeof(_gesture_handle_s))); IF_FAIL_RETURN_TAG(hdl, ERR_OPERATION_FAILED, _E, "Memory allocation failed"); - hdl->proxy = new(std::nothrow) GestureProxy(); - if (hdl->proxy == NULL) { + hdl->sensor = new(std::nothrow) GestureSensor(); + if (hdl->sensor == NULL) { _E("Memory allocation failed"); free(hdl); return ERR_OPERATION_FAILED; @@ -67,7 +67,7 @@ EXTAPI int gesture_release(gesture_h handle) ASSERT_SUPPORTED(FEATURE_GESTURE); ASSERT_NOT_NULL(handle); - delete handle->proxy; + delete handle->sensor; free(handle); return ERR_NONE; @@ -81,21 +81,21 @@ EXTAPI int gesture_start_recognition(gesture_h handle, gesture_type_e gesture, g IF_FAIL_RETURN(IS_VALID_GESTURE(gesture), ERR_INVALID_PARAMETER); if (option == GESTURE_OPTION_DEFAULT) { - handle->proxy->setPowerSave(true); + handle->sensor->setPowerSave(true); } else if (option == GESTURE_OPTION_ALWAYS_ON) { - handle->proxy->setPowerSave(false); + handle->sensor->setPowerSave(false); } else { return ERR_INVALID_PARAMETER; } - if (!handle->proxy->setGesture(gesture)) { + if (!handle->sensor->setGesture(gesture)) { return GESTURE_ERROR_NOT_SUPPORTED; } - handle->proxy->setCb(callback); - handle->proxy->setUserData(user_data); + handle->sensor->setCallback(callback); + handle->sensor->setUserData(user_data); - if (!handle->proxy->start()) { + if (!handle->sensor->start()) { return ERR_OPERATION_FAILED; } @@ -107,7 +107,7 @@ EXTAPI int gesture_stop_recognition(gesture_h handle) ASSERT_SUPPORTED(FEATURE_GESTURE); ASSERT_NOT_NULL(handle); - IF_FAIL_RETURN(handle->proxy->stop(), GESTURE_ERROR_NOT_STARTED); + IF_FAIL_RETURN(handle->sensor->stop(), GESTURE_ERROR_NOT_STARTED); return ERR_NONE; } diff --git a/src/GestureProxy.cpp b/src/GestureSensor.cpp similarity index 55% rename from src/GestureProxy.cpp rename to src/GestureSensor.cpp index 474e968..306b059 100644 --- a/src/GestureProxy.cpp +++ b/src/GestureSensor.cpp @@ -15,57 +15,78 @@ * */ -#include "GestureProxy.h" +#include "GestureSensor.h" using namespace motion; -GestureProxy::GestureProxy() - : __gestureType(static_cast(UNDEFINED)) - , __callback(NULL) +GestureSensor::GestureSensor() : + __gestureType(static_cast(UNDEFINED)), + __callback(NULL), + __userData(NULL), + __sensorAdapter(this) { } -GestureProxy::~GestureProxy() +GestureSensor::~GestureSensor() { } -bool GestureProxy::setGesture(gesture_type_e type) +bool GestureSensor::setGesture(gesture_type_e type) { sensor_type_t sensor = __toSensor(type); IF_FAIL_RETURN(sensor != UNKNOWN_SENSOR, false); __gestureType = type; - setSensor(sensor); + __sensorAdapter.setSensor(sensor); return true; } -void GestureProxy::setCb(gesture_recognition_cb cb) +void GestureSensor::setPowerSave(bool ps) +{ + __sensorAdapter.setPowerSave(ps); +} + +void GestureSensor::setCallback(gesture_recognition_cb cb) { __callback = cb; } -bool GestureProxy::isSupported(gesture_type_e type) +void GestureSensor::setUserData(void* data) +{ + __userData = data; +} + +bool GestureSensor::start() +{ + return __sensorAdapter.start(); +} + +bool GestureSensor::stop() +{ + return __sensorAdapter.stop(); +} + +bool GestureSensor::isSupported(gesture_type_e type) { sensor_type_t sensor = __toSensor(type); IF_FAIL_RETURN(sensor != UNKNOWN_SENSOR, false); - return SensorProxy::isSupported(sensor); + return SensorAdapter::isSupported(sensor); } -void GestureProxy::onEvent(sensor_data_t *eventData) +void GestureSensor::onEvent(double timestamp, float* values, int accuracy) { _gesture_data_s data; data.gesture = __gestureType; /* TODO: This is the default form. For each sensor, this part needs to adapt accordingly */ - data.event = static_cast(eventData->values[0]); + data.event = static_cast(values[0]); - __callback(__gestureType, &data, getTime(eventData->timestamp), - static_cast(ERR_NONE), userData); + __callback(__gestureType, &data, timestamp, static_cast(ERR_NONE), __userData); } -sensor_type_t GestureProxy::__toSensor(gesture_type_e type) +sensor_type_t GestureSensor::__toSensor(gesture_type_e type) { switch (type) { case GESTURE_PICK_UP: diff --git a/src/GestureProxy.h b/src/GestureSensor.h similarity index 67% rename from src/GestureProxy.h rename to src/GestureSensor.h index 9f1951e..2170575 100644 --- a/src/GestureProxy.h +++ b/src/GestureSensor.h @@ -15,11 +15,11 @@ * */ -#ifndef _MOTION_GESTURE_PROXY_H_ -#define _MOTION_GESTURE_PROXY_H_ +#ifndef __MOTION_GESTURE_SENSOR_H__ +#define __MOTION_GESTURE_SENSOR_H__ #include -#include "SensorProxy.h" +#include "SensorAdapter.h" struct _gesture_data_s { int gesture; @@ -30,27 +30,32 @@ struct _gesture_data_s { namespace motion { - class GestureProxy : public SensorProxy { + class GestureSensor : public ISensorListener { public: - GestureProxy(); - ~GestureProxy(); + GestureSensor(); + ~GestureSensor(); bool setGesture(gesture_type_e type); - void setCb(gesture_recognition_cb cb); + void setPowerSave(bool ps); + void setCallback(gesture_recognition_cb cb); + void setUserData(void* data); - static bool isSupported(gesture_type_e type); + bool start(); + bool stop(); - protected: - void onEvent(sensor_data_t *eventData); + static bool isSupported(gesture_type_e type); private: - gesture_type_e __gestureType; - gesture_recognition_cb __callback; + void onEvent(double timestamp, float* values, int accuracy); static sensor_type_t __toSensor(gesture_type_e type); + + gesture_type_e __gestureType; + gesture_recognition_cb __callback; + void *__userData; + SensorAdapter __sensorAdapter; }; } -#endif /* _MOTION_GESTURE_PROXY_H_ */ - +#endif /* __MOTION_GESTURE_SENSOR_H__ */ diff --git a/src/ISensorListener.h b/src/ISensorListener.h new file mode 100644 index 0000000..b6d657e --- /dev/null +++ b/src/ISensorListener.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 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 __MOTION_I_SENSOR_LISTENER_H__ +#define __MOTION_I_SENSOR_LISTENER_H__ + +namespace motion { + + class ISensorListener { + public: + virtual ~ISensorListener() {} + virtual void onEvent(double timestamp, float* values, int accuracy) = 0; + }; + +} + +#endif /* __MOTION_I_SENSOR_LISTENER_H__ */ diff --git a/src/SensorAdapter.cpp b/src/SensorAdapter.cpp new file mode 100644 index 0000000..90cc77b --- /dev/null +++ b/src/SensorAdapter.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2016 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 +#include +#include "SensorAdapter.h" + +#define SENSOR_EVENT(X) (((int)(X) << 16) | 0x01) + +using namespace motion; + +SensorAdapter::SensorAdapter(ISensorListener* listener) : + __sensorHandle(-1), + __sensorType(UNKNOWN_SENSOR), + __powerSave(true), + __listener(listener) +{ +} + +SensorAdapter::~SensorAdapter() +{ + stop(); +} + +void SensorAdapter::setSensor(sensor_type_t type) +{ + __sensorType = type; +} + +void SensorAdapter::setPowerSave(bool ps) +{ + __powerSave = ps; + + if (__sensorHandle < 0) + return; + + sensord_set_attribute_int(__sensorHandle, SENSORD_ATTRIBUTE_PAUSE_POLICY, + __powerSave ? SENSORD_PAUSE_ALL : SENSORD_PAUSE_NONE); +} + +void SensorAdapter::setAttribute(int key, int value) +{ + IF_FAIL_VOID_TAG(__sensorHandle >= 0, _W, "Sensor not started"); + sensord_set_attribute_int(__sensorHandle, key, value); +} + +bool SensorAdapter::start() +{ + int err; + sensor_t sensor; + + err = sensord_get_default_sensor(__sensorType, &sensor); + IF_FAIL_RETURN_TAG(err == 0, false, _E, "Getting sensor failed (%d)", err); + + __sensorHandle = sensord_connect(sensor); + IF_FAIL_RETURN_TAG(__sensorHandle >= 0, false, _E, "Connection failed"); + + if (!sensord_register_event(__sensorHandle, SENSOR_EVENT(__sensorType), 0, 0, __eventCb, this)) { + _E("Event registration failed"); + sensord_disconnect(__sensorHandle); + __sensorHandle = -1; + return false; + } + + if (!sensord_start(__sensorHandle, __powerSave ? SENSOR_OPTION_DEFAULT : SENSOR_OPTION_ALWAYS_ON)) { + _E("Starting failed"); + sensord_unregister_event(__sensorHandle, SENSOR_EVENT(__sensorType)); + sensord_disconnect(__sensorHandle); + __sensorHandle = -1; + return false; + } + + return true; +} + +bool SensorAdapter::stop() +{ + IF_FAIL_RETURN(__sensorHandle >= 0, false); + + sensord_stop(__sensorHandle); + sensord_unregister_event(__sensorHandle, SENSOR_EVENT(__sensorType)); + sensord_disconnect(__sensorHandle); + __sensorHandle = -1; + + return true; +} + +bool SensorAdapter::isSupported(sensor_type_t type) +{ + sensor_t sensor = sensord_get_sensor(type); + return (sensor != NULL); +} + +double SensorAdapter::__getEpoch(unsigned long long monotonic) +{ + struct timespec ts; + struct timeval tv; + double timeDiff; + double timestamp; + + clock_gettime(CLOCK_MONOTONIC, &ts); + timeDiff = (ts.tv_sec * 1000000000.0 + ts.tv_nsec) / 1000000.0 - monotonic / 1000.0; + + gettimeofday(&tv, NULL); + timestamp = tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0 - timeDiff; + return timestamp; +} + +void SensorAdapter::__onEvent(sensor_data_t *eventData) +{ + double timestamp = __getEpoch(eventData->timestamp); + __listener->onEvent(timestamp, eventData->values, eventData->accuracy); +} + +void SensorAdapter::__eventCb(sensor_t sensor, unsigned int eventType, sensor_data_t *eventData, void *cbData) +{ + SensorAdapter *instance = static_cast(cbData); + instance->__onEvent(eventData); +} diff --git a/src/SensorProxy.h b/src/SensorAdapter.h similarity index 64% rename from src/SensorProxy.h rename to src/SensorAdapter.h index 9f74cb5..66ac04d 100644 --- a/src/SensorProxy.h +++ b/src/SensorAdapter.h @@ -15,44 +15,42 @@ * */ -#ifndef _MOTION_SENSOR_PROXY_H_ -#define _MOTION_SENSOR_PROXY_H_ +#ifndef __MOTION_SENSOR_ADAPTER_H__ +#define __MOTION_SENSOR_ADAPTER_H__ #include #include "TypesInternal.h" +#include "ISensorListener.h" namespace motion { - class SensorProxy { + class SensorAdapter { public: - SensorProxy(); - virtual ~SensorProxy(); + SensorAdapter(ISensorListener* listener); + ~SensorAdapter(); void setSensor(sensor_type_t type); void setPowerSave(bool ps); - void setUserData(void *data); + void setAttribute(int key, int value); - bool stop(bool force = false); - - virtual bool start(); - - protected: - int sensorHandle; - bool running; - sensor_type_t sensorType; - bool powerSave; - void *userData; - - double getTime(unsigned long long monotonic); + bool start(); + bool stop(); static bool isSupported(sensor_type_t type); - virtual void onEvent(sensor_data_t *eventData) = 0; - private: + double __getEpoch(unsigned long long monotonic); + void __onEvent(sensor_data_t* eventData); + static void __eventCb(sensor_t sensor, unsigned int eventType, sensor_data_t *eventData, void *cbData); + + int __sensorHandle; + sensor_type_t __sensorType; + bool __powerSave; + void *__userData; + ISensorListener *__listener; }; } -#endif /* _MOTION_SENSOR_PROXY_H_ */ +#endif /* __MOTION_SENSOR_ADAPTER_H__ */ diff --git a/src/SensorProxy.cpp b/src/SensorProxy.cpp deleted file mode 100644 index a120048..0000000 --- a/src/SensorProxy.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2016 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 -#include -#include "SensorProxy.h" - -#define SENSOR_EVENT(X) (((int)(X) << 16) | 0x01) - -using namespace motion; - -SensorProxy::SensorProxy() - : sensorHandle(-1) - , running(false) - , sensorType(UNKNOWN_SENSOR) - , powerSave(true) - , userData(NULL) -{ -} - -SensorProxy::~SensorProxy() -{ - stop(true); -} - -void SensorProxy::setSensor(sensor_type_t type) -{ - sensorType = type; -} - -void SensorProxy::setPowerSave(bool ps) -{ - powerSave = ps; -} - -void SensorProxy::setUserData(void *data) -{ - userData = data; -} - -bool SensorProxy::start() -{ - sensor_t sensor = sensord_get_sensor(sensorType); - IF_FAIL_RETURN_TAG(sensor, false, _E, "Getting sensor failed"); - - sensorHandle = sensord_connect(sensor); - IF_FAIL_RETURN_TAG(sensorHandle >= 0, false, _E, "Connection failed"); - - if (!sensord_register_event(sensorHandle, SENSOR_EVENT(sensorType), 0, 0, __eventCb, this)) { - _E("Event registration failed"); - sensord_disconnect(sensorHandle); - sensorHandle = -1; - return false; - } - - if (!sensord_start(sensorHandle, powerSave ? SENSOR_OPTION_DEFAULT : SENSOR_OPTION_ALWAYS_ON)) { - _E("Starting failed"); - sensord_unregister_event(sensorHandle, SENSOR_EVENT(sensorType)); - sensord_disconnect(sensorHandle); - sensorHandle = -1; - return false; - } - - return true; -} - -bool SensorProxy::stop(bool force) -{ - if (!force) { - IF_FAIL_RETURN(sensorHandle >= 0, false); - } - - sensord_stop(sensorHandle); - sensord_unregister_event(sensorHandle, SENSOR_EVENT(sensorType)); - sensord_disconnect(sensorHandle); - sensorHandle = -1; - - return true; -} - -double SensorProxy::getTime(unsigned long long monotonic) -{ - struct timespec ts; - struct timeval tv; - double timeDiff; - double timestamp; - - clock_gettime(CLOCK_MONOTONIC, &ts); - timeDiff = (ts.tv_sec * 1000000000.0 + ts.tv_nsec) / 1000000.0 - monotonic / 1000.0; - - gettimeofday(&tv, NULL); - timestamp = tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0 - timeDiff; - return timestamp; -} - -bool SensorProxy::isSupported(sensor_type_t type) -{ - sensor_t sensor = sensord_get_sensor(type); - return (sensor != NULL); -} - -void SensorProxy::__eventCb(sensor_t sensor, unsigned int eventType, sensor_data_t *eventData, void *cbData) -{ - SensorProxy *instance = static_cast(cbData); - instance->onEvent(eventData); -} -- 2.34.1 From d4562929a60c1e931f754a5b4042691b697240fe Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Mon, 31 Oct 2016 13:39:05 +0900 Subject: [PATCH 10/16] Cleanup the license script in the spec Change-Id: I78cc55675c4c402b258579f85dc0f6588ba24d46 Signed-off-by: Mu-Woong Lee --- packaging/motion.spec | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packaging/motion.spec b/packaging/motion.spec index 0dc8083..0bb75ba 100644 --- a/packaging/motion.spec +++ b/packaging/motion.spec @@ -51,8 +51,6 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}/usr/share/license -cp LICENSE %{buildroot}/usr/share/license/%{name} # For backward compatibility ln -s ./%{name}.pc %{buildroot}/%{_libdir}/pkgconfig/libcore-context-manager.pc @@ -66,7 +64,7 @@ ln -s ./%{name}.pc %{buildroot}/%{_libdir}/pkgconfig/libcore-context-manager.pc %manifest packaging/%{name}.manifest %defattr(-,root,root,-) %{_libdir}/*.so* -/usr/share/license/%{name} +%license LICENSE %package devel Summary: Tizen Native Motion Recognition API (Development) -- 2.34.1 From a801a755f95695b8c3418aed7440ea65e18cd406 Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Fri, 16 Dec 2016 18:31:39 +0900 Subject: [PATCH 11/16] Doxygen modified Change-Id: I436c6f08c06fa41d5a6aa9682c2e7741e8386b46 Signed-off-by: Somin Kim --- include/activity_recognition.h | 102 ++++++++++++++++----------------- include/gesture_recognition.h | 86 +++++++++++++-------------- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/include/activity_recognition.h b/include/activity_recognition.h index e908d87..0f44788 100644 --- a/include/activity_recognition.h +++ b/include/activity_recognition.h @@ -33,19 +33,19 @@ extern "C" { #endif // __cplusplus /** - * @brief Handle for controlling the activity recognizer + * @brief The activity recognizer controlling handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct _activity_handle_s* activity_h; /** - * @brief Activity data handle delivered through activity_recognition_cb() + * @brief Delivery through activity_recognition_cb() of activity data handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct _activity_data_s* activity_data_h; /** - * @brief Error codes + * @brief Enumeration for error codes. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -61,7 +61,7 @@ typedef enum { } activity_error_e; /** - * @brief Activity types + * @brief Enumeration for activity types. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -72,7 +72,7 @@ typedef enum { } activity_type_e; /** - * @brief Recognition accuracy + * @brief Enumeration for recognition accuracy. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -107,16 +107,16 @@ typedef void(* activity_recognition_cb)(activity_type_e activity, const activity * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] activity Activity type to be checked. - * @param[out] supported @c true, if the activity is recognizable in the current device.@n - * @c false, otherwise. + * @param[in] activity Activity type to be checked + * @param[out] supported @c true if the activity is recognizable in the current device,@n + * @c false otherwise * - * @return 0 if the @c activity is supported, otherwise a negative error value. - * @retval #ACTIVITY_ERROR_NONE Supported. - * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #ACTIVITY_ERROR_NOT_SUPPORTED The @c activity is not supported. - * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error. - * @retval #ACTIVITY_ERROR_PERMISSION_DENIED Does not have permission to use this. + * @return @c 0 if the @c activity is supported, otherwise a negative error value + * @retval #ACTIVITY_ERROR_NONE Supported + * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #ACTIVITY_ERROR_NOT_SUPPORTED The @c activity is not supported + * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error + * @retval #ACTIVITY_ERROR_PERMISSION_DENIED Does not have permission to use this */ int activity_is_supported(activity_type_e activity, bool* supported); @@ -125,13 +125,13 @@ int activity_is_supported(activity_type_e activity, bool* supported); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[out] handle Activity handle to be initialized. + * @param[out] handle Activity handle to be initialized * - * @return 0 on success, otherwise a negative error value. - * @retval #ACTIVITY_ERROR_NONE Successful. - * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported. - * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error, e.g., out of memory. + * @return @c 0 on success, otherwise a negative error value + * @retval #ACTIVITY_ERROR_NONE Successful + * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported + * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error, e.g., out of memory * * @see activity_release() */ @@ -142,13 +142,13 @@ int activity_create(activity_h *handle); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] handle Activity handle to be released. + * @param[in] handle Activity handle to be released * - * @return 0 on success, otherwise a negative error value. - * @retval #ACTIVITY_ERROR_NONE Successful. - * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported. - * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error. + * @return @c 0 on success, otherwise a negative error value + * @retval #ACTIVITY_ERROR_NONE Successful + * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported + * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error * * @pre activity_create() */ @@ -161,18 +161,18 @@ int activity_release(activity_h handle); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] handle Activity handle to be used to control the activity event. - * @param[in] activity Activity type to be monitored. - * @param[in] callback Callback function to receive activity events. - * @param[in] user_data User data to be passed to the callback function. + * @param[in] handle Activity handle to be used to control the activity event + * @param[in] activity Activity type to be monitored + * @param[in] callback Callback function to receive activity events + * @param[in] user_data User data to be passed to the callback function * - * @return 0 on success, otherwise a negative error value. - * @retval #ACTIVITY_ERROR_NONE Successful. - * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported. - * @retval #ACTIVITY_ERROR_ALREADY_STARTED The @c handle is being used already. - * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error. - * @retval #ACTIVITY_ERROR_PERMISSION_DENIED Does not have permission to use this. + * @return @c 0 on success, otherwise a negative error value + * @retval #ACTIVITY_ERROR_NONE Successful + * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported + * @retval #ACTIVITY_ERROR_ALREADY_STARTED The @c handle is being used already + * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error + * @retval #ACTIVITY_ERROR_PERMISSION_DENIED Does not have permission to use this * * @pre activity_create() * @post activity_recognition_cb() @@ -185,14 +185,14 @@ int activity_start_recognition(activity_h handle, activity_type_e activity, acti * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] handle Activity handle to release its callback function registered. + * @param[in] handle Activity handle to release its callback function registered * - * @return 0 on success, otherwise a negative error value. - * @retval #ACTIVITY_ERROR_NONE Successful. - * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported. - * @retval #ACTIVITY_ERROR_NOT_STARTED Nothing is started using the @c handle. - * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error. + * @return @c 0 on success, otherwise a negative error value + * @retval #ACTIVITY_ERROR_NONE Successful + * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported + * @retval #ACTIVITY_ERROR_NOT_STARTED Nothing is started using the @c handle + * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error */ int activity_stop_recognition(activity_h handle); @@ -201,14 +201,14 @@ int activity_stop_recognition(activity_h handle); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] data Activity data received through activity_cb(). - * @param[out] accuracy Accuracy. + * @param[in] data Activity data received through activity_cb() + * @param[out] accuracy Accuracy * - * @return 0 on success, otherwise a negative error value. - * @retval #ACTIVITY_ERROR_NONE Successful. - * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported. - * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error. + * @return @c 0 on success, otherwise a negative error value + * @retval #ACTIVITY_ERROR_NONE Successful + * @retval #ACTIVITY_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #ACTIVITY_ERROR_NOT_SUPPORTED Activity recognition is not supported + * @retval #ACTIVITY_ERROR_OPERATION_FAILED Operation failed because of a system error */ int activity_get_accuracy(const activity_data_h data, activity_accuracy_e *accuracy); diff --git a/include/gesture_recognition.h b/include/gesture_recognition.h index 65b3f2a..c0cfd1a 100644 --- a/include/gesture_recognition.h +++ b/include/gesture_recognition.h @@ -33,19 +33,19 @@ extern "C" { #endif // __cplusplus /** - * @brief Handle for controlling the gesture recognizer + * @brief The gesture recognizer controlling handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct _gesture_handle_s* gesture_h; /** - * @brief Gesture data handle delivered through gesture_recognition_cb() + * @brief Delivery through gesture_recognition_cb() of gesture data handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct _gesture_data_s* gesture_data_h; /** - * @brief Error codes + * @brief Enumeration for error codes. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -61,7 +61,7 @@ typedef enum { } gesture_error_e; /** - * @brief Gesture types + * @brief Enumeration for gesture types. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -77,7 +77,7 @@ typedef enum { } gesture_type_e; /** - * @brief Gesture recognition option + * @brief Enumeration for gesture recognition option. * @details If the default option is used, the system tries to reduce power consumption. * For example, the recognition engine may stop detecting gestures if the display is turned off. * Using #GESTURE_OPTION_ALWAYS_ON disables such power-saving functionalities. @@ -136,10 +136,10 @@ typedef void(* gesture_recognition_cb)(gesture_type_e gesture, const gesture_dat * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] gesture Gesture type to be checked. - * @param[out] supported @c true, if the gesture is recognizable in the current device.@n - * @c false, otherwise. + * @param[out] supported @c true if the gesture is recognizable in the current device,@n + * @c false otherwise. * - * @return 0 if the @c gesture is supported, otherwise a negative error value. + * @return @c 0 if the @c gesture is supported, otherwise a negative error value. * @retval #GESTURE_ERROR_NONE Supported. * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. * @retval #GESTURE_ERROR_NOT_SUPPORTED The @c gesture is not supported. @@ -153,13 +153,13 @@ int gesture_is_supported(gesture_type_e gesture, bool* supported); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[out] handle Gesture handle to be initialized. + * @param[out] handle Gesture handle to be initialized * - * @return 0 on success, otherwise a negative error value. - * @retval #GESTURE_ERROR_NONE Successful. - * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported. - * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error, e.g., out of memory. + * @return @c 0 on success, otherwise a negative error value + * @retval #GESTURE_ERROR_NONE Successful + * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported + * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error, e.g., out of memory * * @see gesture_release() */ @@ -170,13 +170,13 @@ int gesture_create(gesture_h *handle); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] handle Gesture handle to be released. + * @param[in] handle Gesture handle to be released * - * @return 0 on success, otherwise a negative error value. - * @retval #GESTURE_ERROR_NONE Successful. - * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported. - * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error. + * @return @c 0 on success, otherwise a negative error value + * @retval #GESTURE_ERROR_NONE Successful + * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported + * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error * * @pre gesture_create() */ @@ -195,7 +195,7 @@ int gesture_release(gesture_h handle); * @param[in] callback Callback function to receive gesture events. * @param[in] user_data User data to be passed to the callback function. * - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, otherwise a negative error value. * @retval #GESTURE_ERROR_NONE Successful. * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported. @@ -214,14 +214,14 @@ int gesture_start_recognition(gesture_h handle, gesture_type_e gesture, gesture_ * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] handle Gesture handle to release its callback function registered. + * @param[in] handle Gesture handle to release its callback function registered * - * @return 0 on success, otherwise a negative error value. - * @retval #GESTURE_ERROR_NONE Successful. - * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported. - * @retval #GESTURE_ERROR_NOT_STARTED Nothing is started using the @c handle. - * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error. + * @return @c 0 on success, otherwise a negative error value + * @retval #GESTURE_ERROR_NONE Successful + * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported + * @retval #GESTURE_ERROR_NOT_STARTED Nothing is started using the @c handle + * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error */ int gesture_stop_recognition(gesture_h handle); @@ -230,14 +230,14 @@ int gesture_stop_recognition(gesture_h handle); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] data Gesture data received through a callback function. - * @param[out] event Gesture event data. + * @param[in] data Gesture data received through a callback function + * @param[out] event Gesture event data * - * @return 0 on success, otherwise a negative error value. - * @retval #GESTURE_ERROR_NONE Successful. - * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported. - * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error. + * @return @c 0 on success, otherwise a negative error value + * @retval #GESTURE_ERROR_NONE Successful + * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported + * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error */ int gesture_get_event(const gesture_data_h data, gesture_event_e *event); @@ -246,15 +246,15 @@ int gesture_get_event(const gesture_data_h data, gesture_event_e *event); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] data Tilt gesture data received through a callback function. - * @param[out] x Tilting degree on X-axis. - * @param[out] y Tilting degree on Y-axis. + * @param[in] data Tilt gesture data received through a callback function + * @param[out] x Tilting degree on X-axis + * @param[out] y Tilting degree on Y-axis * - * @return 0 on success, otherwise a negative error value. - * @retval #GESTURE_ERROR_NONE Successful. - * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported. - * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error. + * @return @c 0 on success, otherwise a negative error value + * @retval #GESTURE_ERROR_NONE Successful + * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported + * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error */ int gesture_get_tilt(const gesture_data_h data, int *x, int *y); -- 2.34.1 From 1c160ef7bdbb27c4403322354213cfc0625ff649 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 5 Jan 2017 20:36:51 +0900 Subject: [PATCH 12/16] Update doxygen Change-Id: I81ad24c1aa4b4b4d1b68fbd71d3934117cf370b9 Signed-off-by: Mu-Woong Lee --- include/gesture_recognition.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/gesture_recognition.h b/include/gesture_recognition.h index c0cfd1a..d24fba2 100644 --- a/include/gesture_recognition.h +++ b/include/gesture_recognition.h @@ -90,7 +90,8 @@ typedef enum { } gesture_option_e; /** - * @brief Regarding the type of the gesture, gesture_get_event() returns one of the followings. + * @brief Enumeration for gesture event types. + * @details With regards to type of the gesture, gesture_get_event() returns one of the followings. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { -- 2.34.1 From d75b7b6b0e8a51c28756c81ddee7b255da6c16b3 Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Thu, 12 Jan 2017 16:12:57 +0900 Subject: [PATCH 13/16] Doxygen update Change-Id: I2d90a6072574bdae737850f31059ccd3dfa907b8 Signed-off-by: Somin Kim --- include/gesture_recognition.h | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/include/gesture_recognition.h b/include/gesture_recognition.h index d24fba2..ae3bc02 100644 --- a/include/gesture_recognition.h +++ b/include/gesture_recognition.h @@ -114,7 +114,7 @@ typedef enum { * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] gesture Gesture type detected. + * @param[in] gesture Gesture type detected * @param[in] data Detailed information of the detected gesture.@n * gesture_get_event() or gesture_get_tilt() * can be used to extract the information from @c data. @@ -124,7 +124,7 @@ typedef enum { * #GESTURE_ERROR_NOT_SUPPORTED, if the gesture is not supported in the current profile.@n * #GESTURE_ERROR_OPERATION_FAILED, if the operation failed because of a system error.@n * #GESTURE_ERROR_PERMISSION_DENIED, if the application has no permission to use this. - * @param[in] user_data The user data had passed to gesture_start_recognition(). + * @param[in] user_data The user data had passed to gesture_start_recognition() * * @pre gesture_start_recognition() */ @@ -136,16 +136,16 @@ typedef void(* gesture_recognition_cb)(gesture_type_e gesture, const gesture_dat * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] gesture Gesture type to be checked. + * @param[in] gesture Gesture type to be checked * @param[out] supported @c true if the gesture is recognizable in the current device,@n - * @c false otherwise. - * - * @return @c 0 if the @c gesture is supported, otherwise a negative error value. - * @retval #GESTURE_ERROR_NONE Supported. - * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #GESTURE_ERROR_NOT_SUPPORTED The @c gesture is not supported. - * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error. - * @retval #GESTURE_ERROR_PERMISSION_DENIED Does not have permission to use this. + * @c false otherwise + * + * @return @c 0 if the @c gesture is supported, otherwise a negative error value + * @retval #GESTURE_ERROR_NONE Supported + * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #GESTURE_ERROR_NOT_SUPPORTED The @c gesture is not supported + * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error + * @retval #GESTURE_ERROR_PERMISSION_DENIED Does not have permission to use this */ int gesture_is_supported(gesture_type_e gesture, bool* supported); @@ -190,19 +190,19 @@ int gesture_release(gesture_h handle); * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] handle Gesture handle to be used to control the gesture event. - * @param[in] gesture Gesture type to be monitored. It should be one of #gesture_type_e. - * @param[in] option Detection option. It should be one of #gesture_option_e. - * @param[in] callback Callback function to receive gesture events. - * @param[in] user_data User data to be passed to the callback function. - * - * @return @c 0 on success, otherwise a negative error value. - * @retval #GESTURE_ERROR_NONE Successful. - * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used. - * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported. - * @retval #GESTURE_ERROR_ALREADY_STARTED The @c handle is being used already. - * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error. - * @retval #GESTURE_ERROR_PERMISSION_DENIED Does not have permission to use this. + * @param[in] handle Gesture handle to be used to control the gesture event + * @param[in] gesture Gesture type to be monitored + * @param[in] option Detection option + * @param[in] callback Callback function to receive gesture events + * @param[in] user_data User data to be passed to the callback function + * + * @return @c 0 on success, otherwise a negative error value + * @retval #GESTURE_ERROR_NONE Successful + * @retval #GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used + * @retval #GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported + * @retval #GESTURE_ERROR_ALREADY_STARTED The @c handle is being used already + * @retval #GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error + * @retval #GESTURE_ERROR_PERMISSION_DENIED Does not have permission to use this * * @pre gesture_create() * @post gesture_recognition_cb() -- 2.34.1 From 5922a25301d71448c227ad71d8a6b7b857b55c63 Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Thu, 12 Jan 2017 16:59:43 +0900 Subject: [PATCH 14/16] Doxygen update(acitivty) Change-Id: I28b6af808c4678de6001afabd136032d3889c1c6 Signed-off-by: Somin Kim --- include/activity_recognition.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/activity_recognition.h b/include/activity_recognition.h index 0f44788..a6bfc33 100644 --- a/include/activity_recognition.h +++ b/include/activity_recognition.h @@ -86,15 +86,15 @@ typedef enum { * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * - * @param[in] activity Activity recognized. - * @param[in] data Detailed information of the recognized activity. + * @param[in] activity Activity recognized + * @param[in] data Detailed information of the recognized activity * @param[in] timestamp The time when the activity is recognized. Epoch time in seconds. * @param[in] error An error value. It can be one of the following error values:@n * #ACTIVITY_ERROR_NONE, if the operation succeeded.@n * #ACTIVITY_ERROR_NOT_SUPPORTED, if the activity is not supported in the current profile.@n * #ACTIVITY_ERROR_OPERATION_FAILED, if the operation failed because of a system error.@n * #ACTIVITY_ERROR_PERMISSION_DENIED, if the application has no permission to use this. - * @param[in] user_data The user data had passed to activity_start_recognition(). + * @param[in] user_data The user data had passed to activity_start_recognition() * * @pre activity_start_recognition() * @see activity_get_accuracy() -- 2.34.1 From 5e9e5598f9ce14211a6e553510cac6e1fadd912e Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Wed, 8 Feb 2017 14:26:28 +0900 Subject: [PATCH 15/16] Fix svace issue(remove unused variable) Change-Id: I5601efe2c158da93d7c91c3aac7e3392f4179276 Signed-off-by: Somin Kim (cherry picked from commit aaed994cf29919192e8915ca8674647318e7e7dc) --- src/SensorAdapter.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SensorAdapter.h b/src/SensorAdapter.h index 66ac04d..c161d43 100644 --- a/src/SensorAdapter.h +++ b/src/SensorAdapter.h @@ -47,7 +47,6 @@ namespace motion { int __sensorHandle; sensor_type_t __sensorType; bool __powerSave; - void *__userData; ISensorListener *__listener; }; -- 2.34.1 From 085f9ef641cd603d5c73a08fda6a6d7e4058e537 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 2 Mar 2017 12:40:54 +0900 Subject: [PATCH 16/16] Update the license date to 2014-2017 Change-Id: Ib8959b8e271b0ea9f3081374d5dd6d4bc09cd149 Signed-off-by: Mu-Woong Lee --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 87979c5..6ce6ec7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014 - 2016 Samsung Electronics Co., Ltd. All rights reserved. +Copyright (c) 2014 - 2017 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 -- 2.34.1