Revert "[HAM] - fixing pedometer listeners" 19/108219/1
authorJeongkyun Pu <jk.pu@samsung.com>
Tue, 3 Jan 2017 10:54:02 +0000 (02:54 -0800)
committerJeongkyun Pu <jk.pu@samsung.com>
Tue, 3 Jan 2017 10:54:02 +0000 (02:54 -0800)
This reverts commit dbe8157f28394a8bba37a3ecab194c67e360209a.

Change-Id: I842ab00deef4102f6af98bc48875c748d2d8be9f

src/humanactivitymonitor/humanactivitymonitor_api.js

index 5c36b72bd4186b1281cdc59cb8b001c42fdf0d38..2d2d65e1c7172665684ae15ebad506e570a6de32 100755 (executable)
@@ -354,17 +354,12 @@ HumanActivityMonitorManager.prototype.stop = function(type) {
     {name: 'type', type: types_.ENUM, values: Object.keys(HumanActivityType)}
   ]);
 
+  stopListener('HumanActivityMonitor_'  + args.type,
+               'HumanActivityMonitorManager_stop',
+               { type: args.type });
+
   if (HumanActivityType.PEDOMETER === args.type) {
-    if (pedometerListener && !accumulativePedometerListener) {
-      stopListener('HumanActivityMonitor_PEDOMETER',
-                   'HumanActivityMonitorManager_stop',
-                   { type: HumanActivityType.PEDOMETER });
-    }
     pedometerListener = null;
-  } else {
-    stopListener('HumanActivityMonitor_'  + args.type,
-                 'HumanActivityMonitorManager_stop',
-                 { type: args.type });
   }
 
   if (HumanActivityType.GPS === args.type) {
@@ -387,12 +382,13 @@ HumanActivityMonitorManager.prototype.setAccumulativePedometerListener = functio
 };
 
 HumanActivityMonitorManager.prototype.unsetAccumulativePedometerListener = function() {
-  if (accumulativePedometerListener && !pedometerListener) {
-    stopListener('HumanActivityMonitor_PEDOMETER',
-                 'HumanActivityMonitorManager_stop',
-                 { type: HumanActivityType.PEDOMETER });
-  }
+  var oldPedometerListener = pedometerListener;
+
+  // calling stop() will overwrite pedometerListener, needs to be restored afterwards
+  this.stop(HumanActivityType.PEDOMETER);
+
   accumulativePedometerListener = null;
+  pedometerListener = oldPedometerListener;
 };