diff options
author | Yunhee Seo <yuni.seo@samsung.com> | 2023-09-13 10:39:30 +0900 |
---|---|---|
committer | Yunhee Seo <yuni.seo@samsung.com> | 2023-09-15 15:01:18 +0900 |
commit | 0c0c907296fe8b983be9ae43c9693a433a012d23 (patch) | |
tree | fe5b4a0b6fb4ae6646c0affd21cbf569b71255f5 | |
parent | 896c9b73692b9e2da5c1c52bd1f65dee8270c626 (diff) | |
download | libsvi-0c0c907296fe8b983be9ae43c9693a433a012d23.tar.gz libsvi-0c0c907296fe8b983be9ae43c9693a433a012d23.tar.bz2 libsvi-0c0c907296fe8b983be9ae43c9693a433a012d23.zip |
feedback: Add feedback_stop_type_internal()
To support feedback stop according to the feedback type.
With this, it is possible to stop sound feedback play.
"http://tizen.org/privilege/haptic" haptic privilege is required to stop the vibrator.
Change-Id: I4798f805be9f2a6bebc0d6f7da68011a98c3e4f1
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
-rwxr-xr-x | include/feedback-internal.h | 17 | ||||
-rw-r--r-- | src/devices.c | 13 | ||||
-rw-r--r-- | src/devices.h | 1 | ||||
-rw-r--r-- | src/feedback.c | 23 |
4 files changed, 54 insertions, 0 deletions
diff --git a/include/feedback-internal.h b/include/feedback-internal.h index 844b309..0562258 100755 --- a/include/feedback-internal.h +++ b/include/feedback-internal.h @@ -210,6 +210,23 @@ int feedback_get_theme_index_internal(feedback_type_e feedback_type, unsigned in int feedback_set_theme_index_internal(feedback_type_e feedback_type, unsigned int index_of_theme); /** + * @brief Stops various types of reactions by feedback type. + * @details This function can be used to stop reaction to pre-defined actions. + * It stops system pre-defined vibration and sound patterns. + * @since_tizen 7.0 + * @remarks To stop vibrator feedback, the privilege should be set to, %http://tizen.org/privilege/haptic. + * @param[in] feedback_type The feedback type + * @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 + */ +int feedback_stop_type_internal(feedback_type_e feedback_type); + +/** * @} */ diff --git a/src/devices.c b/src/devices.c index 1dc8252..f2daabd 100644 --- a/src/devices.c +++ b/src/devices.c @@ -148,3 +148,16 @@ int devices_stop(void) return ret; } //LCOV_EXCL_STOP + +int devices_stop_by_type(feedback_type_e feedback_type) +{ + GList *elem; + const struct device_ops *dev; + + SYS_G_LIST_FOREACH(dev_head, elem, dev) { + if (dev->type == feedback_type) + return dev->stop(); + } + + return -ENOTSUP; +} diff --git a/src/devices.h b/src/devices.h index 6a9aedb..e7cca85 100644 --- a/src/devices.h +++ b/src/devices.h @@ -44,6 +44,7 @@ void devices_exit(void); int devices_play(int pattern, bool always); int devices_play_soundpath(int pattern, const char *soundpath, bool always); int devices_stop(void); +int devices_stop_by_type(feedback_type_e feedback_type); #define DEVICE_OPS_REGISTER(dev) \ static void __CONSTRUCTOR__ module_init(void) \ diff --git a/src/feedback.c b/src/feedback.c index c0b6800..8750745 100644 --- a/src/feedback.c +++ b/src/feedback.c @@ -638,3 +638,26 @@ API int feedback_set_theme_index_internal(feedback_type_e feedback_type, unsigne return FEEDBACK_ERROR_NONE; } //LCOV_EXCL_STOP + +API int feedback_stop_type_internal(feedback_type_e feedback_type) +{ + int err; + + pthread_mutex_lock(&fmutex); + if (!init_cnt) { + _E("Not initialized"); + pthread_mutex_unlock(&fmutex); + return FEEDBACK_ERROR_NOT_INITIALIZED; + } + pthread_mutex_unlock(&fmutex); + + err = devices_stop_by_type(feedback_type); + if (err == -ENOTSUP) + return FEEDBACK_ERROR_NOT_SUPPORTED; + if (err == -ECOMM || err == -EACCES) + return FEEDBACK_ERROR_PERMISSION_DENIED; + if (err < 0) + return FEEDBACK_ERROR_OPERATION_FAILED; + + return FEEDBACK_ERROR_NONE; +} |