int feedback_play_type_by_name(char *type, char *pattern);
/**
+ * @brief Plays various types of reactions that are pre-defined.
+ * @details This function can be used to react to pre-defined actions. \n
+ * It play various types of system pre-defined media or vibration patterns.
+ * @since_tizen 4.0
+ * @remarks Currently, there are two types of reactions: sound and vibration. \n
+ * Depending on the settings, some types cannot operate.
+ * For example, when set to silent mode, the device doesn't produce any sound.
+ * If to play one of the devices is successful, this function regards as success.
+ * And for controlling haptic device, the privilege should be set to, %http://tizen.org/privilege/haptic.
+ * If you don't have the haptic privilege, it only works sound operation.
+ * It does not return any error in this case.
+ * @param[in] pattern The pre-defined internal pattern
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #FEEDBACK_ERROR_NONE Successful
+ * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted
+ * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
+ * @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized
+ * @pre feedback_initialize()
+ */
+int feedback_play_internal(feedback_pattern_internal_e pattern);
+
+/**
+ * @brief Plays specific type of reactions that are pre-defined.
+ * @details This function can be used to react to pre-defined actions. \n
+ * It play specific type of system pre-defined pattern.
+ * @since_tizen 4.0
+ * @remarks Currently, there are two types of reactions: sound and vibration. \n
+ * Depending on the settings, some types cannot operate.
+ * For example, when set to silent mode, the device doesn't produce any sound.
+ * And for controlling haptic device, the privilege should be set to, %http://tizen.org/privilege/haptic.
+ * If you don't have the haptic privilege, it returns FEEDBACK_ERROR_PERMISSION_DENIED error.
+ * @param[in] type The pattern type
+ * @param[in] pattern The pre-defined internal pattern
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #FEEDBACK_ERROR_NONE Successful
+ * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted
+ * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
+ * @retval #FEEDBACK_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized
+ * @pre feedback_initialize()
+ */
+int feedback_play_type_internal(feedback_type_e type, feedback_pattern_internal_e pattern);
+
+/**
* @brief Gets the file path of resource for the given feedback type and pattern.
* @details
* Depending on the type of each pattern resouorce has a different format. \n
return feedback_play_type(etype, epattern);
}
+API int feedback_play_internal(feedback_pattern_internal_e pattern)
+{
+ int err;
+ bool result;
+ int switched;
+
+ /* check initialize */
+ pthread_mutex_lock(&fmutex);
+ if (!init_cnt) {
+ _E("Not initialized"); //LCOV_EXCL_LINE
+ pthread_mutex_unlock(&fmutex);
+ return FEEDBACK_ERROR_NOT_INITIALIZED;
+ }
+ pthread_mutex_unlock(&fmutex);
+
+ if (pattern <= FEEDBACK_PATTERN_NONE ||
+ pattern >= profile->max_pattern) {
+ _E("Invalid parameter : pattern(%d)", pattern);
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
+ }
+
+ /* if you need to switch pattern */
+ if (profile->get_switched_pattern) {
+ result = profile->get_switched_pattern(pattern, &switched);
+ if (result) {
+ _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
+ profile->str_pattern(pattern), profile->str_pattern(switched));
+ pattern = switched;
+ }
+ }
+
+ /* play all device */
+ err = devices_play(pattern);
+ /**
+ * devices_play() returns error even if all devices are failed.
+ * It means if to play anything is successful,
+ * this function regards as success.
+ */
+ if (err == -ENOTSUP)
+ return FEEDBACK_ERROR_NOT_SUPPORTED;
+ else if (err < 0)
+ return FEEDBACK_ERROR_OPERATION_FAILED;
+
+ return FEEDBACK_ERROR_NONE;
+}
+
+API int feedback_play_type_internal(feedback_type_e type, feedback_pattern_internal_e pattern)
+{
+ const struct device_ops *dev;
+ int err;
+ bool result;
+ int switched;
+
+ /* check initialize */
+ pthread_mutex_lock(&fmutex);
+ if (!init_cnt) {
+ _E("Not initialized"); //LCOV_EXCL_LINE
+ pthread_mutex_unlock(&fmutex);
+ return FEEDBACK_ERROR_NOT_INITIALIZED;
+ }
+ pthread_mutex_unlock(&fmutex);
+
+ if (type <= FEEDBACK_TYPE_NONE ||
+ type >= profile->max_type) {
+ _E("Invalid parameter : type(%d)", type);
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
+ }
+
+ if (pattern <= FEEDBACK_PATTERN_INTERNAL_NONE ||
+ pattern >= profile->max_pattern) {
+ _E("Invalid parameter : pattern(%d)", pattern);
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
+ }
+
+ /* if you need to switch pattern */
+ if (profile->get_switched_pattern) {
+ result = profile->get_switched_pattern(pattern, &switched);
+ if (result) {
+ _W("pattern is changed : (%s) -> (%s)", //LCOV_EXCL_LINE
+ profile->str_pattern(pattern), profile->str_pattern(switched));
+ pattern = switched;
+ }
+ }
+
+ /* play proper device */
+ dev = find_device(type);
+ if (!dev) {
+ _E("Not supported device : type(%s)", profile->str_type[type]); //LCOV_EXCL_LINE
+ return FEEDBACK_ERROR_NOT_SUPPORTED;
+ }
+
+ err = dev->play(pattern);
+ if (err == -ENOTSUP)
+ return FEEDBACK_ERROR_NOT_SUPPORTED;
+ else if (err == -ECOMM || err == -EACCES)
+ return FEEDBACK_ERROR_PERMISSION_DENIED;
+ else if (err < 0)
+ return FEEDBACK_ERROR_OPERATION_FAILED;
+
+ return FEEDBACK_ERROR_NONE;
+}
+
API int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e pattern, char** path)
{
const struct device_ops *dev;