Merge branch 'tizen_4.0' into tizen_5.0
[platform/core/api/webapi-plugins.git] / src / humanactivitymonitor / humanactivitymonitor_api.js
index a8ebf7b..8397d1a 100755 (executable)
@@ -26,11 +26,11 @@ var callbackId = 0;
 var callbacks = {};
 
 function nextCallbackId() {
-  return callbackId++;
+    return callbackId++;
 }
 
 function SetReadOnlyProperty(obj, n, v) {
-  Object.defineProperty(obj, n, {value: v, writable: false});
+    Object.defineProperty(obj, n, { value: v, writable: false });
 }
 
 var ACCUMULATIVE_PEDOMETER_DATA = 'ACCUMULATIVE_PEDOMETER_DATA';
@@ -40,279 +40,296 @@ var MIN_QUERY_TIME = 0;
 var MIN_QUERY_INTERVAL = 0;
 
 var HumanActivityType = {
-  PEDOMETER: 'PEDOMETER',
-  WRIST_UP: 'WRIST_UP',
-  HRM: 'HRM',
-  GPS: 'GPS',
-  SLEEP_MONITOR: 'SLEEP_MONITOR',
-  SLEEP_DETECTOR: 'SLEEP_DETECTOR',
-  STRESS_MONITOR: 'STRESS_MONITOR'
+    PEDOMETER: 'PEDOMETER',
+    WRIST_UP: 'WRIST_UP',
+    HRM: 'HRM',
+    GPS: 'GPS',
+    SLEEP_MONITOR: 'SLEEP_MONITOR',
+    SLEEP_DETECTOR: 'SLEEP_DETECTOR',
+    STRESS_MONITOR: 'STRESS_MONITOR'
 };
 
 var HumanActivityRecorderType = {
-  PEDOMETER: 'PEDOMETER',
-  HRM: 'HRM',
-  SLEEP_MONITOR: 'SLEEP_MONITOR',
-  PRESSURE: 'PRESSURE'
+    PEDOMETER: 'PEDOMETER',
+    HRM: 'HRM',
+    SLEEP_MONITOR: 'SLEEP_MONITOR',
+    PRESSURE: 'PRESSURE'
 };
 
 var PedometerStepStatus = {
-  NOT_MOVING: 'NOT_MOVING',
-  WALKING: 'WALKING',
-  RUNNING: 'RUNNING',
-  UNKNOWN: 'UNKNOWN'
+    NOT_MOVING: 'NOT_MOVING',
+    WALKING: 'WALKING',
+    RUNNING: 'RUNNING',
+    UNKNOWN: 'UNKNOWN'
 };
 
 var ActivityRecognitionType = {
-  STATIONARY: 'STATIONARY',
-  WALKING: 'WALKING',
-  RUNNING: 'RUNNING',
-  IN_VEHICLE: 'IN_VEHICLE'
+    STATIONARY: 'STATIONARY',
+    WALKING: 'WALKING',
+    RUNNING: 'RUNNING',
+    IN_VEHICLE: 'IN_VEHICLE'
 };
 
 var ActivityAccuracy = {
-  LOW: 'LOW',
-  MEDIUM: 'MEDIUM',
-  HIGH: 'HIGH'
+    LOW: 'LOW',
+    MEDIUM: 'MEDIUM',
+    HIGH: 'HIGH'
 };
 
 var SleepStatus = {
-  ASLEEP: 'ASLEEP',
-  AWAKE: 'AWAKE'
+    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',
+    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) {
+    switch (type) {
     case HumanActivityType.PEDOMETER:
-      return new HumanActivityPedometerData(data);
+        return new HumanActivityPedometerData(data);
     case ACCUMULATIVE_PEDOMETER_DATA:
-      return new HumanActivityAccumulativePedometerData(data);
+        return new HumanActivityAccumulativePedometerData(data);
     case HumanActivityType.WRIST_UP:
-      return null;
+        return null;
     case HumanActivityType.HRM:
-      return new HumanActivityHRMData(data);
+        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);
+        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);
+        return new HumanActivitySleepMonitorData(data);
     case HumanActivityType.SLEEP_DETECTOR:
-      return new HumanActivitySleepDetectorData(data);
+        return new HumanActivitySleepDetectorData(data);
     case HumanActivityType.STRESS_MONITOR:
-      return new HumanActivityStressMonitorData(data);
+        return new HumanActivityStressMonitorData(data);
     default:
