There is a setter attribute int in public API.
But there is no getter, so it is needed.
API function
-sensor_listener_get_attribute_int : get listener attribute int
Change-Id: Id8b3a7610d5533e93bb3212fc81df3ce8162929d
Signed-off-by: TaeminYeom <taemin.yeom@samsung.com>
#ifndef __SENSOR_PRIVATE_H__
#define __SENSOR_PRIVATE_H__
+#define SENSOR_LISTENER_MAGIC 0xCAFECAFE
+
struct sensor_listener_s {
int id;
int type;
*/
int sensor_util_get_attribute_int(sensor_type_e type, sensor_attribute_e attr, int *value);
+/**
+ * @brief Gets an attribute to control the behavior of a sensor listener.
+ * @details Applications can change the behavior of a sensor listener, for example,
+ * what is the reference coordinate of the sensor values,
+ * and when the system is allowed to turn off the sensor implicitly to reduce the power consumption.
+ * See #sensor_attribute_e for more details about the available control parameters.
+ * @since_tizen 7.0
+ *
+ * @param[in] listener A listener handle
+ * @param[in] attribute An attribute to change.
+ * It should be in the range each sensor_attribute_e,
+ * or should be fixed enum value such as sensor_axis_e or sensor_pause_e.
+ * @param[out] value An attribute value
+ *
+ * @return #SENSOR_ERROR_NONE on success, otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ */
+int sensor_listener_get_attribute_int(sensor_listener_h listener, sensor_attribute_e attribute, int *value);
+
#ifdef __cplusplus
}
#endif
#include <errno.h>
#include <sensor.h>
#include <sensor_internal.h>
+#include <sensor-private.h>
+#include <sensor-log-private.h>
int sensor_util_set_attribute_int(sensor_type_e type, sensor_attribute_e attr, int value)
{
return 0;
}
+
+static bool is_supported_sensor_listener_attribute(sensor_attribute_e attribute)
+{
+ switch (attribute) {
+ case SENSOR_ATTRIBUTE_AXIS_ORIENTATION:
+ case SENSOR_ATTRIBUTE_PAUSE_POLICY:
+ return true;
+ default:
+ return false;
+ }
+}
+
+int sensor_listener_get_attribute_int(sensor_listener_h listener, sensor_attribute_e attribute, int *value)
+{
+ if (!value) {
+ _E("Failed to validate the parameter");
+ return SENSOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!listener || listener->magic != SENSOR_LISTENER_MAGIC) {
+ _E("Invalid sensor listener");
+ return SENSOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!is_supported_sensor_listener_attribute(attribute)) {
+ _E("Invalid sensor listener attribute");
+ return SENSOR_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = sensord_listener_get_attribute_int(listener->id, (int)attribute, value);
+ if (ret == -EINVAL) {
+ _E("Failed to validate the parameter");
+ return SENSOR_ERROR_INVALID_PARAMETER;
+ } else if (ret != SENSOR_ERROR_NONE) {
+ _E("Failed to get listener attribute");
+ return SENSOR_ERROR_OPERATION_FAILED;
+ }
+
+ return SENSOR_ERROR_NONE;
+}
#define SENSOR_SHIFT_TYPE 16
#define SENSOR_UNDEFINED_ID -1
-#define SENSOR_LISTENER_MAGIC 0xCAFECAFE
#define RAD2DEGREE (180/M_PI)
#define CONVERT_AXIS_ENUM(X) ((X) < 3 ? (X) + 0x81 : (X) - 2)