feedback: Add feedback_put_theme_ids_internal() 70/303270/1 accepted/tizen/8.0/unified/20240111.160639
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 19 Dec 2023 08:43:41 +0000 (17:43 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 22 Dec 2023 07:17:00 +0000 (16:17 +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 c2a71ca..2a9a02d 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,10 +253,25 @@ 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
  *          It play specific type of system pre-defined pattern with priority.
index 5f4c867..ef0a639 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 46586f5..0fbdff3 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 5447c83..d9fff2a 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 1b93d8e..23b6a02 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);