[HAM] Removing a non-existent watch should not result in error.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 16 Mar 2016 11:41:41 +0000 (12:41 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 16 Mar 2016 11:41:41 +0000 (12:41 +0100)
Change-Id: Ia9e2e03631ac770d2f4e41a6ded358890eff56e8
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/humanactivitymonitor/humanactivitymonitor_api.js
src/humanactivitymonitor/humanactivitymonitor_manager.cc

index daf6252..b40a82a 100755 (executable)
@@ -122,10 +122,6 @@ ActivityRecognitionListenerManager.prototype.addListener = function(watchId, lis
 };
 
 ActivityRecognitionListenerManager.prototype.removeListener = function(watchId) {
-  if (this.listeners[watchId] === null || this.listeners[watchId] === undefined) {
-    throw new WebAPIException(0, 'Listener id not found.', 'InvalidValuesError');
-  }
-
   if (this.listeners.hasOwnProperty(watchId)) {
     delete this.listeners[watchId];
     if (type_.isEmptyObject(this.listeners)) {
@@ -328,7 +324,7 @@ HumanActivityMonitorManager.prototype.removeActivityRecognitionListener = functi
     setTimeout(function () { native_.callIfPossible(args.errorCallback, native_.getErrorObject(result)); }, 0);
     return;
   }
-  activityRecognitionListener.removeListener(watchId);
+  activityRecognitionListener.removeListener(args.watchId);
 };
 
 function StepDifference() {
index b47e043..06247e7 100755 (executable)
@@ -647,14 +647,10 @@ class HumanActivityMonitorManager::ActivityRecognition {
 
     const auto it = activity_data_.find(watch_id);
 
-    if (activity_data_.end() == it) {
-      return LogAndCreateResult( ErrorCode::ABORT_ERR,
-                                 "Listener not found",
-                                 ("Listener with id = %ld not found", watch_id));
+    if (activity_data_.end() != it) {
+      activity_data_.erase(it);
     }
 
-    activity_data_.erase(it);
-
     return PlatformResult(ErrorCode::NO_ERROR);
   }