From 174fbf1caea0a90fe7cee5bfe846b8ee29f44413 Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Wed, 27 Jul 2016 17:43:39 +0900 Subject: [PATCH] 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.7.4