capi-sensor: add returning NOT_SUPPORTED in sensor_set_max_batch_latency 80/65280/1
authorkibak.yoon <kibak.yoon@samsung.com>
Tue, 5 Apr 2016 08:53:09 +0000 (17:53 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Fri, 8 Apr 2016 08:00:51 +0000 (17:00 +0900)
* if max_batch_count is 0, it means that batching feature is not supported on this
  sensor. so checking max_batch_count is added.

Change-Id: I466b7406cdb5dfeeb584d0f23bbe8e6d2011ffcf
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/sensor.cpp

index befb32c..a1daebb 100644 (file)
@@ -510,6 +510,7 @@ int sensor_listener_set_max_batch_latency(sensor_listener_h listener, unsigned i
 {
        int id;
        int type;
+       int max_batch_count;
        unsigned int event_id;
 
        _D("called sensor_set_max_batch_latency : listener[0x%x], max_batch_latency[%d]", listener, max_batch_latency);
@@ -520,6 +521,12 @@ int sensor_listener_set_max_batch_latency(sensor_listener_h listener, unsigned i
        if (listener->magic != SENSOR_LISTENER_MAGIC)
                return SENSOR_ERROR_INVALID_PARAMETER;
 
+       if (!sensord_get_max_batch_count(listener->sensor, &max_batch_count))
+               return SENSOR_ERROR_OPERATION_FAILED;
+
+       if (max_batch_count == 0)
+               return SENSOR_ERROR_NOT_SUPPORTED;
+
        id = listener->id;
        type = (int)listener->type;
        event_id = type << SENSOR_SHIFT_TYPE | 0x1;