Use sensor_error_e of hal API
authorYunmi Ha <yunmi.ha@samsung.com>
Tue, 13 Apr 2021 06:47:29 +0000 (15:47 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Tue, 13 Apr 2021 10:37:53 +0000 (19:37 +0900)
Change-Id: I8ca55a9f83d9979808a85fb20c2f10a2235e0bb9
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
src/hal-backend-sensor.cpp
src/sensor_common.h
src/sensorhub/sensorhub.cpp

index 3544482..f9ffc13 100644 (file)
@@ -44,6 +44,7 @@ void create_sensor(const char *name) {
 }
 
 static int sensor_tm1_create(sensor_device_t **devices) {
+  if (devs.empty()) {
 #ifdef ENABLE_ACCEL
   create_sensor<accel_device>("Accelerometer");
 #endif
@@ -53,6 +54,7 @@ static int sensor_tm1_create(sensor_device_t **devices) {
 #ifdef ENABLE_SENSORHUB
   create_sensor<sensorhub_device>("Sensorhub");
 #endif
+  }
 
   *devices = &devs[0];
   return devs.size();
index e34ec3f..a69241d 100755 (executable)
@@ -22,7 +22,6 @@
 #define RAW_DATA_EVENT 0x0001
 
 #define UNKNOWN_NAME "UNKNOWN"
-#include <tizen.h>
 
 
 enum sensorhub_enable_bit {
@@ -55,25 +54,4 @@ enum sensorhub_enable_bit {
        SENSORHUB_ENABLE_BIT_MAX,
 };
 
-
-/**
- * @brief   Enumeration for errors.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- */
-typedef enum {
-       SENSOR_ERROR_NONE                  = TIZEN_ERROR_NONE,                 /**< Successful */
-       SENSOR_ERROR_IO_ERROR              = TIZEN_ERROR_IO_ERROR,             /**< I/O error */
-       SENSOR_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
-       SENSOR_ERROR_NOT_SUPPORTED         = TIZEN_ERROR_NOT_SUPPORTED,        /**< Not supported */
-       SENSOR_ERROR_PERMISSION_DENIED     = TIZEN_ERROR_PERMISSION_DENIED,    /**< Permission denied */
-       SENSOR_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_OUT_OF_MEMORY,        /**< Out of memory */
-       SENSOR_ERROR_NO_DATA               = TIZEN_ERROR_NO_DATA,              /**< No data available
-                                                                                @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */
-       SENSOR_ERROR_NOT_NEED_CALIBRATION  = TIZEN_ERROR_SENSOR | 0x03,        /**< Sensor doesn't need calibration */
-       SENSOR_ERROR_OPERATION_FAILED      = TIZEN_ERROR_SENSOR | 0x06,        /**< Operation failed */
-       SENSOR_ERROR_NOT_AVAILABLE         = TIZEN_ERROR_SENSOR | 0x07,        /**< The sensor is supported, but currently not available
-                                                                                @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */
-} sensor_error_e;
-
-
 #endif /* __SENSOR_COMMON_H__ */
index fc944a3..0d90e7b 100755 (executable)
@@ -57,6 +57,8 @@ int sensorhub_device::get_poll_fd(void)
 int sensorhub_device::get_sensors(const sensor_info_t **sensors)
 {
        int size;
+
+       retvm_if(sensors == NULL || sensors == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "sensorhub_device:NULL interface");
        size = manager->get_sensors(sensors);
 
        return size;