From 24814cf0a33d6b34c343a29dd25d5a27d62057fc Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Thu, 17 Mar 2016 22:16:49 +0900 Subject: [PATCH] capi-sensor: add implementation of sensor_listener_set_attribute_int Change-Id: I82550778555fe2894da3e8ddeaf23d8d08b6c021 Signed-off-by: kibak.yoon --- src/sensor.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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) -- 2.34.1