Add haptic feature 43/177643/11 accepted/tizen/unified/20180611.132133 submit/tizen/20180611.005638
authorpr.jung <pr.jung@samsung.com>
Wed, 2 May 2018 10:11:22 +0000 (19:11 +0900)
committerpr.jung <pr.jung@samsung.com>
Tue, 15 May 2018 07:57:52 +0000 (16:57 +0900)
Change-Id: Ia4368aaf2dde249acda91105a0e4a71f5b750fe6
Signed-off-by: pr.jung <pr.jung@samsung.com>
doc/feedback_doc.h
include/feedback-internal.h
include/feedback.h
src/feedback.c
src/sound.c
src/vibrator.c

index ef3b17f..24d3ce5 100755 (executable)
  * @section CAPI_SYSTEM_FEEDBACK_MODULE_OVERVIEW Overview
  * The FEEDBACK API is responsible for playing simple sound and vibration.
  * It plays sound using mm-sound library and vibration with system framework.
+
+ * @section CAPI_SYSTEM_FEEDBACK_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - %http://tizen.org/feature/feedback.vibration\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * 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="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature List</b>.</a>
+ *
  *
  */
 
index d846d64..939f1af 100644 (file)
@@ -20,7 +20,7 @@
 #define __FEEDBACK_INTERNAL_H__
 
 #include <tizen_error.h>
-#include "feedback-ids.h"
+#include <feedback-ids.h>
 #include "feedback-ids-internal.h"
 
 #ifdef __cplusplus
index f9b1f1f..533eb07 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <tizen.h>
 #include <tizen_error.h>
-#include "feedback-ids.h"
+#include <feedback-ids.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -65,6 +65,7 @@ typedef enum {
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #FEEDBACK_ERROR_NONE Successful
+ * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
  * @post feedback_deinitialize()
  * @see feedback_deinitialize()
  */
@@ -83,6 +84,7 @@ int feedback_initialize(void);
  *         otherwise a negative error value
  * @retval #FEEDBACK_ERROR_NONE Successful
  * @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
  * @pre feedback_initialize()
  * @see feedback_initialize()
  */
index f8617dd..f8e0dab 100644 (file)
@@ -463,7 +463,7 @@ API int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e patt
        }
 
        if (type == FEEDBACK_TYPE_VIBRATION)
-               return FEEDBACK_ERROR_NOT_SUPPORTED;
+               return FEEDBACK_ERROR_INVALID_PARAMETER;
 
        if (pattern <= FEEDBACK_PATTERN_NONE ||
            pattern >= profile->max_pattern) {
@@ -502,7 +502,7 @@ API int feedback_set_resource_path(feedback_type_e type, feedback_pattern_e patt
 
        if (type == FEEDBACK_TYPE_VIBRATION) {
                _E("Not supported type"); //LCOV_EXCL_LINE
-               return FEEDBACK_ERROR_NOT_SUPPORTED;
+               return FEEDBACK_ERROR_INVALID_PARAMETER;
        }
 
        /* proper device set path */
index f6fb699..3daa6f7 100644 (file)
@@ -28,7 +28,7 @@
 #include <vconf.h>
 #include <mm_sound_private.h>
 
-#include "feedback-ids.h"
+#include <feedback-ids.h>
 #include "profiles.h"
 #include "devices.h"
 #include "log.h"
index 5292fa8..616bfee 100644 (file)
@@ -25,6 +25,7 @@
 #include <limits.h>
 #include <vconf.h>
 #include <sys/stat.h>
+#include <system_info.h>
 
 #include "feedback.h"
 #include "profiles.h"
@@ -49,7 +50,9 @@ enum haptic_iteration {
 
 #define DEFAULT_DURATION            100
 #define SIP_DURATION                60
-#define WHITESPACE      " \t"
+#define WHITESPACE                  " \t"
+
+#define VIBRATION_FEATURE              "http://tizen.org/feature/feedback.vibration"
 
 static int vibstatus;
 static unsigned int v_handle;
@@ -156,6 +159,16 @@ static int get_priority(feedback_pattern_e pattern)
 static void vibrator_init(void)
 {
        int ret;
+       bool haptic_avail;
+
+       ret = system_info_get_platform_bool(VIBRATION_FEATURE, &haptic_avail);
+       if (ret < 0) {
+               v_handle = -ENOTSUP;
+               return;
+       } else if (ret == 0 && !haptic_avail) {
+               v_handle = -ENOTSUP;
+               return;
+       }
 
        /* Vibration Init */
        ret = haptic_open();