[HAM] Process API removal change 41/277641/2 accepted/tizen/unified/20220721.135003 submit/tizen/20220721.053220
authorPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Mon, 11 Jul 2022 09:42:42 +0000 (11:42 +0200)
committerPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Mon, 11 Jul 2022 12:10:38 +0000 (14:10 +0200)
[ACR] https://code.sec.samsung.net/jira/browse/TWDAPI-287

[Verification]
Code compiles without errors.
Removed APIs throw NotSupportedError exception on use.

Change-Id: Ic05212ea5656d0fa4a16a2e72ac9ca913e010bed

src/humanactivitymonitor/gesture_manager.cc [deleted file]
src/humanactivitymonitor/gesture_manager.h [deleted file]
src/humanactivitymonitor/humanactivitymonitor.gyp
src/humanactivitymonitor/humanactivitymonitor_api.js
src/humanactivitymonitor/humanactivitymonitor_instance.cc
src/humanactivitymonitor/humanactivitymonitor_instance.h
src/humanactivitymonitor/humanactivitymonitor_manager.cc
src/humanactivitymonitor/humanactivitymonitor_manager.h

diff --git a/src/humanactivitymonitor/gesture_manager.cc b/src/humanactivitymonitor/gesture_manager.cc
deleted file mode 100644 (file)
index 37226bc..0000000
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include "humanactivitymonitor/gesture_manager.h"
-
-#include <gesture_recognition.h>
-
-#include "common/extension.h"
-#include "common/logger.h"
-#include "common/optional.h"
-#include "common/picojson.h"
-#include "common/scope_exit.h"
-#include "common/tools.h"
-
-namespace extension {
-namespace humanactivitymonitor {
-
-using common::PlatformResult;
-using common::ErrorCode;
-using common::tools::ReportError;
-using common::tools::ReportSuccess;
-
-namespace {
-
-const std::string kListenerId = "listenerId";
-const std::string kListener = "GestureRecognitionListener";
-const std::string kType = "type";
-const std::string kTimestamp = "timestamp";
-const std::string kAlwayOn = "alwaysOn";
-const std::string kAction = "action";
-const std::string kEvent = "event";
-const std::string kError = "error";
-const std::string kOnError = "onerror";
-const std::string kOnDetect = "ondetect";
-
-ErrorCode getErrorCode(int error) {
-  switch (error) {
-    case GESTURE_ERROR_NONE:
-      return ErrorCode::NO_ERROR;
-    case GESTURE_ERROR_INVALID_PARAMETER:
-      return ErrorCode::INVALID_VALUES_ERR;
-    case GESTURE_ERROR_OPERATION_FAILED:
-      return ErrorCode::IO_ERR;
-    case GESTURE_ERROR_NOT_SUPPORTED:
-      return ErrorCode::NOT_SUPPORTED_ERR;
-    case GESTURE_ERROR_INVALID_OPERATION:
-    case GESTURE_ERROR_OUT_OF_MEMORY:
-    case GESTURE_ERROR_PERMISSION_DENIED:
-    case GESTURE_ERROR_ALREADY_STARTED:
-    case GESTURE_ERROR_NOT_STARTED:
-    default:
-      return ErrorCode::ABORT_ERR;
-  }
-}
-
-PlatformResult StrToGestureType(const std::string& type, gesture_type_e* type_e) {
-  if ("GESTURE_DOUBLE_TAP" == type) {
-    *type_e = GESTURE_DOUBLE_TAP;
-  } else if ("GESTURE_MOVE_TO_EAR" == type) {
-    *type_e = GESTURE_MOVE_TO_EAR;
-  } else if ("GESTURE_NO_MOVE" == type) {
-    *type_e = GESTURE_NO_MOVE;
-  } else if ("GESTURE_PICK_UP" == type) {
-    *type_e = GESTURE_PICK_UP;
-  } else if ("GESTURE_SHAKE" == type) {
-    *type_e = GESTURE_SHAKE;
-  } else if ("GESTURE_SNAP" == type) {
-    *type_e = GESTURE_SNAP;
-  } else if ("GESTURE_TILT" == type) {
-    *type_e = GESTURE_TILT;
-  } else if ("GESTURE_TURN_FACE_DOWN" == type) {
-    *type_e = GESTURE_TURN_FACE_DOWN;
-  } else if ("GESTURE_WRIST_UP" == type) {
-    *type_e = GESTURE_WRIST_UP;
-  } else {
-    return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Unknown gesture type");
-  }
-
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-std::string GestureTypeToStr(gesture_type_e type) {
-  switch (type) {
-    case GESTURE_DOUBLE_TAP:
-      return "GESTURE_DOUBLE_TAP";
-    case GESTURE_MOVE_TO_EAR:
-      return "GESTURE_MOVE_TO_EAR";
-    case GESTURE_NO_MOVE:
-      return "GESTURE_NO_MOVE";
-    case GESTURE_PICK_UP:
-      return "GESTURE_PICK_UP";
-    case GESTURE_SHAKE:
-      return "GESTURE_SHAKE";
-    case GESTURE_SNAP:
-      return "GESTURE_SNAP";
-    case GESTURE_TILT:
-      return "GESTURE_TILT";
-    case GESTURE_TURN_FACE_DOWN:
-      return "GESTURE_TURN_FACE_DOWN";
-    case GESTURE_WRIST_UP:
-      return "GESTURE_WRIST_UP";
-    default:
-      return "GESTURE_UNKNOWN_TYPE";
-  }
-}
-std::string GestureEventToStr(gesture_event_e event, gesture_type_e gesture) {
-  switch (event) {
-    // GESTURE_EVENT_DETECTED == GESTURE_SHAKE_DETECTED == GESTURE_SNAP_X_NEGATIVE == 1
-    case GESTURE_EVENT_DETECTED:
-      if (GESTURE_SHAKE == gesture) {
-        return "GESTURE_SHAKE_DETECTED";
-      } else if (GESTURE_SNAP == gesture) {
-        return "GESTURE_SNAP_X_NEGATIVE";
-      } else {
-        return "GESTURE_EVENT_DETECTED";
-      }
-    // GESTURE_SHAKE_FINISHED == GESTURE_SNAP_X_POSITIVE == 2
-    case GESTURE_SHAKE_FINISHED:
-      if (GESTURE_SHAKE == gesture) {
-        return "GESTURE_SHAKE_FINISHED";
-      } else {
-        return "GESTURE_SNAP_X_POSITIVE";
-      }
-    case GESTURE_SNAP_Y_NEGATIVE:
-      return "GESTURE_SNAP_Y_NEGATIVE";
-    case GESTURE_SNAP_Y_POSITIVE:
-      return "GESTURE_SNAP_Y_POSITIVE";
-    case GESTURE_SNAP_Z_NEGATIVE:
-      return "GESTURE_SNAP_Z_NEGATIVE";
-    case GESTURE_SNAP_Z_POSITIVE:
-      return "GESTURE_SNAP_Z_POSITIVE";
-    default:
-      return "GESTURE_EVENT_NONE";
-  }
-}
-
-void GestureRecognitionDefaultCb(gesture_type_e gesture, const gesture_data_h data,
-                                 double timestamp, gesture_error_e error, void* user_data) {
-  ScopeLogger();
-
-  GestureManager* manager = static_cast<GestureManager*>(user_data);
-  if (!manager) {
-    LoggerW("User data is null");
-    return;
-  }
-
-  manager->CompleteGestureListenerCb(gesture, data, timestamp, error, false);
-}
-
-void GestureRecognitionAlwaysOnCb(gesture_type_e gesture, const gesture_data_h data,
-                                  double timestamp, gesture_error_e error, void* user_data) {
-  ScopeLogger();
-  GestureManager* manager = static_cast<GestureManager*>(user_data);
-
-  if (!manager) {
-    LoggerW("User data is null");
-    return;
-  }
-
-  manager->CompleteGestureListenerCb(gesture, data, timestamp, error, true);
-}
-
-}  // namespace
-
-GestureManager::GestureManager()
-    : m_callback(nullptr), m_recognition_default_map(), m_recognition_always_on_map() {
-  ScopeLogger();
-}
-
-GestureManager::~GestureManager() {
-  ScopeLogger();
-
-  int ret = GESTURE_ERROR_NONE;
-
-  for (auto& it : m_recognition_default_map) {
-    // gesture_stop_recognition is deprecated since 6.0
-    ret = gesture_stop_recognition(it.second);
-    if (GESTURE_ERROR_NONE != ret) {
-      LoggerE("gesture_stop_recognition() failed");
-    }
-
-    // gesture_release is deprecated since 6.0
-    ret = gesture_release(it.second);
-    if (GESTURE_ERROR_NONE != ret) {
-      LoggerE("gesture_release() failed");
-    }
-  }
-
-  for (auto& it : m_recognition_always_on_map) {
-    // gesture_stop_recognition is deprecated since 6.0
-    ret = gesture_stop_recognition(it.second);
-    if (GESTURE_ERROR_NONE != ret) {
-      LoggerE("gesture_stop_recognition() failed");
-    }
-
-    // gesture_release is deprecated since 6.0
-    ret = gesture_release(it.second);
-    if (GESTURE_ERROR_NONE != ret) {
-      LoggerE("gesture_release() failed");
-    }
-  }
-
-  m_recognition_default_map.clear();
-  m_recognition_always_on_map.clear();
-}
-
-PlatformResult GestureManager::IsSupported(const std::string& type, bool* is_supported) {
-  ScopeLogger();
-
-  gesture_type_e type_e = GESTURE_DOUBLE_TAP;
-  PlatformResult result = StrToGestureType(type, &type_e);
-  if (!result) {
-    return result;
-  }
-
-  // gesture_is_supported is deprecated since 6.0
-  int ret = gesture_is_supported(type_e, is_supported);
-  if (GESTURE_ERROR_NONE != ret && GESTURE_ERROR_NOT_SUPPORTED != ret) {
-    return LogAndCreateResult(
-        getErrorCode(ret), "Checking gesture failed",
-        ("Checking gesture failed, error: %d (%s)", ret, get_error_message(ret)));
-  }
-
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-gesture_event_e GestureManager::GetGestureEvent(const gesture_data_h data) {
-  ScopeLogger();
-
-  gesture_event_e event = GESTURE_EVENT_NONE;
-  // gesture_get_event is deprecated since 6.0
-  int ret = gesture_get_event(data, &event);
-  if (GESTURE_ERROR_NONE != ret) {
-    LoggerE("gesture_get_event() failed, error %d (%s)", ret, get_error_message(ret));
-  }
-
-  return event;
-}
-
-void GestureManager::FillTiltData(const gesture_data_h data, picojson::object* obj) {
-  ScopeLogger();
-
-  int x = 0;
-  int y = 0;
-
-  // gesture_get_tilt is deprecated since 6.0
-  int ret = gesture_get_tilt(data, &x, &y);
-  if (GESTURE_ERROR_NONE != ret) {
-    LoggerE("gesture_get_tilt() failed, error %d (%s)", ret, get_error_message(ret));
-  }
-
-  obj->insert(std::make_pair("x", picojson::value(static_cast<double>(x))));
-  obj->insert(std::make_pair("y", picojson::value(static_cast<double>(y))));
-}
-
-void GestureManager::CompleteGestureListenerCb(gesture_type_e gesture, const gesture_data_h data,
-                                               double timestamp, gesture_error_e error,
-                                               bool always_on) {
-  ScopeLogger();
-
-  picojson::value response = picojson::value(picojson::object());
-  auto& obj = response.get<picojson::object>();
-
-  obj.insert(std::make_pair(kAlwayOn, picojson::value(always_on)));
-  obj.insert(std::make_pair(kListenerId, picojson::value(kListener)));
-
-  if (GESTURE_ERROR_NONE != error) {
-    obj.insert(std::make_pair(kAction, picojson::value(kOnError)));
-
-    PlatformResult result =
-        LogAndCreateResult(getErrorCode(error), "Error occurred during recognition");
-    ReportError(result, &obj);
-  } else {
-    gesture_event_e event = GetGestureEvent(data);
-    if (GESTURE_EVENT_NONE == event) {
-      LoggerD("Gesture event none detected.");
-      return;
-    }
-
-    std::string gesture_str = GestureTypeToStr(gesture);
-    if ("GESTURE_UNKNOWN_TYPE" == gesture_str) {
-      LoggerE("Unknown gesture type");
-      return;
-    }
-
-    obj.insert(std::make_pair(kAction, picojson::value(kOnDetect)));
-
-    picojson::value result = picojson::value(picojson::object());
-    auto& result_obj = result.get<picojson::object>();
-
-    result_obj.insert(std::make_pair(kEvent, picojson::value(GestureEventToStr(event, gesture))));
-    result_obj.insert(std::make_pair(kTimestamp, picojson::value(timestamp)));
-    result_obj.insert(std::make_pair(kType, picojson::value(gesture_str)));
-
-    if (GESTURE_TILT == gesture) {
-      FillTiltData(data, &result_obj);
-    }
-
-    ReportSuccess(result, obj);
-  }
-
-  if (!m_callback) {
-    LoggerE("Callback is not defined");
-  } else {
-    m_callback(&response);
-  }
-}
-
-PlatformResult GestureManager::AddListener(gesture_type_e type, gesture_option_e option,
-                                           RecognitionMap& gesture_map,
-                                           gesture_recognition_cb callback) {
-  ScopeLogger();
-
-  gesture_h handle = nullptr;
-
-  // gesture_create is deprecated since 6.0
-  int ret = gesture_create(&handle);
-  if (GESTURE_ERROR_NONE != ret) {
-    return LogAndCreateResult(
-        getErrorCode(ret), "Creating handle failed",
-        ("Creating handle failed, error: %d (%s)", ret, get_error_message(ret)));
-  }
-
-  // gesture_start_recognition is deprecated since 6.0
-  ret = gesture_start_recognition(handle, type, option, callback, this);
-  if (GESTURE_ERROR_NONE != ret) {
-    gesture_release(handle);
-    return LogAndCreateResult(
-        getErrorCode(ret), "Starting recognition failed",
-        ("Starting recognition failed, error: %d (%s)", ret, get_error_message(ret)));
-  }
-
-  gesture_map[type] = handle;
-
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-PlatformResult GestureManager::AddGestureRecognitionListener(const std::string& type,
-                                                             bool always_on, JsonCallback cb) {
-  ScopeLogger();
-
-  gesture_type_e type_e = GESTURE_DOUBLE_TAP;
-  PlatformResult result = StrToGestureType(type, &type_e);
-  if (!result) {
-    return result;
-  }
-
-  gesture_option_e option = GESTURE_OPTION_DEFAULT;
-  gesture_recognition_cb callback = GestureRecognitionDefaultCb;
-  RecognitionMap* gesture_map = &m_recognition_default_map;
-
-  if (!m_callback) {
-    m_callback = cb;
-  }
-
-  if (always_on) {
-    option = GESTURE_OPTION_ALWAYS_ON;
-    callback = GestureRecognitionAlwaysOnCb;
-    gesture_map = &m_recognition_always_on_map;
-  }
-
-  return AddListener(type_e, option, *gesture_map, callback);
-}
-
-PlatformResult GestureManager::RemoveGestureRecognitionListener(const std::string& type,
-                                                                bool always_on) {
-  ScopeLogger();
-
-  auto& recognition_map = always_on ? m_recognition_always_on_map : m_recognition_default_map;
-  gesture_type_e type_e = GESTURE_DOUBLE_TAP;
-  PlatformResult result = StrToGestureType(type, &type_e);
-  if (!result) {
-    LoggerD("Unknown gesture type.");
-    return PlatformResult(ErrorCode::NO_ERROR);
-  }
-
-  gesture_h handle = nullptr;
-  RecognitionMap::iterator it = recognition_map.find(type_e);
-
-  if (recognition_map.end() != it) {
-    handle = it->second;
-  }
-
-  if (handle) {
-    // gesture_stop_recognition is deprecated since 6.0
-    int ret = gesture_stop_recognition(handle);
-    if (GESTURE_ERROR_NONE != ret) {
-      return LogAndCreateResult(
-          getErrorCode(ret), "Stoping recognition failed",
-          ("Stoping recognition failed, error: %d (%s)", ret, get_error_message(ret)));
-    }
-
-    ret = gesture_release(handle);
-    if (GESTURE_ERROR_NONE != ret) {
-      LoggerE("gesture_release() failed");
-    }
-
-    recognition_map.erase(it);
-  }
-
-  return PlatformResult(ErrorCode::NO_ERROR);
-}
-
-}  // namespace humanactivitymonitor
-}  // namespace extension
diff --git a/src/humanactivitymonitor/gesture_manager.h b/src/humanactivitymonitor/gesture_manager.h
deleted file mode 100644 (file)
index 75b05f9..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#ifndef HUMANACTIVITYMONITOR_GESTURE_MANAGER_H
-#define HUMANACTIVITYMONITOR_GESTURE_MANAGER_H
-
-#include <gesture_recognition.h>
-#include <functional>
-#include <string>
-
-#include "common/picojson.h"
-#include "common/platform_result.h"
-
-namespace extension {
-namespace humanactivitymonitor {
-
-using JsonCallback = std::function<void(picojson::value*)>;
-
-typedef std::map<gesture_type_e, gesture_h> RecognitionMap;
-
-class GestureManager {
- public:
-  GestureManager();
-  virtual ~GestureManager();
-
-  common::PlatformResult IsSupported(const std::string& types, bool* is_supported);
-  common::PlatformResult AddGestureRecognitionListener(const std::string& type, bool always_on,
-                                                       JsonCallback cb);
-  common::PlatformResult RemoveGestureRecognitionListener(const std::string& type, bool always_on);
-  void CompleteGestureListenerCb(gesture_type_e gesture, const gesture_data_h data,
-                                 double timestamp, gesture_error_e error, bool always_on);
-
- private:
-  gesture_event_e GetGestureEvent(const gesture_data_h data);
-  void FillTiltData(const gesture_data_h data, picojson::object* obj);
-  common::PlatformResult AddListener(gesture_type_e type, gesture_option_e option,
-                                     RecognitionMap& gesture_map, gesture_recognition_cb callback);
-
-  JsonCallback m_callback;
-  RecognitionMap m_recognition_default_map;
-  RecognitionMap m_recognition_always_on_map;
-};
-
-}  // namespace humanactivitymonitor
-}  // namespace extension
-
-#endif  // HUMANACTIVITYMONITOR_GESTURE_MANAGER_H
index c6b54a0..6c250c1 100755 (executable)
@@ -17,8 +17,6 @@
         'humanactivitymonitor_instance.h',
         'humanactivitymonitor_manager.cc',
         'humanactivitymonitor_manager.h',
-        'gesture_manager.cc',
-        'gesture_manager.h',
       ],
       'conditions': [
         ['tizen == 1', {
index 2271e4a..ab22568 100755 (executable)
@@ -62,71 +62,11 @@ var PedometerStepStatus = {
     UNKNOWN: 'UNKNOWN'
 };
 
-var ActivityRecognitionType = {
-    STATIONARY: 'STATIONARY',
-    WALKING: 'WALKING',
-    RUNNING: 'RUNNING',
-    IN_VEHICLE: 'IN_VEHICLE'
-};
-
-var ActivityAccuracy = {
-    LOW: 'LOW',
-    MEDIUM: 'MEDIUM',
-    HIGH: 'HIGH'
-};
-
 var SleepStatus = {
     ASLEEP: 'ASLEEP',
     AWAKE: 'AWAKE'
 };
 
-var GestureType = {
-    GESTURE_DOUBLE_TAP: 'GESTURE_DOUBLE_TAP',
-    GESTURE_MOVE_TO_EAR: 'GESTURE_MOVE_TO_EAR',
-    GESTURE_NO_MOVE: 'GESTURE_NO_MOVE',
-    GESTURE_PICK_UP: 'GESTURE_PICK_UP',
-    GESTURE_SHAKE: 'GESTURE_SHAKE',
-    GESTURE_SNAP: 'GESTURE_SNAP',
-    GESTURE_TILT: 'GESTURE_TILT',
-    GESTURE_TURN_FACE_DOWN: 'GESTURE_TURN_FACE_DOWN',
-    GESTURE_WRIST_UP: 'GESTURE_WRIST_UP'
-};
-
-function convertActivityData(type, data) {
-    switch (type) {
-    case HumanActivityType.PEDOMETER:
-        return new HumanActivityPedometerData(data);
-    case ACCUMULATIVE_PEDOMETER_DATA:
-        return new HumanActivityAccumulativePedometerData(data);
-    case HumanActivityType.HRM:
-        return new HumanActivityHRMData(data);
-    case HumanActivityType.GPS:
-        var gpsInfo = [];
-        for (var i = 0, max = data.gpsInfo.length; i < max; i++) {
-            gpsInfo.push(new HumanActivityGPSInfo(data.gpsInfo[i]));
-        }
-        return new HumanActivityGPSInfoArray(gpsInfo);
-    case HumanActivityType.SLEEP_MONITOR:
-        return new HumanActivitySleepMonitorData(data);
-    case HumanActivityType.SLEEP_DETECTOR:
-        return new HumanActivitySleepDetectorData(data);
-    case HumanActivityType.STRESS_MONITOR:
-        return new HumanActivityStressMonitorData(data);
-    default:
-        utils_.error('Uknown human activity type: ' + type);
-    }
-}
-
-function createRecorderData(func, data) {
-    var array = [];
-
-    data.forEach(function(d) {
-        array.push(new func(d));
-    });
-
-    return array;
-}
-
 function convertActivityRecorderData(type, data) {
     var func = undefined;
     switch (type) {
@@ -195,61 +135,6 @@ function StressMonitorDataRange(label, min, max) {
     });
 }
 
-function ActivityRecognitionListenerManager() {
-    this.listeners = {};
-    this.nextId = 1;
-    this.nativeSet = false;
-    this.native = native_;
-    this.listenerName = 'ActivityRecognitionListener';
-}
-
-ActivityRecognitionListenerManager.prototype.onListener = function(data) {
-    var watchId = data.watchId;
-
-    if (this.listeners[watchId]) {
-        if (native_.isFailure(data)) {
-            native_.callIfPossible(
-                this.listeners[watchId].errorCallback,
-                native_.getErrorObject(data)
-            );
-            return;
-        }
-
-        native_.callIfPossible(
-            this.listeners[watchId].listener,
-            new HumanActivityRecognitionData(native_.getResultObject(data))
-        );
-    }
-};
-
-ActivityRecognitionListenerManager.prototype.addListener = function(
-    watchId,
-    listener,
-    errorCallback
-) {
-    this.listeners[watchId] = {
-        listener: listener,
-        errorCallback: errorCallback
-    };
-
-    if (!this.nativeSet) {
-        this.native.addListener(this.listenerName, this.onListener.bind(this));
-        this.nativeSet = true;
-    }
-};
-
-ActivityRecognitionListenerManager.prototype.removeListener = function(watchId) {
-    if (this.listeners.hasOwnProperty(watchId)) {
-        delete this.listeners[watchId];
-        if (type_.isEmptyObject(this.listeners)) {
-            this.native.removeListener(this.listenerName);
-            this.nativeSet = false;
-        }
-    }
-};
-
-var activityRecognitionListener = new ActivityRecognitionListenerManager();
-
 function HumanActivityMonitorManager() {}
 
 HumanActivityMonitorManager.prototype.getHumanActivityData = function(
@@ -526,51 +411,19 @@ HumanActivityMonitorManager.prototype.unsetAccumulativePedometerListener = funct
     accumulativePedometerListener = null;
 };
 
-HumanActivityMonitorManager.prototype.addActivityRecognitionListener = function() {
-    utils_.printDeprecationWarningFor(
-        'HumanActivityMonitorManager.addActivityRecognitionListener()'
-    );
-    var args = validator_.validateArgs(arguments, [
-        { name: 'type', type: types_.ENUM, values: Object.keys(ActivityRecognitionType) },
-        { name: 'listener', type: types_.FUNCTION },
-        { name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true }
-    ]);
-
-    var result = native_.call(
-        'HumanActivityMonitorManagerAddActivityRecognitionListener',
-        { type: args.type, listenerId: activityRecognitionListener.listenerName }
-    );
-    if (native_.isFailure(result)) {
-        throw native_.getErrorObject(result);
-    }
-
-    var watchId = result.watchId;
-    activityRecognitionListener.addListener(watchId, args.listener, args.errorCallback);
-
-    return watchId;
-};
-
-HumanActivityMonitorManager.prototype.removeActivityRecognitionListener = function() {
-    utils_.printDeprecationWarningFor(
-        'HumanActivityMonitorManager.removeActivityRecognitionListener()'
+HumanActivityMonitorManager.prototype.addActivityRecognitionListener = function () {
+    throw new WebAPIException(
+        'NotSupportedError',
+        'addActivityRecognitionListener is not longer supported since Tizen 7.0.'
     );
-    var args = validator_.validateArgs(arguments, [
-        { name: 'watchId', type: types_.LONG },
-        { name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true }
-    ]);
+}
 
-    var result = native_.call(
-        'HumanActivityMonitorManagerRemoveActivityRecognitionListener',
-        { watchId: args.watchId }
+HumanActivityMonitorManager.prototype.removeActivityRecognitionListener = function () {
+    throw new WebAPIException(
+        'NotSupportedError',
+        'removeActivityRecognitionListener is not longer supported since Tizen 7.0.'
     );
-    if (native_.isFailure(result)) {
-        setTimeout(function() {
-            native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
-        }, 0);
-        return;
-    }
-    activityRecognitionListener.removeListener(args.watchId);
-};
+}
 
 HumanActivityMonitorManager.prototype.startRecorder = function() {
     var args = validator_.validateArgs(arguments, [
@@ -685,187 +538,24 @@ HumanActivityMonitorManager.prototype.readRecorderData = function() {
 };
 
 HumanActivityMonitorManager.prototype.isGestureSupported = function() {
-    utils_.printDeprecationWarningFor('HumanActivityMonitorManager.isGestureSupported()');
-    var args = validator_.validateArgs(arguments, [
-        {
-            name: 'type',
-            type: types_.ENUM,
-            values: Object.keys(GestureType)
-        }
-    ]);
-
-    var callArgs = {};
-    callArgs.type = args.type;
-
-    var result = native_.callSync('GestureManagerIsGestureSupported', callArgs);
-    if (native_.isFailure(result)) {
-        throw native_.getErrorObject(result);
-    }
-
-    return native_.getResultObject(result);
-};
-
-function GestureListenerManager(native, listenerName) {
-    this.listeners = {};
-    //below maps keep information about number of registered listeners for the specific
-    //type there are two maps as one keeps information about listeners which should be
-    //always called and one keeps information about number of the listeners which should
-    //be called only if power-saving mode is off
-    this.typeCountMapDefault = {};
-    this.typeCountMapAlwaysOn = {};
-    this.nextId = 1;
-    this.nativeSet = false;
-    this.native = native;
-    this.listenerName = listenerName;
-    for (var type in GestureType) {
-        this.typeCountMapDefault[type] = this.typeCountMapAlwaysOn[type] = 0;
-    }
-}
-
-GestureListenerManager.prototype.onListenerCalled = function(msg) {
-    var d = undefined;
-    var result = undefined;
-    var alwaysOn = msg.alwaysOn;
-    switch (msg.action) {
-    case 'ondetect':
-        d = new GestureData(this.native.getResultObject(msg));
-        break;
-    case 'onerror':
-        d = this.native.getErrorObject(msg);
-        break;
-    default:
-        utils_.log('Unknown mode: ' + msg.action);
-        return;
-    }
-
-    for (var watchId in this.listeners) {
-        if (this.listeners.hasOwnProperty(watchId)) {
-            var listener = this.listeners[watchId];
-            var call = alwaysOn ? listener.alwaysOn : true;
-            if (call && listener[msg.action]) {
-                listener[msg.action](d);
-            }
-        }
-    }
-};
-
-GestureListenerManager.prototype.addListener = function(
-    successCb,
-    errorCb,
-    type,
-    alwaysOn
-) {
-    var listener = {
-        type: type,
-        alwaysOn: converter_.toBoolean(alwaysOn),
-        ondetect: successCb,
-        onerror: errorCb
-    };
-
-    var typeCountMap = alwaysOn ? this.typeCountMapAlwaysOn : this.typeCountMapDefault;
-    if (typeCountMap[type] === 0) {
-        var result = this.native.callSync(
-            'GestureManagerAddGestureRecognitionListener',
-            listener
-        );
-        if (this.native.isFailure(result)) {
-            throw this.native.getErrorObject(result);
-        }
-    }
-
-    typeCountMap[type]++;
-    var id = this.nextId++;
-    this.listeners[id] = listener;
-
-    if (!this.nativeSet) {
-        this.native.addListener(this.listenerName, this.onListenerCalled.bind(this));
-        this.nativeSet = true;
-    }
-
-    return id;
-};
-
-GestureListenerManager.prototype.removeListener = function(watchId) {
-    if (this.listeners.hasOwnProperty(watchId)) {
-        var listener = this.listeners[watchId];
-        var typeCountMap = listener.alwaysOn
-            ? this.typeCountMapAlwaysOn
-            : this.typeCountMapDefault;
-
-        if (typeCountMap[listener.type] === 1) {
-            var result = this.native.callSync(
-                'GestureManagerRemoveGestureRecognitionListener',
-                listener
-            );
-            if (this.native.isFailure(result)) {
-                throw this.native.getErrorObject(result);
-            }
-        }
-
-        delete this.listeners[watchId];
-        typeCountMap[listener.type]--;
-    }
-
-    if (this.nativeSet && type_.isEmptyObject(this.listeners)) {
-        this.native.removeListener(this.listenerName);
-        this.nativeSet = false;
-    }
+    throw new WebAPIException(
+        'NotSupportedError',
+        'isGestureSupported is not longer supported since Tizen 7.0.'
+    );
 };
 
-var GESTURE_RECOGNITION_LISTENER = 'GestureRecognitionListener';
-var gestureRecognitionListener = new GestureListenerManager(
-    native_,
-    GESTURE_RECOGNITION_LISTENER
-);
-
 HumanActivityMonitorManager.prototype.addGestureRecognitionListener = function() {
-    utils_.printDeprecationWarningFor(
-        'HumanActivityMonitorManager.addGestureRecognitionListener()'
-    );
-    var args = validator_.validateArgs(arguments, [
-        {
-            name: 'type',
-            type: types_.ENUM,
-            values: Object.keys(GestureType)
-        },
-        {
-            name: 'eventCallback',
-            type: types_.FUNCTION
-        },
-        {
-            name: 'errorCallback',
-            type: types_.FUNCTION,
-            optional: true,
-            nullable: true
-        },
-        {
-            name: 'alwaysOn',
-            type: types_.BOOLEAN,
-            optional: true,
-            nullable: true
-        }
-    ]);
-
-    return gestureRecognitionListener.addListener(
-        args.eventCallback,
-        args.errorCallback,
-        args.type,
-        args.alwaysOn
+    throw new WebAPIException(
+        'NotSupportedError',
+        'addGestureRecognitionListener is not longer supported since Tizen 7.0.'
     );
 };
 
 HumanActivityMonitorManager.prototype.removeGestureRecognitionListener = function() {
-    utils_.printDeprecationWarningFor(
-        'HumanActivityMonitorManager.removeGestureRecognitionListener()'
+    throw new WebAPIException(
+        'NotSupportedError',
+        'removeGestureRecognitionListener is not longer supported since Tizen 7.0.'
     );
-    var args = validator_.validateArgs(arguments, [
-        {
-            name: 'watchId',
-            type: types_.LONG
-        }
-    ]);
-
-    gestureRecognitionListener.removeListener(args.watchId);
 };
 
 function StressMonitorListenerManager() {
@@ -1034,15 +724,6 @@ function HumanActivityHRMData(data) {
 HumanActivityHRMData.prototype = new HumanActivityData();
 HumanActivityHRMData.prototype.constructor = HumanActivityHRMData;
 
-function HumanActivityRecognitionData(data) {
-    SetReadOnlyProperty(this, 'type', data.type);
-    SetReadOnlyProperty(this, 'timestamp', data.timestamp);
-    SetReadOnlyProperty(this, 'accuracy', data.accuracy);
-}
-
-HumanActivityRecognitionData.prototype = new HumanActivityData();
-HumanActivityRecognitionData.prototype.constructor = HumanActivityRecognitionData;
-
 function HumanActivityGPSInfo(data) {
     SetReadOnlyProperty(this, 'latitude', data.latitude);
     SetReadOnlyProperty(this, 'longitude', data.longitude);
@@ -1129,22 +810,6 @@ function HumanActivityRecorderPressureData(data) {
     SetReadOnlyProperty(this, 'average', data.average);
 }
 
-function GestureData(data) {
-    if (data) {
-        SetReadOnlyProperty(this, 'type', data.type);
-        SetReadOnlyProperty(this, 'event', data.event);
-        SetReadOnlyProperty(this, 'timestamp', data.timestamp);
-
-        if (data.type === 'GESTURE_TILT') {
-            SetReadOnlyProperty(this, 'x', data.x);
-            SetReadOnlyProperty(this, 'y', data.y);
-        } else {
-            SetReadOnlyProperty(this, 'x', null);
-            SetReadOnlyProperty(this, 'y', null);
-        }
-    }
-}
-
 HumanActivityRecorderPressureData.prototype = new HumanActivityRecorderData();
 // prettier-ignore
 HumanActivityRecorderPressureData.prototype.constructor =
index 379da36..9ad062b 100644 (file)
@@ -44,10 +44,11 @@ using common::ErrorCode;
 using common::TaskQueue;
 using common::tools::PrintDeprecationWarningFor;
 
-HumanActivityMonitorInstance::HumanActivityMonitorInstance() : gesture_manager_() {
-  ScopeLogger();
-  using std::placeholders::_1;
-  using std::placeholders::_2;
+HumanActivityMonitorInstance::HumanActivityMonitorInstance()
+{
+    ScopeLogger();
+    using std::placeholders::_1;
+    using std::placeholders::_2;
 
 #define REGISTER_METHOD(M) \
   RegisterSyncHandler(#M, std::bind(&HumanActivityMonitorInstance::M, this, _1, _2))
@@ -55,14 +56,9 @@ HumanActivityMonitorInstance::HumanActivityMonitorInstance() : gesture_manager_(
   REGISTER_METHOD(HumanActivityMonitorManagerGetHumanActivityData);
   REGISTER_METHOD(HumanActivityMonitorManagerStart);
   REGISTER_METHOD(HumanActivityMonitorManagerStop);
-  REGISTER_METHOD(HumanActivityMonitorManagerAddActivityRecognitionListener);
-  REGISTER_METHOD(HumanActivityMonitorManagerRemoveActivityRecognitionListener);
   REGISTER_METHOD(HumanActivityMonitorManagerStartRecorder);
   REGISTER_METHOD(HumanActivityMonitorManagerStopRecorder);
   REGISTER_METHOD(HumanActivityMonitorManagerReadRecorderData);
-  REGISTER_METHOD(GestureManagerIsGestureSupported);
-  REGISTER_METHOD(GestureManagerAddGestureRecognitionListener);
-  REGISTER_METHOD(GestureManagerRemoveGestureRecognitionListener);
 
 #undef REGISTER_METHOD
 }
@@ -206,72 +202,6 @@ void HumanActivityMonitorInstance::HumanActivityMonitorManagerStop(const picojso
   }
 }
 
-void HumanActivityMonitorInstance::HumanActivityMonitorManagerAddActivityRecognitionListener(
-    const picojson::value& args, picojson::object& out) {
-  ScopeLogger();
-  PrintDeprecationWarningFor("HumanActivityMonitorManager.addActivityRecognitionListener()");
-
-  CHECK_PRIVILEGE_ACCESS(kPrivilegeHealthInfo, &out);
-  CHECK_EXIST(args, "type", out)
-
-  const auto& type = args.get("type").get<std::string>();
-
-  PlatformResult result = Init();
-  if (!result) {
-    LogAndReportError(result, &out, ("Failed: Init()"));
-    return;
-  }
-
-  const auto& listener_id = args.get("listenerId").get<std::string>();
-
-  JsonCallback cb = [this, listener_id](picojson::value* data) -> void {
-    ScopeLogger("Entered into asynchronous function, cb");
-    if (!data) {
-      LoggerE("No data passed to json callback");
-      return;
-    }
-
-    picojson::object& data_o = data->get<picojson::object>();
-    data_o["listenerId"] = picojson::value(listener_id);
-
-    Instance::PostMessage(this, data->serialize().c_str());
-  };
-
-  long watch_id = 0;
-
-  result = manager_->AddActivityRecognitionListener(type, cb, &watch_id);
-  if (result) {
-    out["watchId"] = picojson::value(static_cast<double>(watch_id));
-    ReportSuccess(out);
-  } else {
-    LogAndReportError(result, &out, ("Failed: manager_->AddActivityRecognitionListener()"));
-  }
-}
-
-void HumanActivityMonitorInstance::HumanActivityMonitorManagerRemoveActivityRecognitionListener(
-    const picojson::value& args, picojson::object& out) {
-  ScopeLogger();
-  PrintDeprecationWarningFor("HumanActivityMonitorManager.removeActivityRecognitionListener()");
-
-  CHECK_PRIVILEGE_ACCESS(kPrivilegeHealthInfo, &out);
-  CHECK_EXIST(args, "watchId", out)
-
-  const long watchId = static_cast<long>(args.get("watchId").get<double>());
-
-  PlatformResult result = Init();
-  if (!result) {
-    LogAndReportError(result, &out, ("Failed: Init()"));
-    return;
-  }
-
-  result = manager_->RemoveActivityRecognitionListener(watchId);
-  if (result) {
-    ReportSuccess(out);
-  } else {
-    LogAndReportError(result, &out, ("Failed: manager_->RemoveActivityRecognitionListener()"));
-  }
-}
-
 void HumanActivityMonitorInstance::HumanActivityMonitorManagerStartRecorder(
     const picojson::value& args, picojson::object& out) {
   ScopeLogger();
@@ -385,69 +315,6 @@ void HumanActivityMonitorInstance::HumanActivityMonitorManagerReadRecorderData(
   ReportSuccess(out);
 }
 
-void HumanActivityMonitorInstance::GestureManagerIsGestureSupported(const picojson::value& args,
-                                                                    picojson::object& out) {
-  ScopeLogger();
-  PrintDeprecationWarningFor("HumanActivityMonitorManager.isGestureSupported()");
-
-  CHECK_EXIST(args, "type", out)
-  const auto& type = args.get("type").get<std::string>();
-  bool is_supported = false;
-
-  PlatformResult result = gesture_manager_.IsSupported(type, &is_supported);
-  if (result) {
-    ReportSuccess(picojson::value(is_supported), out);
-  } else {
-    LogAndReportError(result, &out, ("Failed: gesture_manager_->IsSupported()"));
-  }
-}
-
-void HumanActivityMonitorInstance::GestureManagerAddGestureRecognitionListener(
-    const picojson::value& args, picojson::object& out) {
-  ScopeLogger();
-  PrintDeprecationWarningFor("HumanActivityMonitorManager.addGestureRecognitionListener()");
-
-  CHECK_EXIST(args, "type", out)
-  CHECK_EXIST(args, "alwaysOn", out)
-  const auto& type = args.get("type").get<std::string>();
-  bool always_on = args.get("alwaysOn").get<bool>();
-
-  auto cb = [this](picojson::value* data) -> void {
-    if (!data) {
-      LoggerE("No data passed to json callback");
-      return;
-    }
-
-    Instance::PostMessage(this, data->serialize().c_str());
-  };
-
-  PlatformResult result = gesture_manager_.AddGestureRecognitionListener(type, always_on, cb);
-  if (result) {
-    ReportSuccess(out);
-  } else {
-    LogAndReportError(result, &out, ("Failed: gesture_manager_->AddGestureRecognitionListener()"));
-  }
-}
-
-void HumanActivityMonitorInstance::GestureManagerRemoveGestureRecognitionListener(
-    const picojson::value& args, picojson::object& out) {
-  ScopeLogger();
-  PrintDeprecationWarningFor("HumanActivityMonitorManager.removeGestureRecognitionListener()");
-
-  CHECK_EXIST(args, "type", out)
-  CHECK_EXIST(args, "alwaysOn", out)
-  const auto& type = args.get("type").get<std::string>();
-  bool always_on = args.get("alwaysOn").get<bool>();
-
-  PlatformResult result = gesture_manager_.RemoveGestureRecognitionListener(type, always_on);
-  if (result) {
-    ReportSuccess(out);
-  } else {
-    LogAndReportError(result, &out,
-                      ("Failed: gesture_manager_->RemoveGestureRecognitionListener()"));
-  }
-}
-
 #undef CHECK_EXIST
 
 }  // namespace humanactivitymonitor
index e0ed215..747ea5d 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "common/extension.h"
 #include "common/platform_result.h"
-#include "humanactivitymonitor/gesture_manager.h"
 #include "humanactivitymonitor/humanactivitymonitor_manager.h"
 
 namespace extension {
@@ -36,23 +35,13 @@ class HumanActivityMonitorInstance : public common::ParsedInstance {
   void HumanActivityMonitorManagerStop(const picojson::value& args, picojson::object& out);
   void HumanActivityMonitorManagerGetHumanActivityData(const picojson::value& args,
                                                        picojson::object& out);
-  void HumanActivityMonitorManagerStart(const picojson::value& args, picojson::object& out);
-  void HumanActivityMonitorManagerAddActivityRecognitionListener(const picojson::value& args,
-                                                                 picojson::object& out);
-  void HumanActivityMonitorManagerRemoveActivityRecognitionListener(const picojson::value& args,
-                                                                    picojson::object& out);
+  void HumanActivityMonitorManagerStart(const picojson::value &args, picojson::object &out);
   void HumanActivityMonitorManagerStartRecorder(const picojson::value& args, picojson::object& out);
   void HumanActivityMonitorManagerStopRecorder(const picojson::value& args, picojson::object& out);
-  void HumanActivityMonitorManagerReadRecorderData(const picojson::value& args,
-                                                   picojson::object& out);
-  void GestureManagerIsGestureSupported(const picojson::value& args, picojson::object& out);
-  void GestureManagerAddGestureRecognitionListener(const picojson::value& args,
-                                                   picojson::object& out);
-  void GestureManagerRemoveGestureRecognitionListener(const picojson::value& args,
-                                                      picojson::object& out);
+  void HumanActivityMonitorManagerReadRecorderData(const picojson::value &args,
+                                                   picojson::object &out);
 
   std::shared_ptr<HumanActivityMonitorManager> manager_;
-  GestureManager gesture_manager_;
   common::PlatformResult Init();
 };
 
index 437895a..3e54bee 100644 (file)
@@ -16,8 +16,6 @@
 
 #include "humanactivitymonitor/humanactivitymonitor_manager.h"
 
-#include <activity_recognition.h>
-#include <gesture_recognition.h>
 #include <location_batch.h>
 #include <sensor.h>
 #include <sensor_internal.h>
@@ -1119,203 +1117,6 @@ class HumanActivityMonitorManager::Monitor::GpsMonitor
   location_manager_h handle_;
 };
 
-class HumanActivityMonitorManager::ActivityRecognition {
- public:
-  PlatformResult AddListener(const std::string& type, JsonCallback callback, long* watch_id) {
-    ScopeLogger();
-
-    activity_type_e activity_type = ToActivityType(type);
-    auto result = IsSupported(activity_type);
-
-    if (!result) {
-      return result;
-    }
-
-    activity_h handle = nullptr;
-    // activity_create is deprecated since 6.0
-    int ret = activity_create(&handle);
-    if (ACTIVITY_ERROR_NONE != ret) {
-      return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to create activity",
-                                ("activity_create() error: %d - %s", ret, get_error_message(ret)));
-    }
-
-    const auto id = GetNextId();
-    auto data = std::make_shared<ActivityData>(id, callback, handle);
-
-    ret = activity_start_recognition(handle, activity_type, OnActivityRecognitionEvent, data.get());
-    if (ACTIVITY_ERROR_NONE != ret) {
-      return LogAndCreateResult(
-          ErrorCode::UNKNOWN_ERR, "Failed to start activity recognition",
-          ("activity_start_recognition() error: %d - %s", ret, get_error_message(ret)));
-    }
-
-    activity_data_.insert(std::make_pair(id, data));
-    *watch_id = id;
-
-    return result;
-  }
-
-  PlatformResult RemoveListener(long watch_id) {
-    ScopeLogger();
-
-    const auto it = activity_data_.find(watch_id);
-
-    if (activity_data_.end() != it) {
-      activity_data_.erase(it);
-    }
-
-    return PlatformResult(ErrorCode::NO_ERROR);
-  }
-
- private:
-  struct ActivityData {
-    ActivityData(long id, const JsonCallback& cb, activity_h h)
-        : watch_id(id), callback(cb), handle(h) {
-    }
-
-    ~ActivityData() {
-      if (handle) {
-        // activity_stop_recognition is deprecated since 6.0
-        activity_stop_recognition(handle);
-        // activity_release is deprecated since 6.0
-        activity_release(handle);
-      }
-    }
-
-    long watch_id;
-    JsonCallback callback;
-    activity_h handle;
-  };
-
-  static long GetNextId() {
-    static long id = 0;
-    return ++id;
-  }
-
-  static void OnActivityRecognitionEvent(activity_type_e type, const activity_data_h data,
-                                         double timestamp, activity_error_e callback_error,
-                                         void* user_data) {
-    ScopeLogger();
-
-    auto activity_data = static_cast<ActivityData*>(user_data);
-    JsonCallback callback = activity_data->callback;
-
-    picojson::value val{picojson::object{}};
-    auto& obj = val.get<picojson::object>();
-    obj.insert(
-        std::make_pair("watchId", picojson::value(static_cast<double>(activity_data->watch_id))));
-
-    if (ACTIVITY_ERROR_NONE != callback_error) {
-      LogAndReportError(PlatformResult(ErrorCode::ABORT_ERR, "System operation has failed"), &obj,
-                        ("activity_recognition_cb() has failed with error code %d - %s",
-                         callback_error, get_error_message(callback_error)));
-      callback(&val);
-      return;
-    }
-
-    activity_accuracy_e accuracy = ACTIVITY_ACCURACY_MID;
-
-    // activity_get_accuracy is deprecated since 6.0
-    int ret = activity_get_accuracy(data, &accuracy);
-    if (ret != ACTIVITY_ERROR_NONE) {
-      LogAndReportError(PlatformResult(ErrorCode::ABORT_ERR, "System operation has failed"), &obj,
-                        ("activity_get_accuracy() has failed with error code %d - %s", ret,
-                         get_error_message(ret)));
-      callback(&val);
-      return;
-    }
-    timestamp = std::floor(timestamp);
-    SLoggerD("Activity type: (%d)", type);
-    SLoggerD("Activity accuracy: (%d)", accuracy);
-    SLoggerD("Activity timestamp: (%f)", timestamp);
-
-    picojson::value result{picojson::object{}};
-    auto& result_obj = result.get<picojson::object>();
-
-    result_obj.insert(std::make_pair("type", picojson::value(FromActivityType(type))));
-    result_obj.insert(std::make_pair("accuracy", picojson::value(FromActivityAccuracy(accuracy))));
-    result_obj.insert(std::make_pair(kTimestamp, picojson::value(timestamp)));
-
-    ReportSuccess(result, obj);
-    callback(&val);
-  }
-
-  PlatformResult IsSupported(activity_type_e type) {
-    ScopeLogger();
-
-    bool supported = false;
-    // activity_is_supported is deprecated since 6.0
-    int ret = activity_is_supported(type, &supported);
-
-    if (ret == ACTIVITY_ERROR_NOT_SUPPORTED || !supported) {
-      return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Activity type is not supported",
-                                ("Type %d not supported", type));
-    } else if (ret != ACTIVITY_ERROR_NONE) {
-      return LogAndCreateResult(
-          ErrorCode::UNKNOWN_ERR, "activity_is_supported failed",
-          ("activity_is_supported error %d - %s", ret, get_error_message(ret)));
-    } else {
-      return PlatformResult(ErrorCode::NO_ERROR);
-    }
-  }
-
-#define ACTIVITY_TYPE_E                \
-  X(ACTIVITY_STATIONARY, "STATIONARY") \
-  X(ACTIVITY_WALK, "WALKING")          \
-  X(ACTIVITY_RUN, "RUNNING")           \
-  X(ACTIVITY_IN_VEHICLE, "IN_VEHICLE") \
-  XD(static_cast<activity_type_e>(-1), "unknown")
-
-#define ACTIVITY_ACCURACY_E          \
-  X(ACTIVITY_ACCURACY_LOW, "LOW")    \
-  X(ACTIVITY_ACCURACY_MID, "MEDIUM") \
-  X(ACTIVITY_ACCURACY_HIGH, "HIGH")  \
-  XD(static_cast<activity_accuracy_e>(-1), "unknown")
-
-#define X(v, s) \
-  case v:       \
-    return s;
-#define XD(v, s)                                               \
-  default:                                                     \
-    LoggerE("Unknown value: %d, returning default: %s", e, s); \
-    return s;
-
-  static std::string FromActivityType(activity_type_e e) {
-    ScopeLogger();
-
-    switch (e) { ACTIVITY_TYPE_E }
-  }
-
-  static std::string FromActivityAccuracy(activity_accuracy_e e) {
-    ScopeLogger();
-
-    switch (e) { ACTIVITY_ACCURACY_E }
-  }
-
-#undef X
-#undef XD
-
-#define X(v, s) \
-  if (e == s) return v;
-#define XD(v, s)                                                     \
-  LoggerE("Unknown value: %s, returning default: %d", e.c_str(), v); \
-  return v;
-
-  static activity_type_e ToActivityType(const std::string& e) {
-    ScopeLogger();
-
-    ACTIVITY_TYPE_E
-  }
-
-#undef X
-#undef XD
-
-#undef ACTIVITY_ACCURACY_E
-#undef ACTIVITY_TYPE_E
-
-  std::map<long, std::shared_ptr<ActivityData>> activity_data_;
-};
-
 PlatformResult SleepStateToString(int state, std::string* sleep_state) {
   ScopeLogger("%d", state);
   if (sleep_state) {
@@ -1340,168 +1141,178 @@ PlatformResult SleepStateToString(int state, std::string* sleep_state) {
 }
 
 HumanActivityMonitorManager::HumanActivityMonitorManager()
-    : activity_recognition_(std::make_shared<ActivityRecognition>()) {
-  ScopeLogger();
+{
+    ScopeLogger();
 
-  auto convert_hrm = [](sensor_event_s* event, picojson::object* data) -> PlatformResult {
-    ScopeLogger("Entered into asynchronous function, convert_hrm");
+    auto convert_hrm = [](sensor_event_s *event, picojson::object *data) -> PlatformResult {
+        ScopeLogger("Entered into asynchronous function, convert_hrm");
 
-    LoggerD("Sensor event:");
-    LoggerD("|- accuracy: %d", event->accuracy);
-    LoggerD("|- timestamp: %llu", event->timestamp);
-    LoggerD("|- value_count: %d", event->value_count);
+        LoggerD("Sensor event:");
+        LoggerD("|- accuracy: %d", event->accuracy);
+        LoggerD("|- timestamp: %llu", event->timestamp);
+        LoggerD("|- value_count: %d", event->value_count);
 
-    if (event->value_count < 2) {
-      return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of HRM event");
-    }
+        if (event->value_count < 2)
+        {
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of HRM event");
+        }
 
-    LoggerD("|- values[0][HR ]: %f", event->values[0]);
-    LoggerD("|- values[2][RRI]: %f", event->values[2]);
+        LoggerD("|- values[0][HR ]: %f", event->values[0]);
+        LoggerD("|- values[2][RRI]: %f", event->values[2]);
 
-    float hr = floor(event->values[0] + 0.5);  // heart beat rate 0 ~ 220 integer (bpm)
+        float hr = floor(event->values[0] + 0.5); // heart beat rate 0 ~ 220 integer (bpm)
 
-    // there are no public native api documentation for peak to peak interval.
-    // but RRI = (60 / HR) * 1000
-    // @ 18.05.2018
-    // in capi, rri is in values[2], but it is not documented because value can be unstable
-    // and it is not available on all devices. On solis it works fine.
+        // there are no public native api documentation for peak to peak interval.
+        // but RRI = (60 / HR) * 1000
+        // @ 18.05.2018
+        // in capi, rri is in values[2], but it is not documented because value can be unstable
+        // and it is not available on all devices. On solis it works fine.
 
-    float rri = floor(event->values[2] + 0.5);  // rr-interval 0 ~ 5000 integer (ms)
+        float rri = floor(event->values[2] + 0.5); // rr-interval 0 ~ 5000 integer (ms)
 
-    data->insert(std::make_pair("heartRate", picojson::value(static_cast<double>(hr))));
-    data->insert(std::make_pair("rRInterval", picojson::value(static_cast<double>(rri))));
+        data->insert(std::make_pair("heartRate", picojson::value(static_cast<double>(hr))));
+        data->insert(std::make_pair("rRInterval", picojson::value(static_cast<double>(rri))));
 
-    return PlatformResult(ErrorCode::NO_ERROR);
-  };
+        return PlatformResult(ErrorCode::NO_ERROR);
+    };
 
-  auto convert_sleep = [](sensor_event_s* event, picojson::object* data) -> PlatformResult {
-    ScopeLogger("Entered into asynchronous function, convert_sleep");
+    auto convert_sleep = [](sensor_event_s *event, picojson::object *data) -> PlatformResult {
+        ScopeLogger("Entered into asynchronous function, convert_sleep");
 
-    if (event->value_count < 1) {
-      return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of SLEEP event");
-    }
+        if (event->value_count < 1)
+        {
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of SLEEP event");
+        }
 
-    sensor_sleep_state_e state = static_cast<sensor_sleep_state_e>(event->values[0]);
-    std::string sleep_state;
-    PlatformResult result = SleepStateToString(state, &sleep_state);
-    if (!result) {
-      return result;
-    }
+        sensor_sleep_state_e state = static_cast<sensor_sleep_state_e>(event->values[0]);
+        std::string sleep_state;
+        PlatformResult result = SleepStateToString(state, &sleep_state);
+        if (!result)
+        {
+            return result;
+        }
 
-    data->insert(std::make_pair(kStatus, picojson::value(sleep_state)));
-    data->insert(std::make_pair(
-        kTimestamp, picojson::value(static_cast<double>(getCurrentTimeStamp(event->timestamp)))));
+        data->insert(std::make_pair(kStatus, picojson::value(sleep_state)));
+        data->insert(std::make_pair(
+            kTimestamp, picojson::value(static_cast<double>(getCurrentTimeStamp(event->timestamp)))));
 
-    return PlatformResult(ErrorCode::NO_ERROR);
-  };
+        return PlatformResult(ErrorCode::NO_ERROR);
+    };
 
-  auto convert_sleep_detector = [](sensor_event_s* event,
-                                   picojson::object* data) -> PlatformResult {
-    ScopeLogger("convert_sleep_detector");
+    auto convert_sleep_detector = [](sensor_event_s *event,
+                                     picojson::object *data) -> PlatformResult {
+        ScopeLogger("convert_sleep_detector");
 
-    if (event->value_count < 1) {
-      return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of SLEEP event");
-    }
+        if (event->value_count < 1)
+        {
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of SLEEP event");
+        }
 
-    sensor_sleep_state_e state = static_cast<sensor_sleep_state_e>(event->values[0]);
-    std::string sleep_state;
-    PlatformResult result = SleepStateToString(state, &sleep_state);
-    if (!result) {
-      return result;
-    }
+        sensor_sleep_state_e state = static_cast<sensor_sleep_state_e>(event->values[0]);
+        std::string sleep_state;
+        PlatformResult result = SleepStateToString(state, &sleep_state);
+        if (!result)
+        {
+            return result;
+        }
 
-    data->insert(std::make_pair(kStatus, picojson::value(sleep_state)));
+        data->insert(std::make_pair(kStatus, picojson::value(sleep_state)));
 
-    return PlatformResult(ErrorCode::NO_ERROR);
-  };
+        return PlatformResult(ErrorCode::NO_ERROR);
+    };
 
-  auto convert_stress = [](sensor_event_s* event, picojson::object* data) -> PlatformResult {
-    ScopeLogger("convert_stress");
+    auto convert_stress = [](sensor_event_s *event, picojson::object *data) -> PlatformResult {
+        ScopeLogger("convert_stress");
 
-    if (event->value_count < 1) {
-      return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of STRESS event");
-    }
+        if (event->value_count < 1)
+        {
+            return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of STRESS event");
+        }
 
-    float stress_score = event->values[0];
-    data->insert(std::make_pair(kStressScore, picojson::value(static_cast<double>(stress_score))));
+        float stress_score = event->values[0];
+        data->insert(std::make_pair(kStressScore, picojson::value(static_cast<double>(stress_score))));
 
-    return PlatformResult(ErrorCode::NO_ERROR);
-  };
+        return PlatformResult(ErrorCode::NO_ERROR);
+    };
 
-  auto convert_recorded_hrm = [](void* data, picojson::object* obj) -> PlatformResult {
-    ScopeLogger("Entered into asynchronous function, convert_recorded_hrm");
+    auto convert_recorded_hrm = [](void *data, picojson::object *obj) -> PlatformResult {
+        ScopeLogger("Entered into asynchronous function, convert_recorded_hrm");
 
-    SensorRecorderDataMap map_int{
-        {SENSOR_RECORDER_DATA_HEART_RATE, kRecordedHeartRate},
-    };
+        SensorRecorderDataMap map_int{
+            {SENSOR_RECORDER_DATA_HEART_RATE, kRecordedHeartRate},
+        };
 
-    auto result = ConvertRecordedInt(data, obj, map_int);
-    if (!result) {
-      return result;
-    }
+        auto result = ConvertRecordedInt(data, obj, map_int);
+        if (!result)
+        {
+            return result;
+        }
 
-    return ConvertRecordedTime(data, obj);
-  };
+        return ConvertRecordedTime(data, obj);
+    };
 
-  auto convert_recorded_sleep_monitor = [](void* data, picojson::object* obj) -> PlatformResult {
-    ScopeLogger("Entered into asynchronous function, convert_recorded_sleep_monitor");
+    auto convert_recorded_sleep_monitor = [](void *data, picojson::object *obj) -> PlatformResult {
+        ScopeLogger("Entered into asynchronous function, convert_recorded_sleep_monitor");
 
-    int state = 0;
-    int ret = sensor_recorder_data_get_int(data, SENSOR_RECORDER_DATA_SLEEP_STATE, &state);
-    if (SENSOR_ERROR_NONE != ret) {
-      return LogAndCreateResult(
-          getErrorCode(ret), "Failed to get int value",
-          ("Failed to get int value, error: %d (%s)", ret, get_error_message(ret)));
-    }
+        int state = 0;
+        int ret = sensor_recorder_data_get_int(data, SENSOR_RECORDER_DATA_SLEEP_STATE, &state);
+        if (SENSOR_ERROR_NONE != ret)
+        {
+            return LogAndCreateResult(
+                getErrorCode(ret), "Failed to get int value",
+                ("Failed to get int value, error: %d (%s)", ret, get_error_message(ret)));
+        }
 
-    std::string sleep_state;
-    PlatformResult result = SleepStateToString(state, &sleep_state);
-    if (!result) {
-      return result;
-    }
+        std::string sleep_state;
+        PlatformResult result = SleepStateToString(state, &sleep_state);
+        if (!result)
+        {
+            return result;
+        }
 
-    obj->insert(std::make_pair(kStatus, picojson::value(sleep_state)));
+        obj->insert(std::make_pair(kStatus, picojson::value(sleep_state)));
 
-    return ConvertRecordedTime(data, obj);
-  };
+        return ConvertRecordedTime(data, obj);
+    };
 
-  auto convert_recorded_pressure = [](void* data, picojson::object* obj) -> PlatformResult {
-    ScopeLogger("Entered into asynchronous function, convert_recorded_pressure");
+    auto convert_recorded_pressure = [](void *data, picojson::object *obj) -> PlatformResult {
+        ScopeLogger("Entered into asynchronous function, convert_recorded_pressure");
 
-    SensorRecorderDataMap map_double{{SENSOR_RECORDER_DATA_MAX_PRESSURE, kRecordedMax},
-                                     {SENSOR_RECORDER_DATA_MIN_PRESSURE, kRecordedMin},
-                                     {SENSOR_RECORDER_DATA_AVERAGE_PRESSURE, kRecordedAverage}};
+        SensorRecorderDataMap map_double{{SENSOR_RECORDER_DATA_MAX_PRESSURE, kRecordedMax},
+                                         {SENSOR_RECORDER_DATA_MIN_PRESSURE, kRecordedMin},
+                                         {SENSOR_RECORDER_DATA_AVERAGE_PRESSURE, kRecordedAverage}};
 
-    auto result = ConvertRecordedDouble(data, obj, map_double);
-    if (!result) {
-      return result;
-    }
+        auto result = ConvertRecordedDouble(data, obj, map_double);
+        if (!result)
+        {
+            return result;
+        }
 
-    return ConvertRecordedTime(data, obj);
-  };
-
-  monitors_.insert(
-      std::make_pair(kActivityTypePedometer, std::make_shared<Monitor::PedometerMonitor>()));
-  monitors_.insert(std::make_pair(kActivityTypeSleepDetector,
-                                  std::make_shared<Monitor::SensorMonitor>(
-                                      kActivityTypeSleepDetector, SENSOR_HUMAN_SLEEP_DETECTOR,
-                                      convert_sleep_detector, nullptr)));
-  monitors_.insert(std::make_pair(
-      kActivityTypeStressMonitor,
-      std::make_shared<Monitor::SensorMonitor>(
-          kActivityTypeStressMonitor, SENSOR_HUMAN_STRESS_MONITOR, convert_stress, nullptr)));
-  monitors_.insert(std::make_pair(
-      kActivityTypeHrm, std::make_shared<Monitor::SensorMonitor>(
-                            kActivityTypeHrm, SENSOR_HRM, convert_hrm, convert_recorded_hrm)));
-  monitors_.insert(
-      std::make_pair(kActivityTypeGps, std::make_shared<Monitor::GpsMonitor>(kActivityTypeGps)));
-  monitors_.insert(std::make_pair(kActivityTypeSleepMonitor,
-                                  std::make_shared<Monitor::SensorMonitor>(
-                                      kActivityTypeSleepMonitor, SENSOR_HUMAN_SLEEP_MONITOR,
-                                      convert_sleep, convert_recorded_sleep_monitor)));
-  monitors_.insert(std::make_pair(kActivityTypePressure, std::make_shared<Monitor::SensorMonitor>(
-                                                             kActivityTypePressure, SENSOR_PRESSURE,
-                                                             nullptr, convert_recorded_pressure)));
+        return ConvertRecordedTime(data, obj);
+    };
+
+    monitors_.insert(
+        std::make_pair(kActivityTypePedometer, std::make_shared<Monitor::PedometerMonitor>()));
+    monitors_.insert(std::make_pair(kActivityTypeSleepDetector,
+                                    std::make_shared<Monitor::SensorMonitor>(
+                                        kActivityTypeSleepDetector, SENSOR_HUMAN_SLEEP_DETECTOR,
+                                        convert_sleep_detector, nullptr)));
+    monitors_.insert(std::make_pair(
+        kActivityTypeStressMonitor,
+        std::make_shared<Monitor::SensorMonitor>(
+            kActivityTypeStressMonitor, SENSOR_HUMAN_STRESS_MONITOR, convert_stress, nullptr)));
+    monitors_.insert(std::make_pair(
+        kActivityTypeHrm, std::make_shared<Monitor::SensorMonitor>(
+                              kActivityTypeHrm, SENSOR_HRM, convert_hrm, convert_recorded_hrm)));
+    monitors_.insert(
+        std::make_pair(kActivityTypeGps, std::make_shared<Monitor::GpsMonitor>(kActivityTypeGps)));
+    monitors_.insert(std::make_pair(kActivityTypeSleepMonitor,
+                                    std::make_shared<Monitor::SensorMonitor>(
+                                        kActivityTypeSleepMonitor, SENSOR_HUMAN_SLEEP_MONITOR,
+                                        convert_sleep, convert_recorded_sleep_monitor)));
+    monitors_.insert(std::make_pair(kActivityTypePressure, std::make_shared<Monitor::SensorMonitor>(
+                                                               kActivityTypePressure, SENSOR_PRESSURE,
+                                                               nullptr, convert_recorded_pressure)));
 }
 
 HumanActivityMonitorManager::~HumanActivityMonitorManager() {
@@ -1535,18 +1346,6 @@ PlatformResult HumanActivityMonitorManager::GetHumanActivityData(const std::stri
   return GetMonitor(type)->GetData(data);
 }
 
-PlatformResult HumanActivityMonitorManager::AddActivityRecognitionListener(const std::string& type,
-                                                                           JsonCallback callback,
-                                                                           long* watch_id) {
-  ScopeLogger();
-  return activity_recognition_->AddListener(type, callback, watch_id);
-}
-
-PlatformResult HumanActivityMonitorManager::RemoveActivityRecognitionListener(const long watch_id) {
-  ScopeLogger();
-  return activity_recognition_->RemoveListener(watch_id);
-}
-
 PlatformResult HumanActivityMonitorManager::StartDataRecorder(const std::string& type, int interval,
                                                               int retention_period) {
   ScopeLogger();
index 0db67d1..44eb8de 100644 (file)
@@ -46,9 +46,6 @@ class HumanActivityMonitorManager {
   common::PlatformResult UnsetListener(const std::string& type);
   common::PlatformResult GetHumanActivityData(const std::string& type, picojson::value* data);
 
-  common::PlatformResult AddActivityRecognitionListener(const std::string& type,
-                                                        JsonCallback callback, long* watch_id);
-  common::PlatformResult RemoveActivityRecognitionListener(const long watchId);
   common::PlatformResult StartDataRecorder(const std::string& type, int interval,
                                            int retention_period);
   common::PlatformResult StopDataRecorder(const std::string& type);
@@ -62,7 +59,6 @@ class HumanActivityMonitorManager {
   std::shared_ptr<Monitor> GetMonitor(const std::string& type);
 
   std::map<std::string, std::shared_ptr<Monitor>> monitors_;
-  std::shared_ptr<ActivityRecognition> activity_recognition_;
 };
 
 }  // namespace humanactivitymonitor