-      utils_.error('Uknown human activity type: ' + type);
-  }
+        utils_.error('Uknown human activity type: ' + type);
+    }
 }
 
 function createRecorderData(func, data) {
-  var array = [];
+    var array = [];
 
-  data.forEach(function (d) {
-    array.push(new func(d));
-  });
+    data.forEach(function(d) {
+        array.push(new func(d));
+    });
 
-  return array;
+    return array;
 }
 
 function convertActivityRecorderData(type, data) {
-  var func = undefined;
-  switch (type) {
+    var func = undefined;
+    switch (type) {
     case HumanActivityRecorderType.PEDOMETER:
-      func = HumanActivityRecorderPedometerData;
-      break;
+        func = HumanActivityRecorderPedometerData;
+        break;
     case HumanActivityRecorderType.HRM:
-      func = HumanActivityRecorderHRMData;
-      break;
+        func = HumanActivityRecorderHRMData;
+        break;
     case HumanActivityRecorderType.SLEEP_MONITOR:
-      func = HumanActivityRecorderSleepMonitorData;
-      break;
+        func = HumanActivityRecorderSleepMonitorData;
+        break;
     case HumanActivityRecorderType.PRESSURE:
-      func = HumanActivityRecorderPressureData;
-      break;
+        func = HumanActivityRecorderPressureData;
+        break;
     default:
-      utils_.error('Uknown human activity recorder type: ' + type);
-      return;
-  }
+        utils_.error('Uknown human activity recorder type: ' + type);
+        return;
+    }
 
-  return createRecorderData(func, data);
+    return createRecorderData(func, data);
 }
 
 function StressMonitorDataRange(label, min, max) {
-  validator_.validateConstructorCall(this, tizen.StressMonitorDataRange);
-
-  var args = validator_.validateArgs(arguments, [
-      { name: 'label', type: types_.STRING, optional: true, nullable: false },
-      { name: 'min', type: types_.UNSIGNED_LONG, optional: true, nullable: false },
-      { name: 'max', type: types_.UNSIGNED_LONG, optional: true, nullable: false }
-  ]);
-
-  var _label = !type_.isNullOrUndefined(args.label) ? args.label : "";
-  var _min = !type_.isNullOrUndefined(args.min) ? args.min : 0;
-  var _max = !type_.isNull(args.max) ? args.max : undefined;
-
-  Object.defineProperties(this, {
-    label: {
-      get: function() {
-        return _label;
-      },
-      set: function(v) {
-        _label = !type_.isNullOrUndefined(v) ? v : _label;
-      },
-      enumerable: true
-    },
-    min: {
-      get: function() {
-        return _min;
-      },
-      set: function(v) {
-        _min = !type_.isNullOrUndefined(v) ? converter_.toUnsignedLong(v) : _min;
-      },
-      enumerable: true
-    },
-    max: {
-      get: function() {
-        return _max;
-      },
-      set: function(v) {
-        _max = !type_.isNullOrUndefined(v) ? converter_.toUnsignedLong(v) : _max;
-      },
-      enumerable: true
-    }
-  });
-};
-
+    validator_.validateConstructorCall(this, tizen.StressMonitorDataRange);
+
+    var args = validator_.validateArgs(arguments, [
+        { name: 'label', type: types_.STRING, optional: true, nullable: false },
+        { name: 'min', type: types_.UNSIGNED_LONG, optional: true, nullable: false },
+        { name: 'max', type: types_.UNSIGNED_LONG, optional: true, nullable: false }
+    ]);
+
+    var _label = !type_.isNullOrUndefined(args.label) ? args.label : '';
+    var _min = !type_.isNullOrUndefined(args.min) ? args.min : 0;
+    var _max = !type_.isNull(args.max) ? args.max : undefined;
+
+    Object.defineProperties(this, {
+        label: {
+            get: function() {
+                return _label;
+            },
+            set: function(v) {
+                _label = !type_.isNullOrUndefined(v) ? v : _label;
+            },
+            enumerable: true
+        },
+        min: {
+            get: function() {
+                return _min;
+            },
+            set: function(v) {
+                _min = !type_.isNullOrUndefined(v) ? converter_.toUnsignedLong(v) : _min;
+            },
+            enumerable: true
+        },
+        max: {
+            get: function() {
+                return _max;
+            },
+            set: function(v) {
+                _max = !type_.isNullOrUndefined(v) ? converter_.toUnsignedLong(v) : _max;
+            },
+            enumerable: true
+        }
+    });
+}
 
 function ActivityRecognitionListenerManager() {
-  this.listeners = {};
-  this.nextId = 1;
-  this.nativeSet = false;
-  this.native = native_;
-  this.listenerName = 'ActivityRecognitionListener';
-};
+    this.listeners = {};
+    this.nextId = 1;
+    this.nativeSet = false;
+    this.native = native_;
+    this.listenerName = 'ActivityRecognitionListener';
+}
 
 ActivityRecognitionListenerManager.prototype.onListener = function(data) {
-  var watchId = data.watchId;
+    var watchId = data.watchId;
+
+    if (this.listeners[watchId]) {
+        if (native_.isFailure(data)) {
+            native_.callIfPossible(
+                this.listeners[watchId].errorCallback,
+                native_.getErrorObject(data)
+            );
+            return;
+        }
 
-  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))
+        );
     }
-
-    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
-  };
+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;
-  }
+    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;
+    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() {
-}
+function HumanActivityMonitorManager() {}
+
+HumanActivityMonitorManager.prototype.getHumanActivityData = function(
+    type,
+    successCallback,
+    errorCallback
+) {
+    var args = validator_.validateArgs(arguments, [
+        { name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityType) },
+        { name: 'successCallback', type: types_.FUNCTION },
+        { name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true }
+    ]);
+
+    if (-1 === [HumanActivityType.HRM, HumanActivityType.PEDOMETER].indexOf(args.type)) {
+        throw new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR);
+    }
 
-HumanActivityMonitorManager.prototype.getHumanActivityData = function(type, successCallback, errorCallback) {
-  var args = validator_.validateArgs(arguments, [
-    {name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityType)},
-    {name: 'successCallback', type: types_.FUNCTION},
-    {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
-  ]);
+    var data = {
+        type: args.type
+    };
 
-  if (-1 === [HumanActivityType.HRM, HumanActivityType.PEDOMETER].indexOf(args.type)) {
-    throw new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR);
-  }
+    var callback = function(result) {
+        if (native_.isFailure(result)) {
+            native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
+            return;
+        }
 
-  var data = {
-    type: args.type
-  };
+        native_.callIfPossible(
+            args.successCallback,
+            convertActivityData(args.type, native_.getResultObject(result))
+        );
+    };
+
+    var result = native_.call(
+        'HumanActivityMonitorManager_getHumanActivityData',
+        data,
+        callback
+    );
 
