From: kibak.yoon Date: Thu, 17 Mar 2016 13:16:49 +0000 (+0900) Subject: capi-sensor: add implementation of sensor_listener_set_attribute_int X-Git-Tag: submit/tizen/20160321.103327^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24814cf0a33d6b34c343a29dd25d5a27d62057fc;p=platform%2Fcore%2Fapi%2Fsensor.git capi-sensor: add implementation of sensor_listener_set_attribute_int Change-Id: I82550778555fe2894da3e8ddeaf23d8d08b6c021 Signed-off-by: kibak.yoon --- diff --git a/src/sensor.cpp b/src/sensor.cpp index 9511d24..10ea73d 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -512,7 +512,32 @@ int sensor_listener_set_max_batch_latency(sensor_listener_h listener, unsigned i int sensor_listener_set_attribute_int(sensor_listener_h listener, sensor_attribute_e attribute, int value) { - return SENSOR_ERROR_NOT_SUPPORTED; + int id; + int error; + + _D("called sensor_set_attribute_int : listener[0x%x], attribute[%d], value[%d]", listener, attribute, value); + + if (!listener) + return SENSOR_ERROR_INVALID_PARAMETER; + + if (listener->magic != SENSOR_LISTENER_MAGIC) + return SENSOR_ERROR_INVALID_PARAMETER; + + id = listener->id; + + error = sensord_set_attribute_int(id, (int)attribute, (int)value); + + if (error == -EINVAL) + return SENSOR_ERROR_INVALID_PARAMETER; + else if (error != SENSOR_ERROR_NONE) + return SENSOR_ERROR_OPERATION_FAILED; + + if (attribute == SENSOR_ATTRIBUTE_PAUSE_POLICY) + listener->option = value; + + _D("success sensor_set_attribute_int"); + + return SENSOR_ERROR_NONE; } int sensor_listener_set_option(sensor_listener_h listener, sensor_option_e option)