From: kiso.chang Date: Wed, 14 Jul 2021 09:50:55 +0000 (+0900) Subject: Add a fuction to select sound route for RPI X-Git-Tag: submit/tizen/20210715.064438^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bddf0683119b3151c3c52b2b1bb42ee4ce799a23;p=profile%2Fcommon%2Fapps%2Fnative%2Fsettings.git Add a fuction to select sound route for RPI Change-Id: I5006c0c4775fb2dd3340ab72c93681c0625b3e8a Signed-off-by: kiso.chang --- diff --git a/resource/po/en.po b/resource/po/en.po index 2107165..0cf6dd6 100644 --- a/resource/po/en.po +++ b/resource/po/en.po @@ -2769,3 +2769,6 @@ msgstr "show network status and other information." msgid "IDS_ST_BODY_THEME" msgstr "Theme" + +msgid "IDS_ST_BODY_SOUND_DEVICE" +msgstr "Sound device" diff --git a/resource/po/ko_KR.po b/resource/po/ko_KR.po index 7dc987e..91e89ec 100644 --- a/resource/po/ko_KR.po +++ b/resource/po/ko_KR.po @@ -2811,3 +2811,6 @@ msgstr "블루투스, Wi-Fi Direct 등에서 장치를 구별하기 위해 디 msgid "IDS_ST_BODY_THEME" msgstr "테마" + +msgid "IDS_ST_BODY_SOUND_DEVICE" +msgstr "사운드 장비" diff --git a/setting-profile/include/setting-profile.h b/setting-profile/include/setting-profile.h index f7343a4..85e438a 100644 --- a/setting-profile/include/setting-profile.h +++ b/setting-profile/include/setting-profile.h @@ -33,6 +33,8 @@ #include "setting-common-draw-widget.h" #include "setting-common-view.h" +#define KeyStr_SoundOut "IDS_ST_BODY_SOUND_DEVICE" + #define SETTING_PROFILE_ICON_PATH_CFG _TZ_SYS_RO_APP"/org.tizen.setting/res/icons/" #define VOLUME_APP_NAME "org.tizen.setting.volume" @@ -96,6 +98,7 @@ struct _SettingSoundData { Setting_GenGroupItem_Data *data_sound_when_ring; Setting_GenGroupItem_Data *data_notifiaction_on_lock_screen; Setting_GenGroupItem_Data *sound_mode; + Setting_GenGroupItem_Data *data_device; /* Feedback */ Setting_GenGroupItem_Data *data_lock_sound; @@ -114,6 +117,8 @@ struct _SettingSoundData { char *ringtone_type; int media_volume_changed_cb_id; + Evas_Object *device_popup; + /* for performance of incoming call ringtone slider */ Ecore_Idler *play_ringtone_idler; diff --git a/setting-profile/src/setting-profile-sound-main.c b/setting-profile/src/setting-profile-sound-main.c index ea64d07..6b77234 100755 --- a/setting-profile/src/setting-profile-sound-main.c +++ b/setting-profile/src/setting-profile-sound-main.c @@ -20,9 +20,6 @@ */ -#include -#include - #include "setting-profile.h" #include "setting-common-general-func.h" @@ -31,6 +28,10 @@ #include "setting-profile-sound-mode.h" #include "setting-profile-sound-mode-view.h" +#include +#include +#include + #define NOTIFICATIONS_ON_LOCK_SCREEN \ "http://tizen.org/appcontrol/operation/setting/notification_on_lock_screen" @@ -157,6 +158,70 @@ setting_view setting_view_sound_main = { .cleanup = NULL }; + +static void __vconf_change_cb(keynode_t *key, void *data) +{ + SETTING_TRACE_BEGIN; + setting_retm_if(NULL == key, "key is NULL"); + setting_retm_if(NULL == data, "data is NULL"); + char *vconf_name = vconf_keynode_get_name(key); + + if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE)) { + int stateDeveloperOption; + int err = vconf_get_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &stateDeveloperOption); + if (err != VCONF_OK) { + SETTING_TRACE_ERROR(">>>>>>>>>> Failed to get vconf[%s]", VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE); + } + } else { + SETTING_TRACE_ERROR("vconf_name is error"); + } +} + + +typedef struct { + sound_rpi_playback_route_type type; + char *description; +} SM_PBRouteType; + + +SM_PBRouteType type_strings[] = { + {SOUND_RPI_PLAYBACK_AUTO, "Auto"}, + {SOUND_RPI_PLAYBACK_HEADPHONE, "Headphone"}, + {SOUND_RPI_PLAYBACK_HDMI1, "HDMI1"}, + {SOUND_RPI_PLAYBACK_HDMI2, "HDMI2"}, +}; + +const char *getStringOfSoundRouteType(sound_rpi_playback_route_type type) +{ + SETTING_TRACE_BEGIN; + + int count = sizeof(type_strings)/sizeof(SM_PBRouteType); + + int i = 0; + while(i < count){ + if(type == type_strings[i].type){ + return type_strings[i].description; + } + i++; + } + + return _("IDS_ST_HEADER_UNAVAILABLE"); +} + +static const char *get_current_sounddevice_str() +{ + SETTING_TRACE_BEGIN; + + sound_rpi_playback_route_type type; + int ret = sound_manager_get_rpi_playback_route(&type); + SETTING_TRACE_DEBUG("ret of sound_manager_get_rpi_playback_route() : %x", ret); + if (SOUND_MANAGER_ERROR_NONE != ret) { + SETTING_TRACE_ERROR("Fail in sound_manager_get_rpi_playback_route()"); + return _("IDS_ST_HEADER_UNAVAILABLE"); + } + return getStringOfSoundRouteType(type); +} + /* *************************************************** * * Public functions @@ -464,13 +529,114 @@ static void __genlist_item_other_sounds_clicked_cb(void *data, Evas_Object *obj, elm_genlist_item_selected_set(event_info, EINA_FALSE); } +static void __device_cb(void *data, Evas_Object *obj, void *event_info) +{ + SETTING_TRACE_BEGIN; + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + SettingSoundData *ad = data; + + ret_if(data == NULL); + retm_if(event_info == NULL, "Invalid argument: event info is NULL"); + + elm_genlist_item_selected_set(item, 0); + Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item); + SETTING_TRACE("clicking item[%s, %s, %d]", _(list_item->keyStr), list_item->sub_desc, list_item->chk_id); + + int selected_id = list_item->chk_id; + SETTING_TRACE_DEBUG("selected_id : %x", selected_id); + + int ret = sound_manager_set_rpi_playback_route((sound_rpi_playback_route_type)selected_id); + if (!ret) + SETTING_TRACE_DEBUG("success to set rpi playback route\n"); + else + SETTING_TRACE_DEBUG("fail to set rpi playback route\n"); + + if (ad->device_popup) { + evas_object_del(ad->device_popup); + ad->device_popup = NULL; + } + +} + +static void __genlist_item_sound_device_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + SETTING_TRACE_BEGIN; + + sound_rpi_playback_route_type cur_type; + int ret = sound_manager_get_rpi_playback_route(&cur_type); + if(ret != SOUND_MANAGER_ERROR_NONE) { + SETTING_TRACE_ERROR("Fail to get rpi_playback_route"); + return; + } + + SettingSoundData *ad = (SettingSoundData *)data; + Evas_Object *menu_glist = NULL; + Evas_Object *rdg = NULL; + + + setting_retm_if(data == NULL, "data is NULL"); + + + ad->device_popup = setting_create_popup_with_list( + &menu_glist, ad, ad->md.window, + KeyStr_SoundOut, NULL, 0, false, false, 0); + if(ad->device_popup) + evas_object_event_callback_add(ad->device_popup, + EVAS_CALLBACK_DEL, setting_protect_cb, &(ad->device_popup)); + + rdg = elm_radio_add(menu_glist); + elm_object_style_set(rdg, "list"); + evas_object_propagate_events_set(rdg, EINA_TRUE); + elm_radio_state_value_set(rdg, -1); + evas_object_data_set(menu_glist, "radio", rdg); +// ad->theme_rdg = rdg; + + int count = sizeof(type_strings) / sizeof(SM_PBRouteType); + + int cur_radio_num = -1; + int radio_num = 0; + for(int i=0; i < count; i++) { + char *name = type_strings[i].description; + Setting_GenGroupItem_Data *data_device = setting_create_Gendial_field_1radio( + menu_glist, + &(ad->itc_1line), + __device_cb, + ad, + SWALLOW_Type_1RADIO_RIGHT, + rdg, + radio_num, /* Always ON */ + name, + NULL); + + if (data_device) { + data_device->chk_id = (int) type_strings[i].type; + data_device->userdata = ad; + __BACK_POINTER_SET(data_device); + + } else { + SETTING_TRACE_ERROR("data_device is NULL"); + } + + if(type_strings[i].type == cur_type) { + cur_radio_num = radio_num; + SETTING_TRACE_DEBUG("cur_radio_num : %d", cur_radio_num); + } + radio_num++; + } + + /* update radio */ + if(cur_radio_num>=0) + elm_radio_value_set(rdg, cur_radio_num); +} + + static void _get_lite_main_list(void *data) { SETTING_TRACE_BEGIN; ret_if(!data); SettingSoundData *ad = (SettingSoundData *)data; - char *app_id = NULL; const char *left_icon = NULL; int mm_value = 0; int sound_value = 0; @@ -503,8 +669,6 @@ static void _get_lite_main_list(void *data) &sound_value) < 0) sound_value = TRUE; /* default value of sound : on */ - (void)app_get_id(&app_id); - /* Sound Mode */ sound_mode_e mode = setting_profile_get_sound_mode(); ad->sound_mode = setting_create_Gendial_field_def( @@ -562,6 +726,35 @@ static void _get_lite_main_list(void *data) NULL, NULL); + + int stateDeveloperOption; + int err = vconf_get_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &stateDeveloperOption); + if (err == VCONF_OK) { + if(stateDeveloperOption){ + + /* group separator */ + setting_create_Gendial_field_titleItem( + genlist, + &(ad->itc_group), + NULL, + NULL); + + /* Sound Device */ + char *pa_device = (char *)get_current_sounddevice_str(); + SETTING_TRACE_DEBUG("pa_device : %s", pa_device); + ad->data_device = + setting_create_Gendial_field_def( + ad->md.genlist, + &(ad->itc_2line), + __genlist_item_sound_device_clicked_cb, + ad, + SWALLOW_Type_1ICON_1IMAGE, NULL, NULL, + 0, KeyStr_SoundOut, + pa_device, + NULL); + } + } + /* separator */ setting_create_Gendial_field_titleItem( genlist, @@ -606,25 +799,6 @@ static void _get_lite_main_list(void *data) NULL, NULL); - /* Notifications group */ -/* - group_item_data = setting_create_Gendial_field_def( - ad->md.genlist, - &(ad->itc_1line), - NULL, - NULL, - SWALLOW_Type_1ICON_1IMAGE, - NULL, - NULL, - 0, - _("IDS_ST_BODY_NOTIFICATIONS"), - NULL, - NULL); - if (group_item_data) - group_item_data->hide_bottom_line = TRUE; - else - SETTING_TRACE_ERROR("group_item_data is NULL"); -*/ /* 4.noti volumn */ if (sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &mm_value) != SOUND_MANAGER_ERROR_NONE) @@ -669,8 +843,6 @@ static void _get_lite_main_list(void *data) __BACK_POINTER_SET(ad->data_touch_volume); - free(app_id); - app_id = NULL; } @@ -711,6 +883,12 @@ static int _view_create(void *cb) ad->md.naviframe_it, SETTING_PACKAGE, EINA_TRUE); + + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, + __vconf_change_cb, ad); + if (ret != 0) + SETTING_TRACE_ERROR("call vconf_ignore_key_changed failed"); + setting_view_sound_main.is_create = TRUE; setting_view_update(&setting_view_sound_main, ad); @@ -729,6 +907,11 @@ static int _view_destroy(void *cb) SettingSoundData *ad = (SettingSoundData *) cb; + int ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, + __vconf_change_cb); + if (ret != 0) + SETTING_TRACE_ERROR("call vconf_ignore_key_changed failed"); + /* 1.Ungrab Key */ setting_sound_key_ungrab(ad); @@ -983,6 +1166,21 @@ static int _view_update(void *data) setting_sound_update_slider_icon(appdata->data_noti_volume, SND_SLIDER_NOTI); setting_sound_update_slider_icon(appdata->data_touch_volume, SND_SLIDER_SYSTEM); + int stateDeveloperOption; + int err = vconf_get_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &stateDeveloperOption); + if (err == VCONF_OK) { + if(stateDeveloperOption){ + if (appdata->data_device) { + G_FREE(appdata->data_device->sub_desc); + appdata->data_device->sub_desc = strdup(get_current_sounddevice_str()); + SETTING_TRACE_DEBUG("appdata->data_device->sub_desc = %s", appdata->data_device->sub_desc); + elm_object_item_data_set( + appdata->data_device->item, appdata->data_device); + elm_genlist_item_update(appdata->data_device->item); + } + } + } + SETTING_TRACE_END; return SETTING_RETURN_SUCCESS;