Change deprecated gesture recognition API to new gesture API 62/282262/1
authorEunyoung Lee <ey928.lee@samsung.com>
Thu, 29 Sep 2022 08:05:06 +0000 (17:05 +0900)
committerEunyoung Lee <ey928.lee@samsung.com>
Thu, 29 Sep 2022 08:09:52 +0000 (17:09 +0900)
Change-Id: I8fc4b5e8f2f8e7ea8a67aefa15ec5dbfdb58f490

call-ui/presenters/misc/MotionSensorPresenter.cpp
call-ui/presenters/misc/MotionSensorPresenter.h

index c6f290af5ecd707c423765815f8f84783516011b..99e18fd7ba96593d31688da9daf96762fc025c37 100644 (file)
@@ -45,52 +45,50 @@ namespace callui {
        MotionSensorPresenter::~MotionSensorPresenter()
        {
                if (m_gesture) {
-                       gesture_stop_recognition(m_gesture);
-                       gesture_release(m_gesture);
+                       hand_gesture_stop_recognition(m_gesture);
+                       hand_gesture_destroy(m_gesture);
                }
        }
 
        Result MotionSensorPresenter::prepare()
        {
-               int res = gesture_create(&m_gesture);
-               if (res != GESTURE_ERROR_NONE) {
+               int res = hand_gesture_create(&m_gesture);
+               if (res != HAND_GESTURE_ERROR_NONE) {
                        LOG_RETURN(RES_FAIL, "gesture_create() failed. "
                                        "res[%d] msg[%s]", res, get_error_message(res));
                }
 
-               res = gesture_start_recognition(m_gesture, GESTURE_WRIST_UP,
-                               GESTURE_OPTION_ALWAYS_ON,
+               res = hand_gesture_start_recognition(m_gesture, HAND_GESTURE_WRIST_UP,
                                CALLBACK_B(MotionSensorPresenter::onGestureCb),
                                this);
-               if (res != GESTURE_ERROR_NONE) {
+               if (res != HAND_GESTURE_ERROR_NONE) {
                        LOG_RETURN(RES_FAIL, "gesture_start_recognition() failed. "
                                        "res[%d] msg[%s]", res, get_error_message(res));
                }
+
+               res = hand_gesture_set_option(m_gesture, HAND_GESTURE_OPTION_ALWAYS_ON);
+               if (res != HAND_GESTURE_ERROR_NONE) {
+                       LOG_RETURN(RES_FAIL, "hand_gesture_set_option() failed. "
+                                       "res[%d] msg[%s]", res, get_error_message(res));
+               }
+
                return RES_OK;
        }
 
-       void MotionSensorPresenter::onGestureCb(gesture_type_e motion,
-                                       const gesture_data_h data,
+       void MotionSensorPresenter::onGestureCb(hand_gesture_h handle,
+                                       hand_gesture_type_e gesture,
                                        double timeStamp,
-                                       gesture_error_e error)
+                                       hand_gesture_error_e error,
+                                       void *user_data)
        {
                if (error) {
                        LOG_RETURN_VOID(RES_FAIL, "Error occured. "
                                        "err[%d] msg[%s]", error, get_error_message(error));
                }
 
-               if (motion == GESTURE_WRIST_UP) {
-                       gesture_event_e event;
-                       int res = gesture_get_event(data, &event);
-                       if (res != GESTURE_ERROR_NONE) {
-                               LOG_RETURN_VOID(RES_FAIL, "gesture_get_event() failed. "
-                                               "err[%d] msg[%s]", res, get_error_message(res));
-                       }
-
-                       if (event == GESTURE_EVENT_DETECTED) {
-                               if (const auto handler = m_handler.lock()) {
-                                       handler();
-                               }
+               if (gesture == HAND_GESTURE_WRIST_UP) {
+                       if (const auto handler = m_handler.lock()) {
+                               handler();
                        }
                }
        }
index ea9556fe4ff70fb573515994c71d14bfaa818193..5daeaccbe5e98b6b1a9a3523bb85f73166fa64d3 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __CALL_UI_PRESENTERS_MISC_MOTION_SENSOR_PRESENTER_H__
 #define __CALL_UI_PRESENTERS_MISC_MOTION_SENSOR_PRESENTER_H__
 
-#include <gesture_recognition.h>
+#include <gesture.h>
 
 #include "call-ui/presenters/types.h"
 
@@ -56,15 +56,16 @@ namespace callui {
 
                ucl::Result prepare();
 
-               void onGestureCb(gesture_type_e motion,
-                               const gesture_data_h data,
-                               double timeStamp,
-                               gesture_error_e error);
+               void onGestureCb(hand_gesture_h handle,
+                               hand_gesture_type_e gesture,
+                               double timestamp,
+                               hand_gesture_error_e error,
+                               void *user_data);
 
        private:
                const NotiHandler m_handler;
 
-               gesture_h m_gesture;
+               hand_gesture_h m_gesture;
 
                friend class ucl::ReffedObj<MotionSensorPresenter>;
        };