var HumanActivityType = {
PEDOMETER: 'PEDOMETER',
- WRIST_UP: 'WRIST_UP',
HRM: 'HRM',
GPS: 'GPS',
SLEEP_MONITOR: 'SLEEP_MONITOR',
return new HumanActivityPedometerData(data);
case ACCUMULATIVE_PEDOMETER_DATA:
return new HumanActivityAccumulativePedometerData(data);
- case HumanActivityType.WRIST_UP:
- return null;
case HumanActivityType.HRM:
return new HumanActivityHRMData(data);
case HumanActivityType.GPS:
{ name: 'options', type: types_.DICTIONARY, optional: true, nullable: true }
]);
- if (HumanActivityType.WRIST_UP === args.type) {
- utils_.warn(
- 'DEPRECATION WARNING: HumanActivityType.WRIST_UP is deprecated since ' +
- 'Tizen 4.0.'
- );
- }
-
if (HumanActivityType.STRESS_MONITOR == args.type) {
utils_.printDeprecationWarningFor(HumanActivityType.STRESS_MONITOR);
}
{ name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityType) }
]);
- if (HumanActivityType.WRIST_UP === args.type) {
- utils_.warn(
- 'DEPRECATION WARNING: HumanActivityType.WRIST_UP is deprecated since ' +
- 'Tizen 4.0. Use GestureType and addGestureRecognitionListener to ' +
- 'monitor WRIST_UP gesture'
- );
- }
-
if (HumanActivityType.STRESS_MONITOR == args.type) {
utils_.printDeprecationWarningFor(HumanActivityType.STRESS_MONITOR);
}
namespace {
const std::string kActivityTypePedometer = "PEDOMETER";
-const std::string kActivityTypeWristUp = "WRIST_UP";
const std::string kActivityTypeHrm = "HRM";
const std::string kActivityTypeSleepMonitor = "SLEEP_MONITOR";
const std::string kActivityTypePressure = "PRESSURE";
class HumanActivityMonitorManager::Monitor {
public:
- class GestureMonitor;
class SensorMonitor;
class GpsMonitor;
class PedometerMonitor;
JsonCallback event_callback_;
};
-class HumanActivityMonitorManager::Monitor::GestureMonitor
- : public HumanActivityMonitorManager::Monitor {
- public:
- explicit GestureMonitor(const std::string& t) : Monitor(t), handle_(nullptr) {
- ScopeLogger("type %s", type().c_str());
- }
-
- virtual ~GestureMonitor() override {
- ScopeLogger("type %s", type().c_str());
- UnsetListenerImpl();
- }
-
- protected:
- virtual PlatformResult IsSupportedImpl(bool* s) const override {
- ScopeLogger("type %s", type().c_str());
-
- bool supported = false;
-
- // gesture_is_supported is deprecated since 6.0
- int ret = gesture_is_supported(GESTURE_WRIST_UP, &supported);
- if (GESTURE_ERROR_NONE != ret) {
- if (ret == GESTURE_ERROR_NOT_SUPPORTED) {
- return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "WRIST_UP gesture check failed",
- ("gesture_is_supported(GESTURE_WRIST_UP), error: %d (%s)", ret,
- get_error_message(ret)));
- } else {
- return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "WRIST_UP gesture check failed",
- ("gesture_is_supported(GESTURE_WRIST_UP), error: %d (%s)", ret,
- get_error_message(ret)));
- }
- }
-
- *s = supported;
- return PlatformResult(ErrorCode::NO_ERROR);
- }
-
- virtual PlatformResult SetListenerImpl(const picojson::value&) override {
- ScopeLogger("type %s", type().c_str());
-
- if (!handle_) {
- // gesture_create is not supported since 6.0
- int ret = gesture_create(&handle_);
- if (GESTURE_ERROR_NONE != ret) {
- return LogAndCreateResult(
- ErrorCode::UNKNOWN_ERR, "Failed to create WRIST_UP listener",
- ("Failed to create WRIST_UP handle, error: %d (%s)", ret, get_error_message(ret)));
- }
-
- // gesture_start_recognition is not supported since 6.0
- ret = gesture_start_recognition(handle_, GESTURE_WRIST_UP, GESTURE_OPTION_DEFAULT,
- OnWristUpEvent, this);
- if (GESTURE_ERROR_NONE != ret) {
- return LogAndCreateResult(
- ErrorCode::UNKNOWN_ERR, "Failed to start WRIST_UP listener",
- ("Failed to start WRIST_UP listener, error: %d (%s)", ret, get_error_message(ret)));
- }
- }
-
- return PlatformResult(ErrorCode::NO_ERROR);
- }
-
- virtual PlatformResult UnsetListenerImpl() override {
- ScopeLogger("type %s", type().c_str());
-
- if (handle_) {
- // gesture_stop_recognition is deprecated since 6.0
- int ret = gesture_stop_recognition(handle_);
- if (GESTURE_ERROR_NONE != ret) {
- LoggerE("Failed to stop WRIST_UP detection, error: %d", ret);
- }
-
- // gesture_release is deprecated since 6.0
- ret = gesture_release(handle_);
- if (GESTURE_ERROR_NONE != ret) {
- LoggerE("Failed to release WRIST_UP handle, error: %d", ret);
- }
-
- handle_ = nullptr;
- }
-
- return PlatformResult(ErrorCode::NO_ERROR);
- }
-
- // GetData is not supported by gesture monitor
-
- private:
- static void OnWristUpEvent(gesture_type_e gesture, const gesture_data_h data, double timestamp,
- gesture_error_e error, void* user_data) {
- ScopeLogger();
-
- auto monitor = static_cast<GestureMonitor*>(user_data);
- auto& callback = monitor->event_callback();
-
- if (!callback) {
- LoggerE("No WRIST_UP event callback registered, skipping.");
- return;
- }
-
- picojson::value v = picojson::value(picojson::object());
- callback(&v);
- }
-
- gesture_h handle_;
-};
-
class HumanActivityMonitorManager::Monitor::SensorMonitor
: public HumanActivityMonitorManager::Monitor {
public:
monitors_.insert(
std::make_pair(kActivityTypePedometer, std::make_shared<Monitor::PedometerMonitor>()));
- monitors_.insert(std::make_pair(kActivityTypeWristUp,
- std::make_shared<Monitor::GestureMonitor>(kActivityTypeWristUp)));
monitors_.insert(std::make_pair(kActivityTypeSleepDetector,
std::make_shared<Monitor::SensorMonitor>(
kActivityTypeSleepDetector, SENSOR_HUMAN_SLEEP_DETECTOR,