2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <system_settings.h>
25 #include <system_settings_private.h>
34 #define LOG_TAG "TIZEN_N_SYSTEM_SETTINGS"
36 #define SYSTEM_SETTINGS_MAX -1
40 system_setting_s system_setting_table[] = {
43 SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE,
44 SYSTEM_SETTING_DATA_TYPE_STRING,
45 system_setting_get_incoming_call_ringtone,
46 system_setting_set_incoming_call_ringtone,
47 system_setting_set_changed_callback_incoming_call_ringtone,
48 system_setting_unset_changed_callback_incoming_call_ringtone,
50 system_setting_add_incoming_call_ringtone, /* ADD */
51 system_setting_del_incoming_call_ringtone, /* DEL */
52 system_setting_list_incoming_call_ringtone, /* LIST */
57 SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN,
58 SYSTEM_SETTING_DATA_TYPE_STRING,
59 system_setting_get_wallpaper_home_screen,
60 system_setting_set_wallpaper_home_screen,
61 system_setting_set_changed_callback_wallpaper_home_screen,
62 system_setting_unset_changed_callback_wallpaper_home_screen,
71 SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN,
72 SYSTEM_SETTING_DATA_TYPE_STRING,
73 system_setting_get_wallpaper_lock_screen,
74 system_setting_set_wallpaper_lock_screen,
75 system_setting_set_changed_callback_wallpaper_lock_screen,
76 system_setting_unset_changed_callback_wallpaper_lock_screen,
85 SYSTEM_SETTINGS_KEY_FONT_SIZE,
86 SYSTEM_SETTING_DATA_TYPE_INT,
87 system_setting_get_font_size,
88 system_setting_set_font_size,
89 system_setting_set_changed_callback_font_size,
90 system_setting_unset_changed_callback_font_size,
99 SYSTEM_SETTINGS_KEY_FONT_TYPE,
100 SYSTEM_SETTING_DATA_TYPE_STRING,
101 system_setting_get_font_type,
102 system_setting_set_font_type,
103 system_setting_set_changed_callback_font_type,
104 system_setting_unset_changed_callback_font_type,
113 SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION,
114 SYSTEM_SETTING_DATA_TYPE_BOOL,
115 system_setting_get_motion_activation,
116 system_setting_set_motion_activation,
117 system_setting_set_changed_callback_motion_activation,
118 system_setting_unset_changed_callback_motion_activation,
127 SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE,
128 SYSTEM_SETTING_DATA_TYPE_STRING,
129 system_setting_get_email_alert_ringtone,
130 system_setting_set_email_alert_ringtone,
131 system_setting_set_changed_callback_email_alert_ringtone,
132 system_setting_unset_changed_callback_email_alert_ringtone,
140 SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED,
141 SYSTEM_SETTING_DATA_TYPE_BOOL,
142 system_setting_get_usb_debugging_option,
143 system_setting_set_usb_debugging_option,
144 system_setting_set_changed_callback_usb_debugging_option,
145 system_setting_unset_changed_callback_usb_debugging_option,
153 SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED,
154 SYSTEM_SETTING_DATA_TYPE_BOOL,
155 system_setting_get_3g_data_network,
156 system_setting_set_3g_data_network,
157 system_setting_set_changed_callback_3g_data_network,
158 system_setting_unset_changed_callback_3g_data_network,
166 SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP,
167 SYSTEM_SETTING_DATA_TYPE_STRING,
168 system_setting_get_lockscreen_app,
169 system_setting_set_lockscreen_app,
170 system_setting_set_changed_callback_lockscreen_app,
171 system_setting_unset_changed_callback_lockscreen_app,
179 SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE,
180 SYSTEM_SETTING_DATA_TYPE_STRING,
181 system_setting_get_default_font_type,
192 SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY,
193 SYSTEM_SETTING_DATA_TYPE_STRING,
194 system_setting_get_locale_country,
195 system_setting_set_locale_country,
196 system_setting_set_changed_callback_locale_country,
197 system_setting_unset_changed_callback_locale_country,
205 SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE,
206 SYSTEM_SETTING_DATA_TYPE_STRING,
207 system_setting_get_locale_language,
208 system_setting_set_locale_language,
209 system_setting_set_changed_callback_locale_language,
210 system_setting_unset_changed_callback_locale_language,
218 SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR,
219 SYSTEM_SETTING_DATA_TYPE_BOOL,
220 system_setting_get_locale_timeformat_24hour,
221 system_setting_set_locale_timeformat_24hour,
222 system_setting_set_changed_callback_locale_timeformat_24hour,
223 system_setting_unset_changed_callback_locale_timeformat_24hour,
231 SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE,
232 SYSTEM_SETTING_DATA_TYPE_STRING,
233 system_setting_get_locale_timezone,
234 system_setting_set_locale_timezone,
235 system_setting_set_changed_callback_locale_timezone,
236 system_setting_unset_changed_callback_locale_timezone,
244 SYSTEM_SETTINGS_KEY_TIME_CHANGED,
245 SYSTEM_SETTING_DATA_TYPE_INT,
246 system_setting_get_time_changed,
248 system_setting_set_changed_callback_time_changed,
249 system_setting_unset_changed_callback_time_changed,
257 SYSTEM_SETTINGS_KEY_SOUND_LOCK,
258 SYSTEM_SETTING_DATA_TYPE_BOOL,
259 system_setting_get_sound_lock,
261 system_setting_set_changed_callback_sound_lock,
262 system_setting_unset_changed_callback_sound_lock,
270 SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE,
271 SYSTEM_SETTING_DATA_TYPE_BOOL,
272 system_setting_get_sound_silent_mode,
273 system_setting_set_sound_silent_mode,
274 system_setting_set_changed_callback_sound_silent_mode,
275 system_setting_unset_changed_callback_sound_silent_mode,
283 SYSTEM_SETTINGS_KEY_SOUND_TOUCH,
284 SYSTEM_SETTING_DATA_TYPE_BOOL,
285 system_setting_get_sound_touch,
287 system_setting_set_changed_callback_sound_touch,
288 system_setting_unset_changed_callback_sound_touch,
296 SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO,
297 SYSTEM_SETTING_DATA_TYPE_BOOL,
298 system_setting_get_auto_rotation_mode,
299 system_setting_set_auto_rotation_mode,
300 system_setting_set_changed_callback_auto_rotation_mode,
301 system_setting_unset_changed_callback_auto_rotation_mode,
309 SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME,
310 SYSTEM_SETTING_DATA_TYPE_INT,
311 system_setting_get_screen_backlight_time,
312 system_setting_set_screen_backlight_time,
313 system_setting_set_changed_callback_screen_backlight_time,
314 system_setting_unset_changed_callback_screen_backlight_time,
322 SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION,
323 SYSTEM_SETTING_DATA_TYPE_STRING,
324 system_setting_get_sound_notification,
325 system_setting_set_sound_notification,
326 system_setting_set_changed_callback_sound_notification,
327 system_setting_unset_changed_callback_sound_notification,
335 SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD,
336 SYSTEM_SETTING_DATA_TYPE_INT,
337 system_setting_get_notification_repetition_period,
338 system_setting_set_notification_repetition_period,
339 system_setting_set_changed_callback_notification_repetition_period,
340 system_setting_unset_changed_callback_notification_repetition_period,
348 SYSTEM_SETTINGS_KEY_DEVICE_NAME,
349 SYSTEM_SETTING_DATA_TYPE_STRING,
350 system_setting_get_device_name,
352 system_setting_set_changed_callback_device_name,
353 system_setting_unset_changed_callback_device_name,
361 SYSTEM_SETTINGS_KEY_MOTION_ENABLED,
362 SYSTEM_SETTING_DATA_TYPE_BOOL,
363 system_setting_get_motion_activation,
365 system_setting_set_changed_callback_motion_activation,
366 system_setting_unset_changed_callback_motion_activation,
374 SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE,
375 SYSTEM_SETTING_DATA_TYPE_BOOL,
376 system_setting_get_network_flight_mode,
378 system_setting_set_changed_callback_network_flight_mode,
379 system_setting_unset_changed_callback_network_flight_mode,
387 SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION,
388 SYSTEM_SETTING_DATA_TYPE_BOOL,
389 system_setting_get_network_wifi_notification,
391 system_setting_set_changed_callback_network_wifi_notification,
392 system_setting_unset_changed_callback_network_wifi_notification,
400 SYSTEM_SETTINGS_KEY_LOCK_STATE,
401 SYSTEM_SETTING_DATA_TYPE_INT,
402 system_setting_get_lock_state,
403 system_setting_set_lock_state,
404 system_setting_set_changed_callback_lock_state,
405 system_setting_unset_changed_callback_lock_state,
413 SYSTEM_SETTINGS_KEY_ADS_ID,
414 SYSTEM_SETTING_DATA_TYPE_STRING,
415 system_setting_get_ads_id,
416 system_setting_set_ads_id,
417 system_setting_set_changed_callback_ads_id,
418 system_setting_unset_changed_callback_ads_id,
427 SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE,
428 SYSTEM_SETTING_DATA_TYPE_INT,
429 system_setting_get_uds_state,
431 system_setting_set_changed_callback_uds_state,
432 system_setting_unset_changed_callback_uds_state,
437 SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST,
438 SYSTEM_SETTING_DATA_TYPE_STRING,
441 system_setting_set_changed_callback_uds_pkg_list,
442 system_setting_unset_changed_callback_uds_pkg_list,
447 SYSTEM_SETTINGS_MAX, -1, NULL, NULL, NULL, NULL, NULL, NULL
452 static void _dump_context()
455 /*int max = SYSTEM_SETTINGS_MAX; */
456 int max = sizeof(system_setting_table) / sizeof(system_setting_s) - 1 ;
458 for (i = 0; i < max; i++) {
459 LOGE("[%s] system_setting_table[i].key = %d", __FUNCTION__, system_setting_table[i].key);
460 LOGE("[%s] system_setting_table[i].data_type = %d", __FUNCTION__, system_setting_table[i].data_type);
461 LOGE("[%s] system_setting_table[i].get_value_cb = %x", __FUNCTION__, system_setting_table[i].get_value_cb);
462 LOGE("[%s] system_setting_table[i].set_value_cb = %x", __FUNCTION__, system_setting_table[i].set_value_cb);
464 LOGE("[%s] system_setting_table[i].set_changed_cb = %x <---", __FUNCTION__, system_setting_table[i].set_changed_cb);
465 LOGE("[%s] system_setting_table[i].unset_changed_cb = %x", __FUNCTION__, system_setting_table[i].unset_changed_cb);
466 LOGE("[%s] system_setting_table[i].changed_cb = %x", __FUNCTION__, system_setting_table[i].changed_cb);
471 /* LCOV_EXCL_START */
472 static int _dump_context_node(int key)
476 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
477 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
480 while (system_setting_table[index].key != SYSTEM_SETTINGS_MAX) {
481 if (system_setting_table[index].key == key) {
483 LOGE("[%s] system_setting_table[i].key = %d", __FUNCTION__, system_setting_table[i].key);
484 LOGE("[%s] system_setting_table[i].data_type = %d", __FUNCTION__, system_setting_table[i].data_type);
485 LOGE("[%s] system_setting_table[i].get_value_cb = %x", __FUNCTION__, system_setting_table[i].get_value_cb);
486 LOGE("[%s] system_setting_table[i].set_value_cb = %x", __FUNCTION__, system_setting_table[i].set_value_cb);
487 LOGE("[%s] system_setting_table[i].set_changed_cb = %x <---", __FUNCTION__, system_setting_table[i].set_changed_cb);
488 LOGE("[%s] system_setting_table[i].unset_changed_cb = %x", __FUNCTION__, system_setting_table[i].unset_changed_cb);
489 LOGE("[%s] system_setting_table[i].changed_cb = %x", __FUNCTION__, system_setting_table[i].changed_cb);
499 int system_settings_get_item(system_settings_key_e key, system_setting_h *item)
501 LOGE("Enter [%s], key=%d", __FUNCTION__, key);
503 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
504 LOGE("Enter [%s] catch invalid parameter error (%d) ", __FUNCTION__, key);
505 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
511 while (system_setting_table[index].key != SYSTEM_SETTINGS_MAX) {
512 if (system_setting_table[index].key == key) {
513 *item = &system_setting_table[index];
514 LOGE("Enter [%s], index = %d, key = %d, type = %d", __FUNCTION__, index, key, (*item)->data_type);
515 return SYSTEM_SETTINGS_ERROR_NONE;
521 return TIZEN_ERROR_INVALID_PARAMETER;
524 int system_settings_get_value(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
526 LOGE("Enter [%s]", __FUNCTION__);
527 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
528 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
531 system_setting_h system_setting_item;
532 system_setting_get_value_cb system_setting_getter;
534 if (0 != system_settings_get_item(key, &system_setting_item)) {
535 _dump_context_node(key);
536 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key --- (%d)", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER, key);
537 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
540 if (system_setting_item->data_type != data_type) {
541 _dump_context_node(key);
542 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid data type --- key : (%d), datatype:(%d)", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER, key, data_type);
543 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
546 system_setting_getter = system_setting_item->get_value_cb;
548 if (system_setting_getter == NULL) {
549 LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_IO_ERROR);
550 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
553 return system_setting_getter(key, system_setting_item->data_type, value);
556 /* LCOV_EXCL_START */
557 int system_settings_set_value(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
559 LOGE("Enter [%s]", __FUNCTION__);
560 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) {
561 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
565 system_setting_h system_setting_item;
566 system_setting_set_value_cb system_setting_setter;
568 int ret = system_settings_get_item(key, &system_setting_item);
571 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
572 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
576 if (system_setting_item->data_type != data_type) {
577 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid data type", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
578 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
581 system_setting_setter = system_setting_item->set_value_cb;
583 if (system_setting_setter == NULL) {
584 LOGE("[%s] IO_ERROR(0x%08x) : failed to call setter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED);
585 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
588 return system_setting_setter(key, system_setting_item->data_type, value);
594 int system_settings_add_value(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
596 LOGE("Enter [%s]", __FUNCTION__);
597 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) {
598 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
602 system_setting_h system_setting_item;
603 system_setting_add_value_cb system_setting_adder;
605 int ret = system_settings_get_item(key, &system_setting_item);
608 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
609 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
613 if (system_setting_item->data_type != data_type) {
614 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid data type", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
615 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
618 system_setting_adder = system_setting_item->add_value_cb;
620 if (system_setting_adder == NULL) {
621 LOGE("[%s] IO_ERROR(0x%08x) : failed to call setter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED);
622 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
625 return system_setting_adder(key, system_setting_item->data_type, value);
629 int system_settings_del_value(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
631 LOGE("Enter [%s]", __FUNCTION__);
632 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) {
633 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
637 system_setting_h system_setting_item;
638 system_setting_del_value_cb system_setting_deler;
640 int ret = system_settings_get_item(key, &system_setting_item);
643 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
644 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
648 if (system_setting_item->data_type != data_type) {
649 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid data type", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
650 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
653 system_setting_deler = system_setting_item->del_value_cb;
655 if (system_setting_deler == NULL) {
656 LOGE("[%s] IO_ERROR(0x%08x) : failed to call setter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED);
657 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
660 return system_setting_deler(key, system_setting_item->data_type, value);
667 int system_settings_list_value(system_settings_key_e key, system_setting_data_type_e data_type, bool (*system_setting_data_iterator)(int, const char* , void *), void *user_data)
669 LOGE("Enter [%s]", __FUNCTION__);
670 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
671 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
675 system_setting_h system_setting_item;
676 system_setting_list_value_cb system_setting_lister;
678 int ret = system_settings_get_item(key, &system_setting_item);
681 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
682 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
686 if (system_setting_item->data_type != data_type) {
687 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid data type", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
688 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
691 //system_setting_list_value_cb list_changed_cb;
692 system_setting_lister = system_setting_item->list_value_cb;
694 if (system_setting_lister == NULL) {
695 LOGE("[%s] IO_ERROR(0x%08x) : failed to call setter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED);
696 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
699 return system_setting_lister(key, system_setting_item->data_type, system_setting_data_iterator, user_data);
707 /* LCOV_EXCL_START */
708 int system_settings_set_value_int(system_settings_key_e key, int value)
710 LOGE("Enter [%s]", __FUNCTION__);
711 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
712 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
717 return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_INT, (void *)p_ptr);
721 int system_settings_get_value_int(system_settings_key_e key, int *value)
723 LOGE("Enter [%s]", __FUNCTION__);
724 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
725 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
728 int *ptr = &value_int;
731 ret = system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_INT, (void **)p_ptr);
736 /* LCOV_EXCL_START */
737 int system_settings_set_value_bool(system_settings_key_e key, bool value)
739 LOGE("Enter [%s]", __FUNCTION__);
740 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
741 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
745 return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_BOOL, (void *)ptr);
749 int system_settings_get_value_bool(system_settings_key_e key, bool *value)
751 LOGE("Enter [%s]", __FUNCTION__);
752 SETTING_TRACE(" SIGNED LONG here ******************* log here *************** ");
753 signed long flag = 0;
757 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
758 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
761 ret = system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_BOOL, (void **)&flag);
762 SETTING_TRACE(" inf (flag) value : %d ", flag);
765 SETTING_TRACE(" flag == 0 ");
766 } else if (flag == 1) {
768 SETTING_TRACE(" flag == 1 ");
771 SETTING_TRACE(" exception here!!! ");
777 /* LCOV_EXCL_START */
778 int system_settings_set_value_string(system_settings_key_e key, const char *value)
780 LOGE("Enter [%s]", __FUNCTION__);
781 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
782 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
786 if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE)
787 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
789 return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, (void *)value);
793 int system_settings_get_value_string(system_settings_key_e key, char **value)
795 LOGE("Enter [%s]", __FUNCTION__);
796 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
797 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
800 return system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, (void **)value);
805 int system_settings_set_changed_cb(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
807 LOGE("Enter [%s]", __FUNCTION__);
808 system_setting_h system_setting_item;
809 system_setting_set_changed_callback_cb system_setting_set_changed_cb;
811 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
812 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
815 if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE)
816 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
818 if (system_settings_get_item(key, &system_setting_item)) {
819 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
820 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
823 system_setting_set_changed_cb = system_setting_item->set_changed_cb;
826 /* Store the callback function from application side */
828 system_setting_item->changed_cb = callback;
831 system_setting_item->user_data = user_data;
833 if (system_setting_set_changed_cb == NULL) {
834 LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_IO_ERROR);
835 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
838 return system_setting_set_changed_cb(key, callback, user_data);
842 int system_settings_unset_changed_cb(system_settings_key_e key)
844 LOGE("Enter [%s]", __FUNCTION__);
845 system_setting_h system_setting_item;
846 system_setting_unset_changed_callback_cb system_setting_unset_changed_cb;
848 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
849 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
852 if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE)
853 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
855 int ret = system_settings_get_item(key, &system_setting_item) ;
857 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
858 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
861 system_setting_unset_changed_cb = system_setting_item->unset_changed_cb;
863 /* free the callback function from application side */
864 if (system_setting_item->changed_cb)
865 system_setting_item->changed_cb = NULL;
866 /*----------------------------------------------------- */
868 if (system_setting_unset_changed_cb == NULL) {
869 LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_IO_ERROR);
870 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
873 return system_setting_unset_changed_cb(key);
876 //////////////////////////////////////////////////////////////////////////////////////////////////
878 //////////////////////////////////////////////////////////////////////////////////////////////////
880 int system_settings_foreach_value_string(system_settings_key_e key, system_settings_iter_cb callback, void *value)
882 LOGE("Enter [%s]", __FUNCTION__);
883 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
884 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
887 return system_settings_list_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, callback, (void *)value);
890 //////////////////////////////////////////////////////////////////////////////////////////////////
892 //////////////////////////////////////////////////////////////////////////////////////////////////
894 int system_settings_add_value_string(system_settings_key_e key, const char* value)
896 LOGE("Enter [%s]", __FUNCTION__);
897 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
898 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
901 return system_settings_add_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, (void *)value);
904 //////////////////////////////////////////////////////////////////////////////////////////////////
906 //////////////////////////////////////////////////////////////////////////////////////////////////
908 int system_settings_delete_value_string(system_settings_key_e key, const char* value)
910 LOGE("Enter [%s]", __FUNCTION__);
911 if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) {
912 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
915 return system_settings_del_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, (void *)value);