-  var callback = function(result) {
     if (native_.isFailure(result)) {
-      native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
-      return;
+        throw native_.getErrorObject(result);
     }
-
-    native_.callIfPossible(args.successCallback,
-        convertActivityData(args.type, native_.getResultObject(result)));
-  };
-
-  var result = native_.call('HumanActivityMonitorManager_getHumanActivityData', data, callback);
-
-  if (native_.isFailure(result)) {
-    throw native_.getErrorObject(result);
-  }
 };
 
 function startListener(listenerId, listener, method, data) {
-  if (!native_.isListenerSet(listenerId)) {
-    var result = native_.callSync(method, data);
-    if (native_.isFailure(result)) {
-      throw native_.getErrorObject(result);
+    if (!native_.isListenerSet(listenerId)) {
+        var result = native_.callSync(method, data);
+        if (native_.isFailure(result)) {
+            throw native_.getErrorObject(result);
+        }
     }
-  }
 
-  // always set the listener, if it's another call to startListener() overwrite the old one
-  native_.addListener(listenerId, listener);
+    // always set the listener
+    // if it's another call to startListener() overwrite the old one
+    native_.addListener(listenerId, listener);
 }
 
 function checkPrivilegesForMethod(method, type) {
-  utils_.checkPrivilegeAccess(utils_.privilege.HEALTHINFO);
-  if ('HumanActivityMonitorManager_stop' === method && 'GPS' === type) {
-    utils_.checkPrivilegeAccess(utils_.privilege.LOCATION);
-  }
+    utils_.checkPrivilegeAccess(utils_.privilege.HEALTHINFO);
+    if ('HumanActivityMonitorManager_stop' === method && 'GPS' === type) {
+        utils_.checkPrivilegeAccess(utils_.privilege.LOCATION);
+    }
 }
 
 function stopListener(listenerId, method, data, doRemoval) {
-  if (!native_.isListenerSet(listenerId)) {
-    checkPrivilegesForMethod(method, data.type);
-    return;
-  }
-
-  if (doRemoval) {
-    var result = native_.callSync(method, data);
-    if (native_.isFailure(result)) {
-      throw native_.getErrorObject(result);
+    if (!native_.isListenerSet(listenerId)) {
+        checkPrivilegesForMethod(method, data.type);
+        return;
     }
 
-    native_.removeListener(listenerId);
-  }
+    if (doRemoval) {
+        var result = native_.callSync(method, data);
+        if (native_.isFailure(result)) {
+            throw native_.getErrorObject(result);
+        }
+
+        native_.removeListener(listenerId);
+    }
 }
 
 // Pedometer listener and accumulative pedometer listener are handled by a single
@@ -322,673 +339,792 @@ var pedometerListener = null;
 var accumulativePedometerListener = null;
 
 function pedometerCallback(result) {
-  if (pedometerListener) {
-    pedometerListener(convertActivityData(HumanActivityType.PEDOMETER, result));
-  }
+    if (pedometerListener) {
+        pedometerListener(convertActivityData(HumanActivityType.PEDOMETER, result));
+    }
 
-  if (accumulativePedometerListener) {
-    accumulativePedometerListener(convertActivityData(ACCUMULATIVE_PEDOMETER_DATA, result));
-  }
+    if (accumulativePedometerListener) {
+        accumulativePedometerListener(
+            convertActivityData(ACCUMULATIVE_PEDOMETER_DATA, result)
+        );
+    }
 }
 
 var GPSListener = null;
 function GPSCallback(result) {
-  if (GPSListener) {
-    GPSListener(result);
-  }
+    if (GPSListener) {
+        GPSListener(result);
+    }
 }
 
 var stressListener = null;
 
 HumanActivityMonitorManager.prototype.start = function(type, changedCallback) {
-  var args = validator_.validateArgs(arguments, [
-    {name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityType)},
-    {name: 'changedCallback', type: types_.FUNCTION, optional: true, nullable: true},
-    {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true},
-    {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. '
-                     + 'Use GestureType and addGestureRecognitionListener to monitor WRIST_UP gesture');
-  }
-
-  var listenerId = 'HumanActivityMonitor_' + args.type;
-  var optionsAttributes = ["callbackInterval", "sampleInterval"], options = args.options || {};
-
-  var callbackInterval = null, sampleInterval = null;
-
-  switch (args.type) {
-  case HumanActivityType.GPS:
-    callbackInterval = !type_.isNullOrUndefined(options[optionsAttributes[0]]) ?
-        options[optionsAttributes[0]] : 150000;
-    sampleInterval = !type_.isNullOrUndefined(options[optionsAttributes[1]]) ?
-        options[optionsAttributes[1]] : 1000;
-    break;
-  case HumanActivityType.HRM:
-    callbackInterval = !type_.isNullOrUndefined(options[optionsAttributes[0]]) ?
-        options[optionsAttributes[0]] : 100;
-    if (callbackInterval < 10 || callbackInterval > 1000) {
-      throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
-                                'callbackInterval is out of range');
-    }
-    break;
-  }
-
-  var listener = null;
-  switch (args.type) {
+    var args = validator_.validateArgs(arguments, [
+        { name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityType) },
+        {
+            name: 'changedCallback',
+            type: types_.FUNCTION,
+            optional: true,
+            nullable: true
+        },
+        { name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true },
+        { 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. Use GestureType and addGestureRecognitionListener to ' +
+                'monitor WRIST_UP gesture'
+        );
+    }
+
+    var listenerId = 'HumanActivityMonitor_' + args.type;
+    var optionsAttributes = ['callbackInterval', 'sampleInterval'],
+        options = args.options || {};
+
+    var callbackInterval = null,
+        sampleInterval = null;
+
+    switch (args.type) {
+    case HumanActivityType.GPS:
+        callbackInterval = !type_.isNullOrUndefined(options[optionsAttributes[0]])
+            ? options[optionsAttributes[0]]
+            : 150000;
+        sampleInterval = !type_.isNullOrUndefined(options[optionsAttributes[1]])
+            ? options[optionsAttributes[1]]
+            : 1000;
+        break;
+    case HumanActivityType.HRM:
+        callbackInterval = !type_.isNullOrUndefined(options[optionsAttributes[0]])
+            ? options[optionsAttributes[0]]
+            : 100;
+        if (callbackInterval < 10 || callbackInterval > 1000) {
+            throw new WebAPIException(
+                WebAPIException.INVALID_VALUES_ERR,
+                'callbackInterval is out of range'
+            );
+        }
+        break;
+    }
+
+    var listener = null;
+    switch (args.type) {
     case HumanActivityType.PEDOMETER:
-      listener = pedometerCallback;
-      break;
+        listener = pedometerCallback;
+        break;
     case HumanActivityType.GPS:
-      listener = GPSCallback;
-      break;
+        listener = GPSCallback;
+        break;
     case HumanActivityType.STRESS_MONITOR:
-      listener = stressMonitorListener.onListener;
-      break;
+        listener = stressMonitorListener.onListener;
+        break;
     default:
-      listener = function(result) {
-        native_.callIfPossible(args.changedCallback, convertActivityData(args.type, result));
-      };
-  }
-
-  utils_.log("callbackInterval = " + callbackInterval + ", sampleInterval = " + sampleInterval);
-  startListener(listenerId,
-                listener,
-                'HumanActivityMonitorManager_start',
-                { type: args.type,
-                  listenerId: listenerId,
-                  callbackInterval: callbackInterval,
-                  sampleInterval: sampleInterval
-                }
-               );
-
-  if (HumanActivityType.PEDOMETER === args.type) {
-    pedometerListener = args.changedCallback;
-  }
+        listener = function(result) {
+            native_.callIfPossible(
+                args.changedCallback,
+                convertActivityData(args.type, result)
+            );
+        };
+    }
 
-  if (HumanActivityType.GPS === args.type || HumanActivityType.STRESS_MONITOR === args.type) {
-    var callback = function(result) {
-      if (native_.isFailure(result)) {
-        native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
-      } else {
-        native_.callIfPossible(args.changedCallback, convertActivityData(args.type, result));
-      }
-    };
+    utils_.log(
+        'callbackInterval = ' + callbackInterval + ', sampleInterval = ' + sampleInterval
+    );
+    startListener(listenerId, listener, 'HumanActivityMonitorManager_start', {
+        type: args.type,
+        listenerId: listenerId,
+        callbackInterval: callbackInterval,
+        sampleInterval: sampleInterval
+    });
+
+    if (HumanActivityType.PEDOMETER === args.type) {
+        pedometerListener = args.changedCallback;
+    }
 
-    if (HumanActivityType.GPS === args.type) {
-      GPSListener = callback;
-    } else if (HumanActivityType.STRESS_MONITOR === args.type){
-      stressListener = callback;
+    if (
+        HumanActivityType.GPS === args.type ||
+        HumanActivityType.STRESS_MONITOR === args.type
+    ) {
+        var callback = function(result) {
+            if (native_.isFailure(result)) {
+                native_.callIfPossible(
+                    args.errorCallback,
+                    native_.getErrorObject(result)
+                );
+            } else {
+                native_.callIfPossible(
+                    args.changedCallback,
+                    convertActivityData(args.type, result)
+                );
+            }
+        };
+
+        if (HumanActivityType.GPS === args.type) {
+            GPSListener = callback;
+        } else if (HumanActivityType.STRESS_MONITOR === args.type) {
+            stressListener = callback;
+        }
     }
-  }
 };
 
 HumanActivityMonitorManager.prototype.stop = function(type) {
-  var args = validator_.validateArgs(arguments, [
-    {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.PEDOMETER === args.type) {
-    stopListener('HumanActivityMonitor_PEDOMETER',
-                 'HumanActivityMonitorManager_stop',
-                 { type: HumanActivityType.PEDOMETER },
-                 pedometerListener && !accumulativePedometerListener);
-    pedometerListener = null;
-  } else {
-    stopListener('HumanActivityMonitor_'  + args.type,
-                 'HumanActivityMonitorManager_stop',
-                 { type: args.type }, true);
-  }
-
-  if (HumanActivityType.GPS === args.type) {
-    GPSListener = null;
-  }
-
-  if (HumanActivityType.STRESS_MONITOR === args.type) {
-    stressListener = null;
-  }
+    var args = validator_.validateArgs(arguments, [
+        { 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.PEDOMETER === args.type) {
+        stopListener(
+            'HumanActivityMonitor_PEDOMETER',
+            'HumanActivityMonitorManager_stop',
+            { type: HumanActivityType.PEDOMETER },
+            pedometerListener && !accumulativePedometerListener
+        );
+        pedometerListener = null;
+    } else {
+        stopListener(
+            'HumanActivityMonitor_' + args.type,
+            'HumanActivityMonitorManager_stop',
+            { type: args.type },
+            true
+        );
+    }
+
+    if (HumanActivityType.GPS === args.type) {
+        GPSListener = null;
+    }
+
+    if (HumanActivityType.STRESS_MONITOR === args.type) {
+        stressListener = null;
+    }
 };
 
 HumanActivityMonitorManager.prototype.setAccumulativePedometerListener = function() {
-  var args = validator_.validateArgs(arguments, [
-    {name: 'changeCallback', type: types_.FUNCTION}
-  ]);
+    var args = validator_.validateArgs(arguments, [
+        { name: 'changeCallback', type: types_.FUNCTION }
+    ]);
 
-  var oldPedometerListener = pedometerListener;
+    var oldPedometerListener = pedometerListener;
 
-  // calling start() will overwrite pedometerListener, needs to be restored afterwards
-  this.start(HumanActivityType.PEDOMETER, args.changeCallback);
+    // calling start() will overwrite pedometerListener, needs to be restored afterwards
+    this.start(HumanActivityType.PEDOMETER, args.changeCallback);
 
-  accumulativePedometerListener = args.changeCallback;
-  pedometerListener = oldPedometerListener;
+    accumulativePedometerListener = args.changeCallback;
+    pedometerListener = oldPedometerListener;
 };
 
 HumanActivityMonitorManager.prototype.unsetAccumulativePedometerListener = function() {
-  stopListener('HumanActivityMonitor_PEDOMETER',
-               'HumanActivityMonitorManager_stop',
-               { type: HumanActivityType.PEDOMETER },
-               accumulativePedometerListener && !pedometerListener);
-  accumulativePedometerListener = null;
+    stopListener(
+        'HumanActivityMonitor_PEDOMETER',
+        'HumanActivityMonitorManager_stop',
+        { type: HumanActivityType.PEDOMETER },
+        accumulativePedometerListener && !pedometerListener
+    );
+    accumulativePedometerListener = null;
 };
 
-
 HumanActivityMonitorManager.prototype.addActivityRecognitionListener = function() {
-  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(
-                  'HumanActivityMonitorManager_addActivityRecognitionListener',
-                  { type: args.type,
-                    listenerId: activityRecognitionListener.listenerName });
-  if (native_.isFailure(result)) {
-    throw native_.getErrorObject(result);
-  }
+    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(
+        'HumanActivityMonitorManager_addActivityRecognitionListener',
+        { 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);
+    var watchId = result.watchId;
+    activityRecognitionListener.addListener(watchId, args.listener, args.errorCallback);
 
-  return watchId;
+    return watchId;
 };
 
 HumanActivityMonitorManager.prototype.removeActivityRecognitionListener = function() {
-  var args = validator_.validateArgs(arguments, [
-    {name: 'watchId', type: types_.LONG},
-    {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
-  ]);
-
-  var result = native_.call(
-                  'HumanActivityMonitorManager_removeActivityRecognitionListener',
-                  { watchId: args.watchId });
-  if (native_.isFailure(result)) {
-    setTimeout(function () { native_.callIfPossible(args.errorCallback, native_.getErrorObject(result)); }, 0);
-    return;
-  }
-  activityRecognitionListener.removeListener(args.watchId);
+    var args = validator_.validateArgs(arguments, [
+        { name: 'watchId', type: types_.LONG },
+        { name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true }
+    ]);
+
+    var result = native_.call(
+        'HumanActivityMonitorManager_removeActivityRecognitionListener',
+        { watchId: args.watchId }
+    );
+    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, [
-    {name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityRecorderType)},
-    {name: 'options', type : types_.DICTIONARY, optional: true, nullable: false}
-  ]);
-
-  var callArgs = {};
+    var args = validator_.validateArgs(arguments, [
+        {
+            name: 'type',
+            type: types_.ENUM,
+            values: Object.keys(HumanActivityRecorderType)
+        },
+        { name: 'options', type: types_.DICTIONARY, optional: true, nullable: false }
+    ]);
+
+    var callArgs = {};
+
+    if (args.options) {
+        if (
+            MIN_OPTION_INTERVAL > args.options.interval ||
+            MIN_OPTION_RETENTION_PERIOD > args.options.interval
+        ) {
+            throw new WebAPIException(
+                WebAPIException.INVALID_VALUES_ERR,
+                'Invalid option value'
+            );
+        }
 
-  if (args.options) {
-    if (MIN_OPTION_INTERVAL > args.options.interval ||
-        MIN_OPTION_RETENTION_PERIOD > args.options.interval) {
-      throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid option value');
+        callArgs.options = args.options;
     }
 
-    callArgs.options = args.options;
-  }
-
-  callArgs.type = args.type;
+    callArgs.type = args.type;
 
-  var result = native_.callSync('HumanActivityMonitorManager_startRecorder', callArgs);
+    var result = native_.callSync('HumanActivityMonitorManager_startRecorder', callArgs);
 
-  if (native_.isFailure(result)) {
-    throw native_.getErrorObject(result);
-  }
+    if (native_.isFailure(result)) {
+        throw native_.getErrorObject(result);
+    }
 };
 
 HumanActivityMonitorManager.prototype.stopRecorder = function() {
-  var args = validator_.validateArgs(arguments, [
-    {name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityRecorderType)},
-  ]);
+    var args = validator_.validateArgs(arguments, [
+        {
+            name: 'type',
+            type: types_.ENUM,
+            values: Object.keys(HumanActivityRecorderType)
+        }
+    ]);
 
-  var callArgs = {};
-  callArgs.type = args.type;
+    var callArgs = {};
+    callArgs.type = args.type;
 
-  var result = native_.callSync('HumanActivityMonitorManager_stopRecorder', callArgs);
+    var result = native_.callSync('HumanActivityMonitorManager_stopRecorder', callArgs);
 
-  if (native_.isFailure(result)) {
-    throw native_.getErrorObject(result);
-  }
+    if (native_.isFailure(result)) {
+        throw native_.getErrorObject(result);
+    }
 };
 
 HumanActivityMonitorManager.prototype.readRecorderData = function() {
-  var args = validator_.validateArgs(arguments, [
-    {name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityRecorderType)},
-    {name: 'query', type : types_.DICTIONARY, optional: false, nullable: true},
-    {name: 'successCallback', type: types_.FUNCTION},
-    {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
-  ]);
-
-  var callArgs = {};
-
-  if (args.query) {
-    if ((args.query.startTime && MIN_QUERY_TIME > args.query.startTime) ||
-        (args.query.endTime && MIN_QUERY_TIME > args.query.endTime) ||
-        (args.query.anchorTime && MIN_QUERY_TIME > args.query.anchorTime) ||
-        (args.query.interval && MIN_QUERY_INTERVAL > args.query.interval) ||
-        (args.query.startTime && args.query.endTime && args.query.startTime > args.query.endTime)) {
-      throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid query value');
-    }
-  }
-
-  callArgs.options = args.options;
-  callArgs.type = args.type;
-  callArgs.query = args.query;
-
-  var callback = function(result) {
-    if (native_.isFailure(result)) {
-        native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
-    } else {
-        var array = convertActivityRecorderData(args.type, native_.getResultObject(result));
-        args.successCallback(array);
+    var args = validator_.validateArgs(arguments, [
+        {
+            name: 'type',
+            type: types_.ENUM,
+            values: Object.keys(HumanActivityRecorderType)
+        },
+        { name: 'query', type: types_.DICTIONARY, optional: false, nullable: true },
+        { name: 'successCallback', type: types_.FUNCTION },
+        { name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true }
+    ]);
+
+    var callArgs = {};
+
+    if (args.query) {
+        if (
+            (args.query.startTime && MIN_QUERY_TIME > args.query.startTime) ||
+            (args.query.endTime && MIN_QUERY_TIME > args.query.endTime) ||
+            (args.query.anchorTime && MIN_QUERY_TIME > args.query.anchorTime) ||
+            (args.query.interval && MIN_QUERY_INTERVAL > args.query.interval) ||
+            (args.query.startTime &&
+                args.query.endTime &&
+                args.query.startTime > args.query.endTime)
+        ) {
+            throw new WebAPIException(
+                WebAPIException.INVALID_VALUES_ERR,
+                'Invalid query value'
+            );
+        }
     }
-  };
 
-  var result = native_.call('HumanActivityMonitorManager_readRecorderData', callArgs, callback);
+    callArgs.options = args.options;
+    callArgs.type = args.type;
+    callArgs.query = args.query;
 
-  if (native_.isFailure(result)) {
-    throw native_.getErrorObject(result);
-  }
+    var callback = function(result) {
+        if (native_.isFailure(result)) {
+            native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
+        } else {
+            var array = convertActivityRecorderData(
+                args.type,
+                native_.getResultObject(result)
+            );
+            args.successCallback(array);
+        }
+    };
+
+    var result = native_.call(
+        'HumanActivityMonitorManager_readRecorderData',
+        callArgs,
+        callback
+    );
+
+    if (native_.isFailure(result)) {
+        throw native_.getErrorObject(result);
+    }
 };
 
 HumanActivityMonitorManager.prototype.isGestureSupported = function() {
-  var args = validator_.validateMethod(arguments, [{
-    name : 'type',
-    type: types_.ENUM,
-    values: Object.keys(GestureType)
-  }
-  ]);
-
-  var callArgs = {};
-  callArgs.type = args.type;
-
-  var result = native_.callSync('GestureManager_isGestureSupported', callArgs);
-  if (native_.isFailure(result)) {
-    throw native_.getErrorObject(result);
-  }
-
-  return native_.getResultObject(result);
+    var args = validator_.validateMethod(arguments, [
+        {
+            name: 'type',
+            type: types_.ENUM,
+            values: Object.keys(GestureType)
+        }
+    ]);
+
+    var callArgs = {};
+    callArgs.type = args.type;
+
+    var result = native_.callSync('GestureManager_isGestureSupported', 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;
-  }
-};
+    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) {
+    var d = undefined;
+    var result = undefined;
+    var alwaysOn = msg.alwaysOn;
+    switch (msg.action) {
     case 'ondetect':
-      d = new GestureData(this.native.getResultObject(msg));
-      break;
+        d = new GestureData(this.native.getResultObject(msg));
+        break;
     case 'onerror':
-      d = this.native.getErrorObject(msg);
-      break;
+        d = this.native.getErrorObject(msg);
+        break;
     default:
-      utils_.log('Unknown mode: ' + msg.action);
-      return;
-  }
+        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);
-      }
+    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
-  };
+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('GestureManager_addGestureRecognitionListener', listener);
-    if (this.native.isFailure(result)) {
-      throw this.native.getErrorObject(result);
+    var typeCountMap = alwaysOn ? this.typeCountMapAlwaysOn : this.typeCountMapDefault;
+    if (typeCountMap[type] === 0) {
+        var result = this.native.callSync(
+            'GestureManager_addGestureRecognitionListener',
+            listener
+        );
+        if (this.native.isFailure(result)) {
+            throw this.native.getErrorObject(result);
+        }
     }
-  }
 
-  typeCountMap[type]++;
-  var id = this.nextId++;
-  this.listeners[id] = listener;
+    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;
-  }
+    if (!this.nativeSet) {
+        this.native.addListener(this.listenerName, this.onListenerCalled.bind(this));
+        this.nativeSet = true;
+    }
 
-  return id;
+    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('GestureManager_removeGestureRecognitionListener', listener);
-        if (this.native.isFailure(result)) {
-          throw this.native.getErrorObject(result);
+    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(
+                'GestureManager_removeGestureRecognitionListener',
+                listener
+            );
+            if (this.native.isFailure(result)) {
+                throw this.native.getErrorObject(result);
+            }
         }
-      }
 
-      delete this.listeners[watchId];
-      typeCountMap[listener.type]--;
-  }
+        delete this.listeners[watchId];
+        typeCountMap[listener.type]--;
+    }
 
