Allows getting feedback theme id array supported.
This function is added to feedback.
- int feedback_get_theme_ids_internal(feedback_type_e feedback_type,
unsigned int *count_of_theme, unsigned int **theme_ids);
- This function gets count of theme available and theme id array.
Test codes have also been added to check normal operation.
Change-Id: I396452314d9b87907bbc52658f788b8987bf67af
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
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.
+ * @since_tizen 7.0
+ * @param[in] type The feedback type
+ * @param[out] count_of_theme This means size of theme id array
+ * @param[out] theme_ids The theme id array
+ * @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
+ */
+int feedback_get_theme_ids_internal(feedback_type_e feedback_type, unsigned int *count_of_theme, unsigned int **theme_ids);
+
+/**
* @}
*/
int (*get_count_of_theme) (unsigned int *);
int (*get_theme_id) (unsigned int *);
int (*set_theme_id) (unsigned int);
+ int (*get_theme_ids) (unsigned int *, unsigned int **);
};
void devices_init(void);
return FEEDBACK_ERROR_OPERATION_FAILED;
return FEEDBACK_ERROR_NONE;
+}
+
+API int feedback_get_theme_ids_internal(feedback_type_e feedback_type, unsigned int *count_of_theme, unsigned int **theme_ids)
+{
+ const struct device_ops *dev = NULL;
+ int ret = 0;
+
+ 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 (feedback_type <= FEEDBACK_TYPE_NONE || feedback_type >= profile->max_type || !count_of_theme || !theme_ids) {
+ _E("Invalid parameter : type(%d)", feedback_type);
+ return FEEDBACK_ERROR_INVALID_PARAMETER;
+ }
+
+ dev = find_device(feedback_type);
+ if (!dev) {
+ _E("Not supported device : type(%s)", profile->str_type[feedback_type]);
+ return FEEDBACK_ERROR_NOT_SUPPORTED;
+ }
+
+ if (!dev->get_theme_ids)
+ return FEEDBACK_ERROR_NOT_SUPPORTED;
+
+ ret = dev->get_theme_ids(count_of_theme, theme_ids);
+ if (ret < 0)
+ return FEEDBACK_ERROR_OPERATION_FAILED;
+
+ return FEEDBACK_ERROR_NONE;
}
\ No newline at end of file
return 0;
}
+int sound_thememan_get_sound_theme_ids(unsigned int *count_of_theme, unsigned int **sound_theme_ids)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+ int get_id = 0;
+ int index = 0;
+ unsigned int *temp_sound_theme_ids = NULL;
+
+ if (!is_g_sound_theme_list_initialized())
+ return -EPERM;
+
+ g_hash_table_iter_init(&iter, g_sound_theme_list);
+ sound_thememan_get_number_of_theme(count_of_theme);
+
+ temp_sound_theme_ids = calloc(*count_of_theme, sizeof(unsigned int));
+ if (!temp_sound_theme_ids)
+ return -ENOMEM;
+
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ get_id = *(unsigned int*)key;
+ temp_sound_theme_ids[index++] = get_id;
+ }
+
+ *sound_theme_ids = g_steal_pointer(&temp_sound_theme_ids);
+ return 0;
+}
+
int sound_thememan_init(void)
{
g_sound_theme_list = g_hash_table_new_full(g_int_hash, g_int_equal, g_free,
int sound_thememan_get_sound_theme_info(unsigned int sound_theme_id, void *sound_info);
int sound_thememan_get_number_of_theme(unsigned int *number_of_theme);
int sound_thememan_add_sound_theme(unsigned int sound_theme_id, const char* conf_file_path);
+int sound_thememan_get_sound_theme_ids(unsigned int *count_of_theme, unsigned int **sound_theme_ids);
int sound_thememan_init(void);
void sound_thememan_exit(void);
return 0;
}
+static int sound_get_theme_ids(unsigned int *count_of_theme, unsigned int **theme_ids)
+{
+ int ret = 0;
+
+ if (!count_of_theme || !theme_ids)
+ return -EINVAL;
+
+ ret = sound_thememan_get_sound_theme_ids(count_of_theme, theme_ids);
+ if (ret < 0)
+ return -EPERM;
+
+ return 0;
+}
+
static const struct device_ops sound_device_ops = {
.type = FEEDBACK_TYPE_SOUND,
.name = "Sound",
.get_count_of_theme = sound_get_count_of_theme,
.get_theme_id = sound_get_theme_id,
.set_theme_id = sound_set_theme_id,
+ .get_theme_ids = sound_get_theme_ids,
};
DEVICE_OPS_REGISTER(&sound_device_ops);
.get_count_of_theme = NULL,
.set_theme_id = NULL,
.get_theme_id = NULL,
+ .get_theme_ids = NULL,
};
DEVICE_OPS_REGISTER(&vibrator_device_ops);
LOG_RESULT(TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(), "TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL");
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");
}
void show_usage()
REPORT_AND_RETURN();
}
+static void test_get_sound_theme_ids_internal(void)
+{
+ unsigned int count_of_theme = 0;
+ unsigned int *sound_theme_ids = NULL;
+ int index = 0;
+
+ feedback_initialize();
+ RESULT(feedback_get_theme_ids_internal(FEEDBACK_TYPE_VIBRATION, &count_of_theme, &sound_theme_ids),
+ FEEDBACK_ERROR_NOT_SUPPORTED, "not supported");
+ RESULT(feedback_get_theme_ids_internal(FEEDBACK_TYPE_SOUND, NULL, NULL),
+ FEEDBACK_ERROR_INVALID_PARAMETER, "invalid parameter");
+
+ feedback_get_theme_ids_internal(FEEDBACK_TYPE_SOUND, &count_of_theme, &sound_theme_ids);
+
+ for (index = 0; index < count_of_theme; index++)
+ {
+ RESULT(feedback_set_theme_id_internal(FEEDBACK_TYPE_SOUND, sound_theme_ids[index]),
+ FEEDBACK_ERROR_NONE, "error none");
+ }
+
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_GET_SOUND_THEME_IDS_INTERNAL(void)
+{
+ INIT();
+ test_get_sound_theme_ids_internal();
+ REPORT_AND_RETURN();
+}
+
void TEST_INTERNAL_INIT()
{
init_supported_pattern(FEEDBACK_TYPE_SOUND, pattern_s);
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);
void TEST_INTERNAL_INIT(void);