Merge remote-tracking branch 'origin/tizen_3.0' into tizen 48/106348/1
authorkiso.chang <kiso.chang@samsung.com>
Wed, 21 Dec 2016 10:14:11 +0000 (19:14 +0900)
committerkiso.chang <kiso.chang@samsung.com>
Wed, 21 Dec 2016 10:14:21 +0000 (19:14 +0900)
Signed-off-by: kiso.chang <kiso.chang@samsung.com>
Conflicts:
setting-profile/src/setting-profile-common.c

Change-Id: I0833b5b3d28980895cdefcf2e58ecc63c64b2cf1

1  2 
setting-profile/src/setting-profile-common.c

index 9299d44a7b8cba39e694f595f4bdc0f77c5dfce2,bb5622dc719ec0188091f80b06e8b74539eb2ae4..742235ebd8d512c78e5583176568468c503e3f3b
mode 100644,100644..100755
@@@ -320,467 -337,35 +320,467 @@@ bool setting_sound_play_sound
                }
        }
  
 -      /*3.Enable "System", via Sound Manager */
 -      item_to_update = ad->data_touch_volume;
 -      if (item_to_update && item_to_update->item
 -                      && item_to_update->eo_check) {
 -              int mm_value = 0;
 -              int ret =  sound_manager_get_volume(
 -                              SOUND_TYPE_SYSTEM, &mm_value);
 -              SETTING_TRACE("ret:%d", ret);
 -              item_to_update->chk_status = mm_value;
 -              elm_slider_value_set(
 -                              item_to_update->eo_check,
 -                              item_to_update->chk_status);
 -              elm_object_item_disabled_set(
 -                              item_to_update->item, EINA_FALSE);
 -              elm_object_disabled_set(item_to_update->eo_check, EINA_FALSE);
 +      player_get_state(ad->mp_player, &state);
 +      if (state != PLAYER_STATE_IDLE)
 +              player_unprepare(ad->mp_player);
  
-       err = player_set_audio_policy_info(ad->mp_player, sound_stream_info_to_set);
 -              setting_sound_update_slider_icon(
 -                              item_to_update, SND_SLIDER_SYSTEM);
++      err = player_set_sound_stream_info(ad->mp_player, sound_stream_info_to_set);
 +      if (err != PLAYER_ERROR_NONE) {
 +              SETTING_TRACE_ERROR("error to set audio policy [%s]",
 +                              get_error_message(err));
 +              if (sound_type != SOUND_TYPE_NOTIFICATION)
 +                      sound_manager_release_focus(sound_stream_info_to_set,
 +                                      SOUND_STREAM_FOCUS_FOR_PLAYBACK,
 +                                      SOUND_BEHAVIOR_NONE, NULL);
 +              player_unprepare(ad->mp_player);
 +              return false;
        }
  
 +      err = player_set_uri(ad->mp_player, ad->song_playing);
 +      if (err != PLAYER_ERROR_NONE) {
 +              SETTING_TRACE_ERROR("error to set attribute---profile_uri[%s]",
 +                              get_error_message(err));
 +              if (sound_type != SOUND_TYPE_NOTIFICATION)
 +                      sound_manager_release_focus(sound_stream_info_to_set,
 +                                      SOUND_STREAM_FOCUS_FOR_PLAYBACK,
 +                                      SOUND_BEHAVIOR_NONE, NULL);
 +              player_unprepare(ad->mp_player);
 +              return false;
 +      }
  
 -      /*4.Enable "Call ringtone", via "Backuped" value */
 -      item_to_update = ad->data_call_volume;
 -      if (item_to_update && item_to_update->eo_check) {
 -              SETTING_TRACE("....ad->is_ringtone_slidering:%d, "
 -                              "ad->data_call_volume->chk_status:%d",
 -                              ad->is_ringtone_slidering,
 -                              item_to_update->chk_status);
 -              /* do need to restore from BACKUP VOLUME */
 +#if SUPPORT_PLAYER_ASYNC
 +      err = player_prepare_async(ad->mp_player, __mm_player_prepared_cb, ad);
 +      if (err != PLAYER_ERROR_NONE) {
 +              SETTING_TRACE_ERROR("realizing the player handle failed[%s]",
 +                              get_error_message(err));
 +              if (sound_type != SOUND_TYPE_NOTIFICATION)
 +                      sound_manager_release_focus(sound_stream_info_to_set,
 +                                      SOUND_STREAM_FOCUS_FOR_PLAYBACK,
 +                                      SOUND_BEHAVIOR_NONE, NULL);
 +              player_unprepare(ad->mp_player);
 +              return false;
 +      }
 +      ad->mp_prepare_async = ad->mp_player;
 +      SETTING_TRACE("waiting..player (%x)", ad->mp_prepare_async);
 +#else
 +      err = player_prepare(ad->mp_player);
 +      if (err != PLAYER_ERROR_NONE) {
 +              SETTING_TRACE_ERROR("player_prepare() error %d", err);
 +              if (sound_type != SOUND_TYPE_NOTIFICATION)
 +                      sound_manager_release_focus(sound_stream_info_to_set,
 +                                      SOUND_STREAM_FOCUS_FOR_PLAYBACK,
 +                                      SOUND_BEHAVIOR_NONE, NULL);
 +              player_unprepare(ad->mp_player);
 +              return false;
 +      }
 +
 +      state = PLAYER_STATE_NONE;
 +      err = player_get_state(ad->mp_player, &state);
 +      SETTING_TRACE("state:%d", state);
 +      if (state != PLAYER_STATE_READY) {
 +              SETTING_TRACE_ERROR("state of player is invalid %d", err);
 +              if (sound_type != SOUND_TYPE_NOTIFICATION)
 +                      sound_manager_release_focus(sound_stream_info_to_set,
 +                                      SOUND_STREAM_FOCUS_FOR_PLAYBACK,
 +                                      SOUND_BEHAVIOR_NONE, NULL);
 +              player_unprepare(ad->mp_player);
 +              return false;
 +      }
 +
 +      player_set_completed_cb(ad->mp_player, __mm_player_msg_cb, ad);
 +
 +      err = player_start(ad->mp_player);
 +      if (err != PLAYER_ERROR_NONE) {
 +              /* if directly return error.. */
 +              SETTING_TRACE_ERROR("player_start [%s]",
 +                              get_error_message(err));
 +              player_unset_completed_cb(ad->mp_player);
 +              if (sound_type != SOUND_TYPE_NOTIFICATION)
 +                      sound_manager_release_focus(sound_stream_info_to_set,
 +                                      SOUND_STREAM_FOCUS_FOR_PLAYBACK,
 +                                      SOUND_BEHAVIOR_NONE, NULL);
 +              player_unprepare(ad->mp_player);
 +              return false;
 +      }
 +#endif
 +
 +      return true;
 +}
 +
 +void setting_sound_play_sound_origin(void *data, void *cb, char *ringtone_file,
 +              float vol, sound_type_e sound_type)
 +{
 +      SETTING_TRACE_BEGIN;
 +      int vconf_value = 0;
 +      SettingSoundData *ad = (SettingSoundData *) data;
 +
 +      ret_if(!ad);
 +
 +      if (vol < EXP) {
 +              SETTING_TRACE_DEBUG("vol < EXP");
 +              setting_sound_stop_sound(ad);
 +              return;
 +      }
 +
 +      vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TURN_OFF_ALL_SOUNDS,
 +                      &vconf_value);
 +
 +      if (vconf_value == TRUE)
 +              return;
 +
 +      setting_sound_play_sound(ad, cb, ringtone_file, vol, sound_type);
 +      SETTING_TRACE("play sound type %d", sound_type);
 +}
 +
 +void setting_sound_stop_sound(SettingSoundData *ad)
 +{
 +      SETTING_TRACE_BEGIN;
 +      sound_stream_focus_state_e ssfs = SOUND_STREAM_FOCUS_STATE_ACQUIRED;
 +      player_state_e player_state = PLAYER_STATE_NONE;
 +
 +      if (ad->song_playing) {
 +              g_free(ad->song_playing);
 +              ad->song_playing = NULL;
 +      }
 +
 +      player_unset_completed_cb(ad->mp_player);
 +
 +      sound_manager_get_focus_state(ad->ringtone_sound_stream_info, &ssfs, NULL);
 +      if (ssfs == SOUND_STREAM_FOCUS_STATE_ACQUIRED)
 +              sound_manager_release_focus(ad->ringtone_sound_stream_info,
 +                              SOUND_STREAM_FOCUS_FOR_PLAYBACK,
 +                              SOUND_BEHAVIOR_NONE, NULL);
 +
 +      sound_manager_get_focus_state(ad->media_sound_stream_info, &ssfs, NULL);
 +      if (ssfs == SOUND_STREAM_FOCUS_STATE_ACQUIRED)
 +              sound_manager_release_focus(ad->media_sound_stream_info,
 +                              SOUND_STREAM_FOCUS_FOR_PLAYBACK,
 +                              SOUND_BEHAVIOR_NONE, NULL);
 +
 +      player_get_state(ad->mp_player, &player_state);
 +
 +      if (player_state != PLAYER_STATE_IDLE)
 +              if (player_unprepare(ad->mp_player) != PLAYER_ERROR_NONE)
 +                      SETTING_TRACE_ERROR("player unrealize failed");
 +}
 +
 +void setting_sound_key_grab(SettingSoundData *ad)
 +{
 +      SETTING_TRACE_BEGIN;
 +
 +      /* To prevent conflict with volume app */
 +      vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 2);
 +
 +      if (0 != safeStrCmp(ad->viewtype, VOLUME_APP_NAME))
 +              return;
 +
 +      if (!ad->keydown_handler)
 +              ad->keydown_handler = ecore_event_handler_add(
 +                              ECORE_EVENT_KEY_DOWN, __volume_key_down_cb, ad);
 +      if (!ad->keydown_handler)
 +              SETTING_TRACE_DEBUG("ecore_event_handler_add() failed");
 +
 +      if (!ad->keyup_handler)
 +              ad->keyup_handler = ecore_event_handler_add(
 +                              ECORE_EVENT_KEY_UP, __volume_key_up_cb, ad);
 +      if (!ad->keyup_handler)
 +              SETTING_TRACE_DEBUG("ecore_event_handler_add() failed");
 +}
 +
 +void setting_sound_key_ungrab(SettingSoundData *ad)
 +{
 +      SETTING_TRACE_BEGIN;
 +
 +      /* To prevent conflict with volume app */
 +      vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 0);
 +
 +      ecore_timer_del(ad->updown_timer);
 +      ad->updown_timer = NULL;
 +
 +      ecore_event_handler_del(ad->keydown_handler);
 +      ad->keydown_handler = NULL;
 +
 +      ecore_event_handler_del(ad->keyup_handler);
 +      ad->keyup_handler = NULL;
 +}
 +
 +Evas_Object *setting_sound_init(SettingSoundData *ad)
 +{
 +      SETTING_TRACE_BEGIN;
 +      int err = 0;
 +
 +      bindtextdomain(SETTING_PACKAGE, SETTING_LOCALEDIR);
 +
 +      setting_create_Gendial_itc(SETTING_GENLIST_LEFT_ICON_CONTENT_ICON_STYLE,
 +                      &(ad->itc_layout));
 +
 +      ad->itc_layout.func.content_get = __sound_slider_icon_get;
 +
 +      setting_create_Gendial_itc(SETTING_GENLIST_LEFT_ICON_CONTENT_ICON_STYLE,
 +                      &(ad->itc_layout_1icon));
 +
 +      ad->itc_layout_1icon.func.content_get = __sound_slider_icon_get;
 +
 +      /* register view node table */
 +      setting_view_node_table_intialize();
 +      setting_view_node_table_register(&setting_view_sound_main, NULL);
 +
 +      err = player_create(&ad->mp_player);
 +      if (PLAYER_ERROR_NONE != err) {
 +              SETTING_TRACE_ERROR("Cannot create ringtone player %s",
 +                              get_error_message(err));
 +              return NULL;
 +      }
 +
 +      if (
 +              (sound_manager_create_stream_information(
 +                              SOUND_STREAM_TYPE_RINGTONE_VOIP,
 +                              __sound_stream_focus_state_changed_cb, ad,
 +                              &ad->ringtone_sound_stream_info)
 +                      != SOUND_MANAGER_ERROR_NONE) ||
 +              (sound_manager_create_stream_information(
 +                              SOUND_STREAM_TYPE_MEDIA,
 +                              __sound_stream_focus_state_changed_cb, ad,
 +                              &ad->media_sound_stream_info)
 +                      != SOUND_MANAGER_ERROR_NONE) ||
 +              (sound_manager_create_stream_information(
 +                              SOUND_STREAM_TYPE_NOTIFICATION,
 +                              __sound_stream_focus_state_changed_cb, ad,
 +                              &ad->noti_sound_stream_info)
 +                      != SOUND_MANAGER_ERROR_NONE)
 +      ) {
 +              SETTING_TRACE_ERROR("Cannot create stream information ");
 +              return NULL;
 +      }
 +      /* creating a view. */
 +      setting_view_node_set_cur_view(&setting_view_sound_main);
 +      setting_view_create(&setting_view_sound_main, (void *)ad);
 +
 +      err = feedback_initialize();
 +      SETTING_TRACE_DEBUG("Feedback init: %s", get_error_message(err));
 +
 +      __listen_vconf_change(ad);
 +
 +      return ad->md.naviframe;
 +}
 +
 +void setting_sound_deinit(void *data)
 +{
 +      SETTING_TRACE_BEGIN;
 +      ret_if(data == NULL);
 +      SettingSoundData *ad = data;
 +
 +      __unlisten_vconf_change(ad);
 +      feedback_deinitialize();
 +      setting_sound_stop_sound(ad);
 +
 +      evas_object_del(ad->calling_popup);
 +      ad->calling_popup = NULL;
 +
 +      setting_sound_key_ungrab(ad);
 +
 +      FREE(ad->viewtype);
 +
 +      sound_manager_destroy_stream_information(
 +                      ad->ringtone_sound_stream_info);
 +      sound_manager_destroy_stream_information(ad->media_sound_stream_info);
 +      sound_manager_destroy_stream_information(ad->noti_sound_stream_info);
 +
 +      ad->ringtone_sound_stream_info = ad->media_sound_stream_info =
 +      ad->noti_sound_stream_info = NULL;
 +
 +      player_destroy(ad->mp_player);
 +      ad->mp_player = NULL;
 +
 +      /* it is the view manage strategy to invoke view's destory operation */
 +      setting_view_destroy(&setting_view_sound_main, ad);
 +
 +      SETTING_TRACE_END;
 +}
 +
 +/* Show guide popup, when drag or tap slider if during call.
 +      Do not provide pre-listening. */
 +void setting_sound_create_warning_popup_during_call(void *data)
 +{
 +      ret_if(data == NULL);
 +      SettingSoundData *ad = (SettingSoundData *)data;
 +
 +      cm_call_status_e call_status = CM_CALL_STATUS_IDLE;
 +      cm_client_h cm_handle = NULL;
 +      cm_init(&cm_handle);
 +      cm_get_call_status(cm_handle, &call_status);
 +      cm_deinit(cm_handle);
 +      if (CM_CALL_STATUS_IDLE != call_status) {
 +              SETTING_TRACE("Call status is not OFF (%d)", call_status);
 +              if (!ad->calling_popup) {
 +                      ad->calling_popup = setting_create_popup(
 +                                      ad,
 +                                      ad->md.window,
 +                                      "IDS_ST_HEADER_UNABLE_TO_PLAY_SAMPLE_ABB",
 +                                      "IDS_ST_POP_SAMPLES_CANNOT_BE_PLAYED_DURING_CALLS",
 +                                      __calling_popup_cb,
 +                                      0,
 +                                      false,
 +                                      false,
 +                                      1,
 +                                      "IDS_ST_BUTTON_OK");
 +              }
 +      }
 +}
 +
 +/* ------------------------------------------------------------------------- */
 +/* |          | elm.swallow.icon.0 | elm.text | elm.swallow.icon.1 |     | */
 +/* | elm.swallow.icon |----------------------------------| elm.swallow.end | */
 +/* |            |     elm.text.sub      | elm.text.sub.end   |           | */
 +/* ------------------------------------------------------------------------- */
 +static Evas_Object *__sound_slider_icon_get(void *data, Evas_Object *obj,
 +              const char *part)
 +{
 +      SETTING_TRACE_BEGIN;
 +      /*appcore_measure_start(); */
 +      retv_if(data == NULL, NULL);
 +
 +      SETTING_TRACE(" -----------------> EDC part [%s]", part);
 +      if (safeStrCmp(part, "elm.swallow.content"))
 +              return NULL;
 +
 +      Evas_Object *layout;
 +      /* Set custom layout style */
 +      layout = elm_layout_add(obj);
 +
 +      Setting_GenGroupItem_Data *item_data =
 +                      (Setting_GenGroupItem_Data *)data;
 +      Evas_Object *slider = setting_create_slider(obj, item_data);
 +
 +      if (slider == NULL)
 +              return NULL;
 +
 +      char *gl_style = "gl_custom_item";
 +      elm_layout_file_set(layout, EDJDIR"/setting-theme.edj", gl_style);
 +      evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
 +      evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
 +                      EVAS_HINT_EXPAND);
 +
 +      if (0 == safeStrCmp(item_data->keyStr, "IDS_ST_BODY_MEDIA")) {
 +              elm_object_style_set(slider, "warning");
 +
 +              Edje_Message_Float_Set *msg =
 +                              alloca(sizeof(Edje_Message_Float_Set)
 +                                              + (sizeof(double)));
 +              msg->count = 1;
 +              /* Warning area point has to be calculated considering rounding
 +               * off. For example, value 10's area will be 9.5~10.4.
 +               * So, if warning area has to be started at 10, we need to
 +               * calculate the start point with 9.5.
 +               * Warning start point = (Warning min value - 0.5) /
 +               *                              (Max_Value - Min_Value) */
 +              msg->val[0] = 0.633333;
 +              edje_object_message_send(
 +                              _EDJ(slider), EDJE_MESSAGE_FLOAT_SET, 0, msg);
 +              elm_slider_indicator_format_set(slider, "%1.0f");
 +              elm_slider_indicator_show_set(slider, 1);
 +      }
 +
 +      item_data->eo_check = slider;
 +
 +      evas_object_pass_events_set(slider, EINA_TRUE);
 +      evas_object_propagate_events_set(slider, EINA_FALSE);
 +
 +      if (item_data->userdata == NULL)
 +              return NULL;
 +
 +      /* Set text into layout */
 +      /*if (0 == safeStrCmp(item_data->keyStr, "IDS_ST_BODY_MEDIA") */
 +      /*      || 0 == safeStrCmp(item_data->keyStr, "IDS_ST_BODY_SYSTEM"))
 +       * { */
 +      elm_object_part_text_set(layout, "elm.text", _(item_data->keyStr));
 +      /*} */
 +      elm_object_part_content_set(layout, "elm.swallow.content", slider);
 +      return layout;
 +}
 +
 +static void __enable_sound_menu(void *data)
 +{
 +      SETTING_TRACE_BEGIN;
 +      ret_if(!data);
 +      SettingSoundData *ad = data;
 +      ad->sound_on = TRUE;
 +      Setting_GenGroupItem_Data *item_to_update = NULL;
 +
 +
 +      /*1.Enable "Vibrate when ringing" */
 +      if (ad->data_sound_when_ring) {
 +              item_to_update = ad->data_sound_when_ring;
 +              setting_genlist_item_disabled_set(item_to_update, EINA_FALSE);
 +      }
 +
 +      if (ad->data_call_volume) {
 +              elm_object_item_disabled_set(ad->data_call_volume->item,
 +                              EINA_FALSE);
 +              elm_object_disabled_set(ad->data_call_volume->eo_check,
 +                              EINA_FALSE);
 +      }
 +
 +      /*2.Enable "Notification", via Sound Manager */
 +      item_to_update = ad->data_noti_volume;
 +
 +      /* @todo make sure data_msg_alert_tone is correct for 'Silent' set.
 +      if (item_to_update && safeStrCmp(item_to_update->sub_desc, "Silent"))*/
 +      if ((ad->data_msg_alert_tone &&
 +              safeStrCmp(ad->data_msg_alert_tone->sub_desc, "Silent")) ||
 +              (!safeStrCmp(ad->viewtype, VOLUME_APP_NAME))
 +              ) {
 +              /* Enable */
 +              if (item_to_update
 +                              && item_to_update->item
 +                              && item_to_update->eo_check) {
 +                      int mm_value = 0;
 +                      int ret =  sound_manager_get_volume(
 +                                      SOUND_TYPE_NOTIFICATION, &mm_value);
 +                      SETTING_TRACE("ret:%d", ret);
 +                      item_to_update->chk_status = mm_value;
 +                      elm_slider_value_set(
 +                                      item_to_update->eo_check,
 +                                      item_to_update->chk_status);
 +                      elm_object_item_disabled_set(item_to_update->item,
 +                                      EINA_FALSE);
 +                      elm_object_disabled_set(item_to_update->eo_check,
 +                                      EINA_FALSE);
 +
 +                      setting_sound_update_slider_icon(
 +                                      item_to_update, SND_SLIDER_NOTI);
 +              }
 +      }
 +
 +      /*3.Enable "System", via Sound Manager */
 +      item_to_update = ad->data_touch_volume;
 +      if (item_to_update && item_to_update->item
 +                      && item_to_update->eo_check) {
 +              int mm_value = 0;
 +              int ret =  sound_manager_get_volume(
 +                              SOUND_TYPE_SYSTEM, &mm_value);
 +              SETTING_TRACE("ret:%d", ret);
 +              item_to_update->chk_status = mm_value;
 +              elm_slider_value_set(
 +                              item_to_update->eo_check,
 +                              item_to_update->chk_status);
 +              elm_object_item_disabled_set(
 +                              item_to_update->item, EINA_FALSE);
 +              elm_object_disabled_set(item_to_update->eo_check, EINA_FALSE);
 +
 +              setting_sound_update_slider_icon(
 +                              item_to_update, SND_SLIDER_SYSTEM);
 +      }
 +
 +
 +      /*4.Enable "Call ringtone", via "Backuped" value */
 +      item_to_update = ad->data_call_volume;
 +      if (item_to_update && item_to_update->eo_check) {
 +              SETTING_TRACE("....ad->is_ringtone_slidering:%d, "
 +                              "ad->data_call_volume->chk_status:%d",
 +                              ad->is_ringtone_slidering,
 +                              item_to_update->chk_status);
 +              /* do need to restore from BACKUP VOLUME */
                if (ad->is_ringtone_slidering) return;
  
                int mm_value = 0;