-  if (this.nativeSet && type_.isEmptyObject(this.listeners)) {
-    this.native.removeListener(this.listenerName);
-    this.nativeSet = false;
-  }
+    if (this.nativeSet && type_.isEmptyObject(this.listeners)) {
+        this.native.removeListener(this.listenerName);
+        this.nativeSet = false;
+    }
 };
 
 var GESTURE_RECOGNITION_LISTENER = 'GestureRecognitionListener';
-var gestureRecognitionListener = new GestureListenerManager(native_, GESTURE_RECOGNITION_LISTENER);
+var gestureRecognitionListener = new GestureListenerManager(
+    native_,
+    GESTURE_RECOGNITION_LISTENER
+);
 
 HumanActivityMonitorManager.prototype.addGestureRecognitionListener = function() {
-  var args = validator_.validateMethod(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);
+    var args = validator_.validateMethod(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
+    );
 };
 
 HumanActivityMonitorManager.prototype.removeGestureRecognitionListener = function() {
-  var args = validator_.validateMethod(arguments, [{
-    name : 'watchId',
-    type : types_.LONG,
-  }]);
+    var args = validator_.validateMethod(arguments, [
+        {
+            name: 'watchId',
+            type: types_.LONG
+        }
+    ]);
 
-  gestureRecognitionListener.removeListener(args.watchId);
+    gestureRecognitionListener.removeListener(args.watchId);
 };
 
 function StressMonitorListenerManager() {
-  this.listeners = {};
-  this.nextId = 1;
-};
+    this.listeners = {};
+    this.nextId = 1;
+}
 
 StressMonitorListenerManager.prototype.onListener = function(data) {
-
-  if (stressListener) {
-    stressListener(data);
-  }
-  var score = data.stressScore;
-  for (var watchId in stressMonitorListener.listeners) {
-    if (stressMonitorListener.listeners.hasOwnProperty(watchId)) {
-      var _listener = stressMonitorListener.listeners[watchId];
-      var rangeArray = _listener.ranges;
-      for (var id in rangeArray) {
-        var _min = rangeArray[id].min;
-        var _max = !type_.isUndefined(rangeArray[id].max) ? rangeArray[id].max : Number.MAX_VALUE;
-        if ((score >= _min && score < _max) && (_listener.lastStressScore < _min || _listener.lastStressScore >= _max)) {
-          _listener.listener(rangeArray[id].label);
+    if (stressListener) {
+        stressListener(data);
+    }
+    var score = data.stressScore;
+    for (var watchId in stressMonitorListener.listeners) {
+        if (stressMonitorListener.listeners.hasOwnProperty(watchId)) {
+            var _listener = stressMonitorListener.listeners[watchId];
+            var rangeArray = _listener.ranges;
+            for (var id in rangeArray) {
+                var _min = rangeArray[id].min;
+                var _max = !type_.isUndefined(rangeArray[id].max)
+                    ? rangeArray[id].max
+                    : Number.MAX_VALUE;
+                if (
+                    score >= _min &&
+                    score < _max &&
+                    (_listener.lastStressScore < _min ||
+                        _listener.lastStressScore >= _max)
+                ) {
+                    _listener.listener(rangeArray[id].label);
+                }
+            }
+            _listener.lastStressScore = score;
         }
-      }
-      _listener.lastStressScore = score;
     }
-  }
 };
 
-StressMonitorListenerManager.prototype.addListener = function(ranges, listener, errorCallback) {
-
-  var id = this.nextId++;
-
-  this.listeners[id] = {
-    ranges: ranges,
-    listener: listener,
-    lastStressScore: -1
-  };
+StressMonitorListenerManager.prototype.addListener = function(
+    ranges,
+    listener,
+    errorCallback
+) {
+    var id = this.nextId++;
+
+    this.listeners[id] = {
+        ranges: ranges,
+        listener: listener,
+        lastStressScore: -1
+    };
 
-  return id;
+    return id;
 };
 
 StressMonitorListenerManager.prototype.removeListener = function(watchId) {
-  if (this.listeners.hasOwnProperty(watchId)) {
-    delete this.listeners[watchId];
-  }
+    if (this.listeners.hasOwnProperty(watchId)) {
+        delete this.listeners[watchId];
+    }
 };
 
 var stressMonitorListener = new StressMonitorListenerManager();
 
 HumanActivityMonitorManager.prototype.addStressMonitorChangeListener = function() {
-  utils_.checkPrivilegeAccess(privilege_.HEALTHINFO);
-  var args = validator_.validateMethod(arguments, [{
-    name : 'ranges',
-    type: types_.ARRAY,
-    values: StressMonitorDataRange
-  },
-  {
-    name : 'listener',
-    type : types_.FUNCTION
-  }]);
-
-  return stressMonitorListener.addListener(args.ranges, args.listener);
+    utils_.checkPrivilegeAccess(privilege_.HEALTHINFO);
+    var args = validator_.validateMethod(arguments, [
+        {
+            name: 'ranges',
+            type: types_.ARRAY,
+            values: StressMonitorDataRange
+        },
+        {
+            name: 'listener',
+            type: types_.FUNCTION
+        }
+    ]);
+
+    return stressMonitorListener.addListener(args.ranges, args.listener);
 };
 
-HumanActivityMonitorManager.prototype.removeStressMonitorChangeListener  = function() {
-  var args = validator_.validateMethod(arguments, [{
-    name : 'watchId',
-    type : types_.LONG,
-  }]);
+HumanActivityMonitorManager.prototype.removeStressMonitorChangeListener = function() {
+    var args = validator_.validateMethod(arguments, [
+        {
+            name: 'watchId',
+            type: types_.LONG
+        }
+    ]);
 
-  stressMonitorListener.removeListener(args.watchId);
+    stressMonitorListener.removeListener(args.watchId);
 };
 
 function StepDifference(data) {
-  SetReadOnlyProperty(this, 'stepCountDifference', data.stepCountDifference);
-  SetReadOnlyProperty(this, 'timestamp', data.timestamp);
-}
-
-
-function HumanActivityData() {
+    SetReadOnlyProperty(this, 'stepCountDifference', data.stepCountDifference);
+    SetReadOnlyProperty(this, 'timestamp', data.timestamp);
 }
 
+function HumanActivityData() {}
 
 function HumanActivityPedometerData(data) {
-  SetReadOnlyProperty(this, 'stepStatus', data.stepStatus);
-  SetReadOnlyProperty(this, 'speed', data.speed);
-  SetReadOnlyProperty(this, 'walkingFrequency', data.walkingFrequency);
-  SetReadOnlyProperty(this, 'cumulativeDistance', data.cumulativeDistance);
-  SetReadOnlyProperty(this, 'cumulativeCalorie', data.cumulativeCalorie);
-  SetReadOnlyProperty(this, 'cumulativeTotalStepCount', data.cumulativeTotalStepCount);
-  SetReadOnlyProperty(this, 'cumulativeWalkStepCount', data.cumulativeWalkStepCount);
-  SetReadOnlyProperty(this, 'cumulativeRunStepCount', data.cumulativeRunStepCount);
-
-  var steps = [];
-  for (var i = 0; i < data.stepCountDifferences.length; ++i) {
-    steps.push(new StepDifference(data.stepCountDifferences[i]));
-  }
-  SetReadOnlyProperty(this, 'stepCountDifferences', steps);
+    SetReadOnlyProperty(this, 'stepStatus', data.stepStatus);
+    SetReadOnlyProperty(this, 'speed', data.speed);
+    SetReadOnlyProperty(this, 'walkingFrequency', data.walkingFrequency);
+    SetReadOnlyProperty(this, 'cumulativeDistance', data.cumulativeDistance);
+    SetReadOnlyProperty(this, 'cumulativeCalorie', data.cumulativeCalorie);
+    SetReadOnlyProperty(this, 'cumulativeTotalStepCount', data.cumulativeTotalStepCount);
+    SetReadOnlyProperty(this, 'cumulativeWalkStepCount', data.cumulativeWalkStepCount);
+    SetReadOnlyProperty(this, 'cumulativeRunStepCount', data.cumulativeRunStepCount);
+
+    var steps = [];
+    for (var i = 0; i < data.stepCountDifferences.length; ++i) {
+        steps.push(new StepDifference(data.stepCountDifferences[i]));
+    }
+    SetReadOnlyProperty(this, 'stepCountDifferences', steps);
 }
 
 HumanActivityPedometerData.prototype = new HumanActivityData();
 HumanActivityPedometerData.prototype.constructor = HumanActivityPedometerData;
 
-
 function HumanActivityAccumulativePedometerData(data) {
-  SetReadOnlyProperty(this, 'stepStatus', data.stepStatus);
-  SetReadOnlyProperty(this, 'speed', data.speed);
-  SetReadOnlyProperty(this, 'walkingFrequency', data.walkingFrequency);
-  SetReadOnlyProperty(this, 'accumulativeDistance', data.accumulativeDistance);
-  SetReadOnlyProperty(this, 'accumulativeCalorie', data.accumulativeCalorie);
-  SetReadOnlyProperty(this, 'accumulativeTotalStepCount', data.accumulativeTotalStepCount);
-  SetReadOnlyProperty(this, 'accumulativeWalkStepCount', data.accumulativeWalkStepCount);
-  SetReadOnlyProperty(this, 'accumulativeRunStepCount', data.accumulativeRunStepCount);
-
-  var steps = [];
-  for (var i = 0; i < data.stepCountDifferences.length; ++i) {
-    steps.push(new StepDifference(data.stepCountDifferences[i]));
-  }
-  SetReadOnlyProperty(this, 'stepCountDifferences', steps);
+    SetReadOnlyProperty(this, 'stepStatus', data.stepStatus);
+    SetReadOnlyProperty(this, 'speed', data.speed);
+    SetReadOnlyProperty(this, 'walkingFrequency', data.walkingFrequency);
+    SetReadOnlyProperty(this, 'accumulativeDistance', data.accumulativeDistance);
+    SetReadOnlyProperty(this, 'accumulativeCalorie', data.accumulativeCalorie);
+    SetReadOnlyProperty(
+        this,
+        'accumulativeTotalStepCount',
+        data.accumulativeTotalStepCount
+    );
+    SetReadOnlyProperty(
+        this,
+        'accumulativeWalkStepCount',
+        data.accumulativeWalkStepCount
+    );
+    SetReadOnlyProperty(this, 'accumulativeRunStepCount', data.accumulativeRunStepCount);
+
+    var steps = [];
+    for (var i = 0; i < data.stepCountDifferences.length; ++i) {
+        steps.push(new StepDifference(data.stepCountDifferences[i]));
+    }
+    SetReadOnlyProperty(this, 'stepCountDifferences', steps);
 }
 
 HumanActivityAccumulativePedometerData.prototype = new HumanActivityData();
-HumanActivityAccumulativePedometerData.prototype.constructor = HumanActivityAccumulativePedometerData;
-
+// prettier-ignore
+HumanActivityAccumulativePedometerData.prototype.constructor =
+    HumanActivityAccumulativePedometerData;
 
 function HumanActivityHRMData(data) {
-  SetReadOnlyProperty(this, 'heartRate', data.heartRate);
-  SetReadOnlyProperty(this, 'rRInterval', data.rRInterval);
+    SetReadOnlyProperty(this, 'heartRate', data.heartRate);
+    SetReadOnlyProperty(this, 'rRInterval', data.rRInterval);
 }
 
 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);
+    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);
-  SetReadOnlyProperty(this, 'altitude', data.altitude);
-  SetReadOnlyProperty(this, 'speed', data.speed);
-  SetReadOnlyProperty(this, 'errorRange', data.errorRange);
-  SetReadOnlyProperty(this, 'timestamp', data.timestamp);
+    SetReadOnlyProperty(this, 'latitude', data.latitude);
+    SetReadOnlyProperty(this, 'longitude', data.longitude);
+    SetReadOnlyProperty(this, 'altitude', data.altitude);
+    SetReadOnlyProperty(this, 'speed', data.speed);
+    SetReadOnlyProperty(this, 'errorRange', data.errorRange);
+    SetReadOnlyProperty(this, 'timestamp', data.timestamp);
 }
 
-
 function HumanActivityGPSInfoArray(data) {
-  SetReadOnlyProperty(this, 'gpsInfo', data);
+    SetReadOnlyProperty(this, 'gpsInfo', data);
 }
 
 HumanActivityGPSInfoArray.prototype = new HumanActivityData();
 HumanActivityGPSInfoArray.prototype.constructor = HumanActivityGPSInfoArray;
 
 function HumanActivitySleepMonitorData(data) {
-  SetReadOnlyProperty(this, 'status', data.status);
-  SetReadOnlyProperty(this, 'timestamp', data.timestamp);
+    SetReadOnlyProperty(this, 'status', data.status);
+    SetReadOnlyProperty(this, 'timestamp', data.timestamp);
 }
 
 HumanActivitySleepMonitorData.prototype = new HumanActivityData();
 HumanActivitySleepMonitorData.prototype.constructor = HumanActivitySleepMonitorData;
 
 function HumanActivitySleepDetectorData(data) {
-  SetReadOnlyProperty(this, 'status', data.status);
+    SetReadOnlyProperty(this, 'status', data.status);
 }
 
 HumanActivitySleepDetectorData.prototype = new HumanActivityData();
 HumanActivitySleepDetectorData.prototype.constructor = HumanActivitySleepMonitorData;
 
 function HumanActivityStressMonitorData(data) {
-  SetReadOnlyProperty(this, 'stressScore', data.stressScore);
+    SetReadOnlyProperty(this, 'stressScore', data.stressScore);
 }
 
 HumanActivityStressMonitorData.prototype = new HumanActivityData();
-HumanActivityStressMonitorData.prototype.constructor = HumanActivityStressMonitorData
+HumanActivityStressMonitorData.prototype.constructor = HumanActivityStressMonitorData;
 
 //Recorded data
 function HumanActivityRecorderData(data) {
-  if (data) {
-    SetReadOnlyProperty(this, 'startTime', data.startTime);
-    SetReadOnlyProperty(this, 'endTime', data.endTime);
-  }
+    if (data) {
+        SetReadOnlyProperty(this, 'startTime', data.startTime);
+        SetReadOnlyProperty(this, 'endTime', data.endTime);
+    }
 }
 
 function HumanActivityRecorderPedometerData(data) {
-  HumanActivityRecorderData.call(this, data);
-  SetReadOnlyProperty(this, 'distance', data.distance);
-  SetReadOnlyProperty(this, 'calorie', data.calorie);
-  SetReadOnlyProperty(this, 'totalStepCount', data.totalStepCount);
-  SetReadOnlyProperty(this, 'walkStepCount', data.walkStepCount);
-  SetReadOnlyProperty(this, 'runStepCount', data.runStepCount);
+    HumanActivityRecorderData.call(this, data);
+    SetReadOnlyProperty(this, 'distance', data.distance);
+    SetReadOnlyProperty(this, 'calorie', data.calorie);
+    SetReadOnlyProperty(this, 'totalStepCount', data.totalStepCount);
+    SetReadOnlyProperty(this, 'walkStepCount', data.walkStepCount);
+    SetReadOnlyProperty(this, 'runStepCount', data.runStepCount);
 }
 
 HumanActivityRecorderPedometerData.prototype = new HumanActivityRecorderData();
-HumanActivityRecorderPedometerData.prototype.constructor = HumanActivityRecorderPedometerData;
+// prettier-ignore
+HumanActivityRecorderPedometerData.prototype.constructor =
+    HumanActivityRecorderPedometerData;
 
 function HumanActivityRecorderHRMData(data) {
-  HumanActivityRecorderData.call(this, data);
-  SetReadOnlyProperty(this, 'heartRate', data.heartRate);
+    HumanActivityRecorderData.call(this, data);
+    SetReadOnlyProperty(this, 'heartRate', data.heartRate);
 }
 
 HumanActivityRecorderHRMData.prototype = new HumanActivityRecorderData();
 HumanActivityRecorderHRMData.prototype.constructor = HumanActivityRecorderHRMData;
 
 function HumanActivityRecorderSleepMonitorData(data) {
-  HumanActivityRecorderData.call(this, data);
-  SetReadOnlyProperty(this, 'status', data.status);
+    HumanActivityRecorderData.call(this, data);
+    SetReadOnlyProperty(this, 'status', data.status);
 }
 
 HumanActivityRecorderSleepMonitorData.prototype = new HumanActivityRecorderData();
-HumanActivityRecorderSleepMonitorData.prototype.constructor = HumanActivityRecorderSleepMonitorData;
+// prettier-ignore
+HumanActivityRecorderSleepMonitorData.prototype.constructor =
+    HumanActivityRecorderSleepMonitorData;
 
 function HumanActivityRecorderPressureData(data) {
-  HumanActivityRecorderData.call(this, data);
-  SetReadOnlyProperty(this, 'max', data.max);
-  SetReadOnlyProperty(this, 'min', data.min);
-  SetReadOnlyProperty(this, 'average', data.average);
+    HumanActivityRecorderData.call(this, data);
+    SetReadOnlyProperty(this, 'max', data.max);
+    SetReadOnlyProperty(this, 'min', data.min);
+    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);
+    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();
-HumanActivityRecorderPressureData.prototype.constructor = HumanActivityRecorderPressureData;
+// prettier-ignore
+HumanActivityRecorderPressureData.prototype.constructor =
+    HumanActivityRecorderPressureData;
 
 tizen.StressMonitorDataRange = StressMonitorDataRange;