feedback: Add feedback_put_theme_ids_internal() 39/303339/1
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 19 Dec 2023 08:43:41 +0000 (17:43 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Tue, 26 Dec 2023 04:15:36 +0000 (13:15 +0900)
This function is added to feedback.
- int feedback_put_theme_ids_internal(unsigned int **theme_ids);
    - This function free the array of theme ids from feedback_get_theme_ids_internal().

After use the array of theme id, it should be freed by caller.
Also, it is possible for the user to release the array directly.

Change-Id: I7d2f2a4456d9e6662c59e3360a1eb0a5490ed6b1
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
include/feedback-internal.h
src/feedback.c
tests/main.c
tests/test-feedback-internal.c
tests/test-feedback-internal.h

index c2a71ca4b1b1fe5f793f179d44f50a4331a96242..2a9a02d405927ee54929b6523313a1aae3acc01f 100755 (executable)
@@ -242,6 +242,7 @@ int feedback_stop_type_internal(feedback_type_e feedback_type);
  * @brief Gets the array of theme id supported.
  * @details This function gets all theme id as defined in the conf file.
  *          The theme id is positive value according to conf file.
+ *          After using theme ids, it should be freed by caller.
  * @since_tizen 7.0
  * @param[in] type The feedback type
  * @param[out] count_of_theme This means size of theme id array
@@ -252,9 +253,24 @@ int feedback_stop_type_internal(feedback_type_e feedback_type);
  * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted
  * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
+ * @see feedback_put_theme_ids_internal()
  */
 int feedback_get_theme_ids_internal(feedback_type_e feedback_type, unsigned int *count_of_theme, unsigned int **theme_ids);
 
+/**
+ * @brief Free the array of theme id.
+ * @details This function free the array of theme ids from feedback_get_theme_ids_internal()
+ *          Also, it is possible for the user to release the array directly.
+ * @since_tizen 7.0
+ * @param[in] theme_ids The Address of theme id array
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #FEEDBACK_ERROR_NONE Successful
+ * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see feedback_get_theme_ids_internal()
+ */
+int feedback_put_theme_ids_internal(unsigned int **theme_ids);
+
 /**
  * @brief Plays specific type of reactions that are pre-defined with priority.
  * @details This function can be used to react to pre-defined actions. \n
index 5f4c867afab919c0d854a208081e7434a064299a..ef0a639ce72030b843f60a14740ca26c00eb5c7a 100644 (file)
@@ -694,6 +694,17 @@ API int feedback_get_theme_ids_internal(feedback_type_e feedback_type, unsigned
        return FEEDBACK_ERROR_NONE;
 }
 
+API int feedback_put_theme_ids_internal(unsigned int **theme_ids)
+{
+       if (!theme_ids || !*theme_ids)
+               return FEEDBACK_ERROR_INVALID_PARAMETER;
+
+       free(*theme_ids);
+       *theme_ids = NULL;
+
+       return FEEDBACK_ERROR_NONE;
+}
+
 API int feedback_play_type_with_flags_internal(feedback_type_e type, feedback_pattern_internal_e internal_pattern, feedback_flag_e flag)
 {
        const struct device_ops *dev;
index 46586f56396b0144828f32fe185ca7ac17f9104c..0fbdff3c58f08f25a89bad3aec23832cde80652e 100644 (file)
@@ -31,6 +31,7 @@ void test_all()
        LOG_RESULT(TEST_FEEDBACK_GET_SOUND_THEME_ID_INTERNAL(), "TEST_FEEDBACK_GET_SOUND_THEME_ID_INTERNAL");
        LOG_RESULT(TEST_FEEDBACK_SET_SOUND_THEME_ID_INTERNAL(), "TEST_FEEDBACK_SET_SOUND_THEME_ID_INTERNAL");
        LOG_RESULT(TEST_FEEDBACK_GET_SOUND_THEME_IDS_INTERNAL(), "TEST_FEEDBACK_GET_SOUND_THEME_IDS_INTERNAL");
+       LOG_RESULT(TEST_FEEDBACK_PUT_SOUND_THEME_IDS_INTERNAL(), "TEST_FEEDBACK_PUT_SOUND_THEME_IDS_INTERNAL");
        LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE_WITH_FLAGS_INTERNAL(), "TEST_FEEDBACK_PLAY_TYPE_WITH_FLAGS_INTERNAL");
 }
 
index 5447c8302ce9571cef7931ef58a3edb9a14a0c7f..d9fff2aea17545de3d5cac5ca2b3ed78746aa820 100644 (file)
@@ -441,6 +441,30 @@ bool TEST_FEEDBACK_GET_SOUND_THEME_IDS_INTERNAL(void)
        REPORT_AND_RETURN();
 }
 
+static void test_put_sound_theme_ids_internal(void)
+{
+       unsigned int count_of_theme = 0;
+       unsigned int *sound_theme_ids = NULL;
+
+       feedback_initialize();
+       RESULT(feedback_put_theme_ids_internal(&sound_theme_ids),
+               FEEDBACK_ERROR_INVALID_PARAMETER, "invalid parameter");
+       RESULT(feedback_put_theme_ids_internal(NULL),
+               FEEDBACK_ERROR_INVALID_PARAMETER, "invalid parameter");
+
+       feedback_get_theme_ids_internal(FEEDBACK_TYPE_SOUND, &count_of_theme, &sound_theme_ids);
+       RESULT(feedback_put_theme_ids_internal(&sound_theme_ids),
+               FEEDBACK_ERROR_NONE, "error none");
+       feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_PUT_SOUND_THEME_IDS_INTERNAL(void)
+{
+       INIT();
+       test_put_sound_theme_ids_internal();
+       REPORT_AND_RETURN();
+}
+
 static void test_feedback_play_type_with_flags_internal(void)
 {
        feedback_initialize();
index 1b93d8e441301f997b06c5ff732ee88b6b3a3f45..23b6a02eb71ccfc33dcbeba35f2272b0d5159743 100644 (file)
@@ -124,6 +124,7 @@ bool TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(void);
 bool TEST_FEEDBACK_GET_SOUND_THEME_ID_INTERNAL(void);
 bool TEST_FEEDBACK_SET_SOUND_THEME_ID_INTERNAL(void);
 bool TEST_FEEDBACK_GET_SOUND_THEME_IDS_INTERNAL(void);
+bool TEST_FEEDBACK_PUT_SOUND_THEME_IDS_INTERNAL(void);
 bool TEST_FEEDBACK_PLAY_TYPE_WITH_FLAGS_INTERNAL(void);
 
 void TEST_INTERNAL_INIT(void);