Tizen 2.4 SDK Rev6 Release accepted/tizen_2.4_mobile tizen_2.4 accepted/tizen/2.4/mobile/20160530.220254 submit/tizen_2.4/20160530.023137
authorJaekyu Park <jk7744.park@samsung.com>
Fri, 27 May 2016 08:05:41 +0000 (17:05 +0900)
committerJaekyu Park <jk7744.park@samsung.com>
Fri, 27 May 2016 08:05:41 +0000 (17:05 +0900)
doc/sensor_doc.h
include/sensor.h
src/sensor.cpp

index 73f26b7..9140390 100644 (file)
@@ -61,7 +61,7 @@
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
  *
 */
 
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
  *
  */
 
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
  *
  *
  */
index bed17ca..95ef440 100644 (file)
@@ -164,8 +164,6 @@ typedef enum
  * @brief Checks whether a given sensor type is available on a device.
  * @details Availability of a sensor should be checked first because this sensor may not be supported on the device.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @remarks For getting a handle of HRM Sensor(including HRM_LED_GREEN, HRM_LED_IR and HRM_LED_RED)
- * the privilege should be set to, %http://tizen.org/privilege/healthinfo.
  *
  * @param[in]   type        The sensor type to check
  * @param[out]  supported   If @c true this sensor type is supported,
@@ -417,6 +415,10 @@ int sensor_listener_unset_accuracy_cb(sensor_listener_h listener);
 
 /**
  * @brief Gets sensor data.
+ * @details    This function may fail (return #SENSOR_ERROR_OPERATION_FAILED) if it is called before the sensor is ready.
+ *                     In case of interval-driven sensors,
+ *                     it is recommended to call the function after at least one sensor event is delivered.
+ *                     Otherwise, applications can retry to call this function to be sure that the sensor is ready.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in]   listener    The listener handle
@@ -428,6 +430,7 @@ int sensor_listener_unset_accuracy_cb(sensor_listener_h listener);
  * @retval      #SENSOR_ERROR_INVALID_PARAMETER    Invalid parameter
  * @retval      #SENSOR_ERROR_NOT_SUPPORTED        The sensor type is not supported in the current device
  * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED     Operation failed
  *
  * @pre In order to read sensor data, an application should call sensor_listener_start().
  */
@@ -476,7 +479,7 @@ int sensor_listener_set_max_batch_latency(sensor_listener_h listener, unsigned i
 
 /**
  * @brief Changes the option of the sensor.
- * @details If it is default, sensor data cannot be recieved when the LCD is off and in the power save mode.
+ * @details If it is default, sensor data cannot be received when the LCD is off and in the power save mode.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in]   listener        The listener handle
index 100fc3c..95847f9 100644 (file)
@@ -110,8 +110,8 @@ static sensor_type_t _sensor_type_to_internal_type(sensor_type_e type)
 
 int sensor_is_supported(sensor_type_e type, bool *supported)
 {
+       int result;
        sensor_t sensor;
-       bool _supported;
        sensor_type_t internal_type;
 
        if (type < SENSOR_ALL || type > SENSOR_CUSTOM)
@@ -124,22 +124,29 @@ int sensor_is_supported(sensor_type_e type, bool *supported)
 
        internal_type = _sensor_type_to_internal_type(type);
 
-       sensor = sensord_get_sensor(internal_type);
-       _supported = false;
+       result = sensord_get_default_sensor(internal_type, &sensor);
 
-       if (sensor)
-               _supported = true;
+       if (result == -EIO)
+               return SENSOR_ERROR_OPERATION_FAILED;
+
+       *supported = false;
 
-       *supported = _supported;
+       /*
+        *  because sensor_is_supported() is N/P API,
+        *  it must not return SENSOR_ERROR_PERMISSION_DENIED error
+        *  -EACCES means that there is at least one sensor.
+        */
+       if (sensor || (result == -EACCES))
+               *supported = true;
 
-       _D("success sensor(%d) is supported[%d] : sensor[0x%x]",
-               type, _supported, sensor);
+       _D("success sensor(%d) is supported[%d]", type, *supported);
 
        return SENSOR_ERROR_NONE;
 }
 
 int sensor_get_default_sensor(sensor_type_e type, sensor_h *sensor)
 {
+       int result;
        sensor_t _sensor;
        sensor_privilege_t privilege;
        sensor_type_t internal_type;
@@ -154,9 +161,13 @@ int sensor_get_default_sensor(sensor_type_e type, sensor_h *sensor)
 
        internal_type = _sensor_type_to_internal_type(type);
 
-       _sensor = sensord_get_sensor(internal_type);
+       result = sensord_get_default_sensor(internal_type, &_sensor);
 
-       if (!_sensor)
+       if (result == -EACCES)
+               return SENSOR_ERROR_PERMISSION_DENIED;
+       else if (result == -EPERM)
+               return SENSOR_ERROR_OPERATION_FAILED;
+       else if (result == -ENODATA)
                return SENSOR_ERROR_NOT_SUPPORTED;
 
        sensord_get_privilege(_sensor, &privilege);
@@ -173,11 +184,12 @@ int sensor_get_default_sensor(sensor_type_e type, sensor_h *sensor)
 
 int sensor_get_sensor_list(sensor_type_e type, sensor_h **list, int *sensor_count)
 {
+       int result;
        sensor_h *_list = NULL;
        int count;
        sensor_type_t internal_type;
 
-       _D("called sensor_get_list : type[%d]");
+       _D("called sensor_get_list : type[%d]", type);
 
        if (type < SENSOR_ALL || type > SENSOR_CUSTOM)
                return SENSOR_ERROR_INVALID_PARAMETER;
@@ -187,7 +199,14 @@ int sensor_get_sensor_list(sensor_type_e type, sensor_h **list, int *sensor_coun
 
        internal_type = _sensor_type_to_internal_type(type);
 
-       sensord_get_sensor_list(internal_type, &_list, &count);
+       result = sensord_get_sensors(internal_type, &_list, &count);
+
+       if (result == -EACCES)
+               return SENSOR_ERROR_PERMISSION_DENIED;
+       else if (result == -EIO)
+               return SENSOR_ERROR_OPERATION_FAILED;
+       else if (result == -ENODATA)
+               return SENSOR_ERROR_NOT_SUPPORTED;
 
        int i, j;
        int count_public = 0;