Merge remote-tracking branch 'origin/sdk' into tizen 59/200759/2
authorLukasz Stanislawski <l.stanislaws@samsung.com>
Mon, 18 Feb 2019 07:53:07 +0000 (08:53 +0100)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Thu, 7 Mar 2019 07:28:38 +0000 (08:28 +0100)
Change-Id: Ibe4181f11a2825303c11f125355264c1c0cb2c54

12 files changed:
1  2 
setting-appmgr/src/setting-appmgr-main.c
setting-common/src/setting-common-draw-popup.c
setting-language-and-input/src/setting-display-language-view.c
setting-language-and-input/src/setting-language-and-input.c
setting-password/src/setting-password-sim.c
setting-profile-common/src/setting-profile-common.c
setting-ringtone/src/setting-ringtone.c
setting-ringtone/tizen-manifest.xml
setting-time/src/setting-time-main.c
smartmanager-data/inc/smartmanager-data.h
smartmanager-data/inc/smartmanager-utils.h
smartmanager-data/src/smartmanager-data.c

index dd3ebd51eedf85415b56927921e4636bacb9e98c,5490170db03b10a79d8a7ce85aaf6f50cb95752f..2972c26d3eafe5a658976e0536ff92624d3b7915
mode 100755,100644..100644
index b2c57c7447d3dcd91e41db6acbdd9a52aabe88c5,01c5ea7fecbe7790d965d5cc24fb29ba1d5622c9..01c5ea7fecbe7790d965d5cc24fb29ba1d5622c9
mode 100755,100644..100755
index 827a7d77b95a2cf15621e293984a2a5a4829681d,d181ebce807cc553c34d2d320b7639e946ca3351..eaeb31605e317982f751ccddc2dde2ef9e916c85
mode 100755,100644..100755
index 920eabdc17c674794eb277a7e679cb7a04e8abfd,51292e51f7d4d99dceb2c10275205f62a79652f8..51292e51f7d4d99dceb2c10275205f62a79652f8
mode 100755,100644..100755
index 1521608d7d2d9c3c68f71741c3179f92628afbfe,ae8f4d924a8fcebe70cd86ee66a8b439c8b9e826..ae8f4d924a8fcebe70cd86ee66a8b439c8b9e826
mode 100755,100644..100755
index 0000000000000000000000000000000000000000,98d1ee591b50578e089ea21b58291e26a1732c43..52d1e0285ed4348f6a1cd1686810fd50cfe3a89e
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,1407 +1,1410 @@@
+ /*
+  * setting
+  *
+  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
+  *
+  * Contact: MyoungJune Park <mj2004.park@samsung.com>
+  *
+  * Licensed under the Apache License, Version 2.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  * http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  *
+  */
+ #include <telephony.h>
+ #include <sys/stat.h>
+ #include <dirent.h>
+ #include <app_manager.h>
+ #include <metadata_extractor.h>
+ #include <player.h>
+ #include <setting-profile-common.h>
+ #define SETTING_DEFAULT_FOLDER_PATH   "media/settings/"
+ #define SDCARD_PATH   "/sdcard/"
+ #define EXP 0.001
+ typedef struct _SliderIcons {
+       int index;
+       char mute[256];
+       char volume[256];
+ } SliderIcons;
+ SliderIcons slider_icons[SND_SLIDER_MAX] = {
+       {SND_SLIDER_CALL,       ICON_CALL_MUTE,         ICON_CALL_NORMAL},
+       {SND_SLIDER_NOTI,       ICON_NOTI_MUTE,         ICON_NOTI_NORMAL},
+       {SND_SLIDER_MEDIA,      ICON_MEDIA_MUTE,        ICON_MEDIA_NORMAL},
+       {SND_SLIDER_SYSTEM,     ICON_SYSTEM_MUTE,       ICON_SYSTEM_NORMAL}
+ };
+ static void __mm_player_prepared_cb(void *user_data);
+ static void __sound_stream_focus_state_changed_cb(
+               sound_stream_info_h stream_info,
+               sound_stream_focus_mask_e focus_mask,
+               sound_stream_focus_state_e focus_state,
+               sound_stream_focus_change_reason_e reason,
+               int sound_behavior,
+               const char *extra_info,
+               void *user_data);
+ static Eina_Bool __volume_key_down_cb(void *data, int type, void *event);
+ static Eina_Bool __volume_key_up_cb(void *data, int type, void *event);
+ static Evas_Object *__sound_slider_icon_get(void *data, Evas_Object *obj,
+               const char *part);
+ static int __listen_vconf_change(void *data);
+ static int __unlisten_vconf_change(void *data);
+ static void __calling_popup_cb(void *data, Evas_Object *obj, void *event_info);
+ bool is_call_status_idle(void);
+ EXPORT_PUBLIC
+ void setting_sound_update_do_not_disturb_item(void *data)
+ {
+       SettingSoundData *ad = (SettingSoundData *) data;
+       const char *sub_desc = NULL;
+       if (!ad || !ad->data_do_not_disturb)
+               return;
+       sub_desc = setting_do_not_disturb_is_enable(data);
+       g_free(ad->data_do_not_disturb->sub_desc);
+       ad->data_do_not_disturb->sub_desc = g_strdup(sub_desc);
+       elm_genlist_item_update(ad->data_do_not_disturb->item);
+ }
+ EXPORT_PUBLIC
+ void setting_sound_update_notifiaction_on_lock_screen_item(void *data)
+ {
+       SettingSoundData *ad = (SettingSoundData *) data;
+       const char *sub_desc = NULL;
+       if (!ad || !ad->data_notifiaction_on_lock_screen)
+               return;
+       sub_desc = setting_notifiaction_on_lock_screen(data);
+       g_free(ad->data_notifiaction_on_lock_screen->sub_desc);
+       ad->data_notifiaction_on_lock_screen->sub_desc = g_strdup(sub_desc);
+       elm_genlist_item_update(ad->data_notifiaction_on_lock_screen->item);
+ }
+ EXPORT_PUBLIC
+ char *setting_sound_get_slider_icon(int type, int volume)
+ {
+       if (type < SND_SLIDER_CALL || type >= SND_SLIDER_MAX)
+               return NULL;
+       SETTING_TRACE("type : %d, volume : %d", type, volume);
+       /* 1.Call ringtone and notification have 3 icon status */
+       if (SND_SLIDER_CALL == type || SND_SLIDER_NOTI == type) {
+               /*special process */
+               int sound = 0;
+               int vibration = 0;
+               char *icon_call = get_resource_path(ICON_CALL_NORMAL);
+               char *icon_noti = get_resource_path(ICON_NOTI_NORMAL);
+               vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound);
+               vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibration);
+               if (sound && !vibration) {
+                       return (SND_SLIDER_CALL == type ? icon_call : icon_noti);
+               }
+               icon_call = get_resource_path(ICON_CALL_VIB);
+               icon_noti = get_resource_path(ICON_NOTI_VIB);
+               if (vibration && !sound) {
+                       return (SND_SLIDER_CALL == type ? icon_call : icon_noti);
+               }
+               icon_call = get_resource_path(ICON_CALL_MUTE);
+               icon_noti = get_resource_path(ICON_NOTI_MUTE);
+               if (!vibration && !sound) {
+                       return (SND_SLIDER_CALL == type ? icon_call : icon_noti);
+               }
+               icon_call = get_resource_path(ICON_CALL_NORMAL);
+               icon_noti = get_resource_path(ICON_NOTI_NORMAL);
+               return (SND_SLIDER_CALL == type ? icon_call : icon_noti);
+       }
+       char *path = get_resource_path(SETTING_ICON_PATH);
+       char *buf = calloc(PATH_MAX, sizeof(char));
+       /* 2.Other types, just have two icon status */
+       if (volume > 0) {
+               snprintf(buf, PATH_MAX, "%s/%s", path, slider_icons[type].volume);
+       } else {
+               snprintf(buf, PATH_MAX, "%s/%s", path, slider_icons[type].mute);
+       }
+       return buf;
+ }
+ EXPORT_PUBLIC
+ void setting_sound_update_slider_icon(Setting_GenGroupItem_Data *item_data,
+               int type)
+ {
+       SETTING_TRACE_BEGIN;
+       ret_if(!item_data || !item_data->eo_check);
+       Evas_Object *icon = elm_object_content_get(item_data->eo_check);
+       if (icon) {
+               char *new_file = setting_sound_get_slider_icon(type, item_data->chk_status);
+               elm_image_file_set(icon, new_file, NULL);
+               free(new_file);
+       }
+ }
+ EXPORT_PUBLIC
+ char *setting_media_basename(char *path)
+ {
+       metadata_extractor_h metadata = NULL;
+       char *title = NULL;
+       int ret = METADATA_EXTRACTOR_ERROR_NONE;
+       if (NULL == path || '\0' == path[0])
+               return strdup(_("IDS_ST_BODY_PHONEPROFILES_SILENT"));
+       ret = metadata_extractor_create(&metadata);
+       if (ret == METADATA_EXTRACTOR_ERROR_NONE && metadata) {
+               ret = metadata_extractor_set_path(metadata, path);
+               if (ret == METADATA_EXTRACTOR_ERROR_NONE) {
+                       ret = metadata_extractor_get_metadata(metadata,
+                                       METADATA_TITLE, &title);
+                       if (title) {
+                               char *strdup_title = strdup(title);
+                               metadata_extractor_destroy(metadata);
+                               free(title);
+                               return strdup_title;
+                       }
+               }
+               metadata_extractor_destroy(metadata);
+       }
+       return setting_file_basename(path);
+ }
+ /* ***************************************************
+  *
+  *general func
+  *
+  ***************************************************/
+ int setting_sound_check_file_exist(void *data, const char *file_path)
+ {
+       retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+       retv_if(file_path == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+       const char *tz_platform_path = setting_tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, SETTING_DEFAULT_FOLDER_PATH);
+       if (0 == safeStrNCmp(file_path, tz_platform_path, safeStrLen(tz_platform_path))) {
+               SETTING_TRACE("Default file[%s]!", file_path);
+               return SETTING_RETURN_SUCCESS;
+       }
+       if (!ecore_file_exists(file_path)) {
+               if (safeStrCmp(file_path, "Silent") == 0) {
+                       SETTING_TRACE("%s", file_path);
+                       return SETTING_RETURN_SUCCESS;
+               }
+               const char *tz_platform_media = setting_tzplatform_mkpath(TZ_SYS_MEDIA, SDCARD_PATH);
+               SETTING_TRACE_ERROR(
+                               "Cannot find the ringtone file[%s]!",
+                               file_path);
+               if (0 == safeStrNCmp(file_path, tz_platform_media, safeStrLen(tz_platform_media))) {
+                       char *strdup_file_path = strdup(file_path);
+                       /*sdcard file*/
+                       int ret = vconf_set_str(
+                                       VCONFKEY_SETAPPL_CALL_VIBRATION_PATTERN_STR,
+                                       strdup_file_path);
+                       if (ret < 0)
+                               SETTING_TRACE_DEBUG("failed to set vconf");
+                       FREE(strdup_file_path);
+               }
+               return SETTING_RETURN_FAIL;
+       }
+       const char *tz_platform_media = setting_tzplatform_mkpath(TZ_SYS_MEDIA, SDCARD_PATH);
+       int mmc_status = VCONFKEY_SYSMAN_MMC_REMOVED;
+       vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_status);
+       if (VCONFKEY_SYSMAN_MMC_MOUNTED != mmc_status) {
+               if (!safeStrNCmp(tz_platform_media, file_path, safeStrLen(tz_platform_media))) {
+                       return SETTING_RETURN_FAIL;
+               }
+       }
+       return SETTING_RETURN_SUCCESS;
+ }
+ bool setting_sound_play_sound(
+               void *data,
+               void *cb,
+               char *ringtone_file,
+               int vol,
+               sound_type_e sound_type)
+ {
+       int err = 0;
+       sound_stream_focus_state_e ssfs = SOUND_STREAM_FOCUS_STATE_ACQUIRED;
+       player_state_e state = PLAYER_STATE_NONE;
+       /* error check */
+       retv_if(data == NULL, NULL);
+       SettingSoundData *ad = (SettingSoundData *) data;
+       sound_stream_info_h sound_stream_info_to_set = NULL;
+       int is_existing = setting_sound_check_file_exist(ad, ringtone_file);
+       const char *tz_platform_path = setting_tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, SETTING_DEFAULT_CALL_TONE_SDK);
+       if (is_existing == SETTING_RETURN_FAIL || NULL == ringtone_file) {
+               switch (sound_type) {
+               case SOUND_TYPE_RINGTONE:
+                       ad->song_playing = (char *)g_strdup(tz_platform_path);
+                       sound_stream_info_to_set = ad->ringtone_sound_stream_info;
+                       break;
+               case SOUND_TYPE_MEDIA:
+                       if (isEmulBin())
+                               ad->song_playing = (char *)g_strdup(tz_platform_path);
+                       else
+                               ad->song_playing = (char *)g_strdup(tz_platform_path);
+                       sound_stream_info_to_set = ad->media_sound_stream_info;
+                       break;
+               case SOUND_TYPE_NOTIFICATION:
+                       ad->song_playing = (char *)g_strdup(
+                                       SETTING_DEFAULT_MSG_TONE);
+                       sound_stream_info_to_set = ad->noti_sound_stream_info;
+                       break;
+               default:
+                       return false;
+                       break;
+               }
+       } else {
+               if (safeStrCmp(ringtone_file, "Silent") == 0)
+                       return false;
+               switch (sound_type) {
+               case SOUND_TYPE_RINGTONE:
+                       sound_stream_info_to_set =
+                                       ad->ringtone_sound_stream_info;
+                       break;
+               case SOUND_TYPE_MEDIA:
+                       sound_stream_info_to_set = ad->media_sound_stream_info;
+                       break;
+               case SOUND_TYPE_NOTIFICATION:
+                       sound_stream_info_to_set = ad->noti_sound_stream_info;
+                       break;
+               default:
+                       return false;
+                       break;
+               }
+               ad->song_playing = (char *)g_strdup(ringtone_file);
+       }
+       player_get_state(ad->mp_player, &state);
+       if (state != PLAYER_STATE_IDLE) {
+               if (err != player_unprepare(ad->mp_player)) {
+                       SETTING_TRACE_ERROR("player_unprepare() failed: [%s]",
+                                       get_error_message(err));
+                       player_unprepare(ad->mp_player);
+                       return false;
+               }
+       }
+       if (sound_type != SOUND_TYPE_NOTIFICATION) {
+               sound_manager_get_focus_state(sound_stream_info_to_set, &ssfs,
+                               NULL);
+               if (ssfs == SOUND_STREAM_FOCUS_STATE_RELEASED) {
+                       err = sound_manager_acquire_focus(
+                                       sound_stream_info_to_set,
+                                       SOUND_STREAM_FOCUS_FOR_PLAYBACK,
+                                       SOUND_BEHAVIOR_NONE, NULL);
+                       if (err != SOUND_MANAGER_ERROR_NONE) {
+                               SETTING_TRACE_ERROR(
+                                               "Could not acquire focus: [%s]",
+                                               get_error_message(err));
+                               player_unprepare(ad->mp_player);
+                               return false;
+                       }
+               }
+       }
+       player_get_state(ad->mp_player, &state);
+       if (state != PLAYER_STATE_IDLE)
+               player_unprepare(ad->mp_player);
+       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;
+       }
+ #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)", (unsigned int)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);
+ }
+ EXPORT_PUBLIC
+ void setting_sound_stop_sound(void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       SettingSoundData *ad = (SettingSoundData *)data;
+       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;
+ }
+ EXPORT_PUBLIC
+ 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("full", &(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;
+ }
+ EXPORT_PUBLIC
+ 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;
+       bool is_idle  = is_call_status_idle();
+       if (!is_idle) {
+               SETTING_TRACE("Call status is not OFF (%d)", is_idle);
+               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;
+       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;
+       set_layout_file(layout, EDJDIR"/setting-theme.edj", "gl_custom_item");
+       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(
+                               elm_layout_edje_get(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;
+       if (item_data->keyStr)
+               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;
+               elm_object_item_disabled_set(item_to_update->item, 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;
+               sound_manager_get_volume(SOUND_TYPE_RINGTONE, &mm_value);
+               if (mm_value <= 0) mm_value = 1;
+               sound_manager_set_volume(SOUND_TYPE_RINGTONE, mm_value);
+               item_to_update->chk_status = mm_value;
+               elm_slider_value_set(
+                               item_to_update->eo_check,
+                               item_to_update->chk_status);
+               SETTING_TRACE("ad->data_call_volume->chk_status : %d",
+                               item_to_update->chk_status);
+       }
+ }
+ static void __disable_sound_menu(void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       ret_if(!data);
+       SettingSoundData *ad = data;
+       ad->sound_on = FALSE;
+       Setting_GenGroupItem_Data *item_to_update = NULL;
+       setting_sound_stop_sound(ad);
+       /*1.Disable      "Vibrate when ringing" */
+       item_to_update = ad->data_sound_when_ring;
+       if (item_to_update)
+               elm_object_item_disabled_set(item_to_update->item, EINA_TRUE);
+       /* Disable Call Volume slider if Silent ringtone is selected */
+       if (ad->data_call_alert_tone && !safeStrCmp(
+                       ad->data_call_alert_tone->sub_desc, "Silent")) {
+               elm_object_item_disabled_set(ad->data_call_volume->item,
+                               EINA_TRUE);
+               elm_object_disabled_set(ad->data_call_volume->eo_check,
+                               EINA_TRUE);
+       }
+       /*2.Disable "Notification" */
+       item_to_update = ad->data_noti_volume;
+       if (item_to_update && item_to_update->item
+                       && item_to_update->eo_check) {
+               item_to_update->chk_status = 0;
+               elm_slider_value_set(item_to_update->eo_check,
+                               item_to_update->chk_status);
+               elm_object_item_disabled_set(item_to_update->item, EINA_TRUE);
+               elm_object_disabled_set(item_to_update->eo_check, EINA_TRUE);
+               /* Change notification slider's icon as mute style */
+               setting_sound_update_slider_icon(item_to_update,
+                               SND_SLIDER_NOTI);
+       }
+       /*3.Disable "System" */
+       item_to_update = ad->data_touch_volume;
+       if (item_to_update && item_to_update->item
+                       && item_to_update->eo_check) {
+               item_to_update->chk_status = 0;
+               elm_slider_value_set(item_to_update->eo_check,
+                               item_to_update->chk_status);
+               elm_object_item_disabled_set(item_to_update->item, EINA_TRUE);
+               elm_object_disabled_set(item_to_update->eo_check, EINA_TRUE);
+               /* Change system slider's icon as mute style */
+               setting_sound_update_slider_icon(item_to_update,
+                               SND_SLIDER_SYSTEM);
+       }
+       /*4.Disable "Call ringtone" */
+       item_to_update = ad->data_call_volume;
+       if (item_to_update && item_to_update->eo_check) {
+               /*DO NOT CHANGE Backup Values(
+                * VCONFKEY_SETAPPL_RINGTONE_BACKUP_VOLUME) */
+               item_to_update->chk_status = 0;
+               elm_slider_value_set(item_to_update->eo_check,
+                               item_to_update->chk_status);
+               SETTING_TRACE("item_to_update->chk_status : %d",
+                               item_to_update->chk_status);
+       }
+ }
+ static void __sound_vconf_change_cb(keynode_t *key, void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       ret_if(data == NULL);
+       SettingSoundData *ad = data;
+       int status = 0;
+       int ret = 0;
+       char *vconf_name = vconf_keynode_get_name(key);
+       Setting_GenGroupItem_Data *item_to_update = NULL;
+       const char *tz_platform_path = setting_tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, SETTING_DEFAULT_CALL_TONE_SDK);
+       if (!safeStrCmp(vconf_name, VCONFKEY_SYSMAN_MMC_STATUS)) {
+               status = vconf_keynode_get_int(key);
+               SETTING_TRACE("status:%d", status);
+               if (VCONFKEY_SYSMAN_MMC_MOUNTED != status) {
+                       /* when remove mmc card, change default tone */
+                       char *call_tone = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
+                       if (call_tone && !safeStrNCmp(
+                                       SETTING_PROFILE_MMC_PATH,
+                                       call_tone,
+                                       safeStrLen(SETTING_PROFILE_MMC_PATH))) {
+                                       ret = vconf_set_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, tz_platform_path);
+                               if (ret < 0)
+                                       SETTING_TRACE_DEBUG(
+                                                       "failed to set vconf");
+                       }
+                       FREE(call_tone);
+                       SETTING_TRACE("song_playing:%s", ad->song_playing);
+                       if (!safeStrNCmp(SETTING_PROFILE_MMC_PATH,
+                                       ad->song_playing,
+                                       safeStrLen(SETTING_PROFILE_MMC_PATH))) {
+                               /*      close mm plaer */
+                               setting_sound_stop_sound(ad);
+                               /*      close vibration */
+                       }
+               }
+       } else if (!safeStrCmp(vconf_name,
+                       VCONFKEY_SETAPPL_SOUND_STATUS_BOOL)) {
+               status = vconf_keynode_get_bool(key);
+               SETTING_TRACE_DEBUG("sound status is changed. %d", status);
+               if (status)
+                       __enable_sound_menu(ad);
+               else
+                       __disable_sound_menu(ad);
+               setting_sound_update_slider_icon(ad->data_call_volume,
+                               SND_SLIDER_CALL);
+               if (ad->data_sound_when_ring)
+                       elm_object_item_disabled_set(ad->data_sound_when_ring->item,
+                                                                               !status);
+       } else if (!safeStrCmp(vconf_name,
+                       VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL)) {
+               status = vconf_keynode_get_bool(key);
+               SETTING_TRACE_DEBUG("vibration status is changed. %d", status);
+               setting_sound_update_slider_icon(ad->data_call_volume,
+                               SND_SLIDER_CALL);
+       } else if (!safeStrCmp(vconf_name,
+                       VCONFKEY_SETAPPL_VIBRATE_WHEN_RINGING_BOOL)) {
+               item_to_update = ad->data_sound_when_ring;
+               status = vconf_keynode_get_bool(key);
+               if (item_to_update && item_to_update->eo_check) {
+                       item_to_update->chk_status = status;
+                       elm_check_state_set(item_to_update->eo_check,
+                                       item_to_update->chk_status);
+               }
+       } else if (!safeStrCmp(vconf_name,
+                       VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL)) {
+               item_to_update = ad->data_button_sounds;
+               status = vconf_keynode_get_bool(key);
+               if (item_to_update && item_to_update->eo_check) {
+                       item_to_update->chk_status = status;
+                       elm_check_state_set(item_to_update->eo_check,
+                                       item_to_update->chk_status);
+               }
+       } else if (!safeStrCmp(vconf_name,
+                       VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL)) {
+               item_to_update = ad->data_touch_sounds;
+               status = vconf_keynode_get_bool(key);
+               if (item_to_update && item_to_update->eo_check) {
+                       item_to_update->chk_status = status;
+                       elm_check_state_set(item_to_update->eo_check,
+                                       item_to_update->chk_status);
+               }
+       } else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_SOUND_LOCK_BOOL)) {
+               item_to_update = ad->data_lock_sound;
+               status = vconf_keynode_get_bool(key);
+               if (item_to_update && item_to_update->eo_check) {
+                       item_to_update->chk_status = status;
+                       elm_check_state_set(item_to_update->eo_check,
+                                       item_to_update->chk_status);
+               }
+       }
+ #if 0
+       else if (!safeStrCmp(vconf_name, VCONFKEY_ISE_KEYSOUND)) {
+               item_to_update = ad->data_keyboard_sound;
+               status = vconf_keynode_get_bool(key);
+               if (item_to_update && item_to_update->eo_check) {
+                       item_to_update->chk_status = status;
+                       elm_check_state_set(item_to_update->eo_check,
+                                       item_to_update->chk_status);
+               }
+       }
+ #endif
+ }
+ static int __listen_vconf_change(void *data)
+ {
+       retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+       /*Ints */
+       vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+                       __sound_vconf_change_cb, data);
+       /*Bools */
+       vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
+                       __sound_vconf_change_cb, data);
+       vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
+                       __sound_vconf_change_cb, data);
+       vconf_notify_key_changed(
+                       VCONFKEY_SETAPPL_VIBRATE_WHEN_RINGING_BOOL,
+                       __sound_vconf_change_cb, data);
+       vconf_notify_key_changed(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL,
+                       __sound_vconf_change_cb, data);
+       vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL,
+                       __sound_vconf_change_cb, data);
+       vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL,
+                       __sound_vconf_change_cb, data);
+       return 0;
+ }
+ static int __unlisten_vconf_change(void *data)
+ {
+       /* unused listen */
+       /*Ints */
+       vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+                       __sound_vconf_change_cb);
+       /*Bools */
+       vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
+                       __sound_vconf_change_cb);
+       vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
+                       __sound_vconf_change_cb);
+       vconf_ignore_key_changed(
+                       VCONFKEY_SETAPPL_VIBRATE_WHEN_RINGING_BOOL,
+                       __sound_vconf_change_cb);
+       vconf_ignore_key_changed(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL,
+                       __sound_vconf_change_cb);
+       vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL,
+                       __sound_vconf_change_cb);
+       vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL,
+                       __sound_vconf_change_cb);
+       return 0;
+ }
+ static Eina_Bool __volume_up_timer_cb(void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       int volume = 0;
+       int volume_max = 0;
+       int ret = 0;
+       retv_if(!data, EINA_FALSE);
+       SettingSoundData *ad = (SettingSoundData *)data;
+       if (!ad->is_pressing) {
+               ad->updown_timer = NULL;
+               return EINA_FALSE;
+       }
+       ret =  sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
+       SETTING_TRACE("Getting volume: %s %d", get_error_message(ret), volume);
+       ret = sound_manager_get_max_volume(SOUND_TYPE_RINGTONE, &volume_max);
+       SETTING_TRACE("Getting max volume: %s %d", get_error_message(ret),
+                       volume_max);
+       if (volume < volume_max) {
+               sound_manager_set_volume(SOUND_TYPE_RINGTONE, ++volume);
+               if (ad->data_call_volume && ad->data_call_volume->eo_check) {
+                       ad->data_call_volume->chk_status = volume;
+                       elm_slider_value_set(ad->data_call_volume->eo_check,
+                                               volume);
+                       SETTING_TRACE("ad->data_call_volume->chk_status : %d",
+                                       ad->data_call_volume->chk_status);
+               }
+       }
+       return EINA_TRUE;
+ }
+ static Eina_Bool __volume_down_timer_cb(void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       int ret = 0;
+       int volume = 0;
+       retv_if(!data, EINA_FALSE);
+       SettingSoundData *ad = (SettingSoundData *)data;
+       if (!ad->is_pressing) {
+               ad->updown_timer = NULL;
+               return EINA_FALSE;
+       }
+       ret =  sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
+       SETTING_TRACE("Getting volume: %s %d", get_error_message(ret), volume);
+       if (volume > 0) {
+               sound_manager_set_volume(SOUND_TYPE_RINGTONE, --volume);
+               if (volume == 0) {
+                       /* change to Vibration mode */
+                       vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
+                                       FALSE);
+                       vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
+                                       TRUE);
+                       feedback_play_type(FEEDBACK_TYPE_VIBRATION,
+                                       FEEDBACK_PATTERN_VIBRATION_ON);
+               }
+               if (ad->data_call_volume
+                               && ad->data_call_volume->eo_check) {
+                       ad->data_call_volume->chk_status = volume;
+                       elm_slider_value_set(
+                                       ad->data_call_volume->eo_check,
+                                       volume);
+                       SETTING_TRACE("ad->data_call_volume->chk_status : %d",
+                                       ad->data_call_volume->chk_status);
+                       setting_sound_update_slider_icon(
+                                       ad->data_call_volume,
+                                       SND_SLIDER_CALL);
+               }
+       }
+       return EINA_TRUE;
+ }
+ static Eina_Bool __volume_key_up_cb(void *data, int type, void *event)
+ {
+       SETTING_TRACE_BEGIN;
+       retv_if(!data || !event, EINA_TRUE);
+       SettingSoundData *ad = (SettingSoundData *)data;
+       Ecore_Event_Key *ev = event;
+       char *key = (char *)ev->key;
+       if (!key)
+               return EINA_TRUE;
+       if (!safeStrCmp(key, "XF86AudioRaiseVolume")
+                       || !safeStrCmp(key, "XF86AudioLowerVolume")) {
+               ad->is_pressing = FALSE;
+               if (ad->updown_timer) {
+                       ecore_timer_del(ad->updown_timer);
+                       ad->updown_timer = NULL;
+               }
+       }
+       return EINA_TRUE;
+ }
+ /*
+  * S5 concept:
+  * On the volume popup,
+  *    1) if user controls the slider, don't play any sounds
+  *    just change volume.
+  *    2) if user controls the HW volume key for ringtone
+  *    sound, the beep sound is supported
+  * On Setting > Sound
+  *    1) if user controls the slider, change volume &
+  *    play sound
+  *    2) if user controls the HW volume key, do nothing
+  *    (DO NOT change volume,DO NOT play sound)
+ */
+ static Eina_Bool __volume_key_down_cb(void *data, int type, void *event)
+ {
+       int ret = 0;
+       int sound = 0;
+       char *key = NULL;
+       int volume = 0;
+       int volume_max = 0;
+       SettingSoundData *ad = (SettingSoundData *)data;
+       Ecore_Event_Key *ev = event;
+       SETTING_TRACE_BEGIN;
+       retv_if(!ad || !event, EINA_TRUE);
+       key = (char *)ev->key;
+       if (!key)
+               return EINA_TRUE;
+       ret =  sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
+       SETTING_TRACE("Getting volume: %s %d", get_error_message(ret), volume);
+       ret = sound_manager_get_max_volume(SOUND_TYPE_RINGTONE, &volume_max);
+       SETTING_TRACE("Getting max volume: %s %d", get_error_message(ret),
+                       volume_max);
+       vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound);
+       if (!safeStrCmp(key, "XF86AudioRaiseVolume")) {
+               SETTING_TRACE("Press KEY_VOLUMEUP");
+               ad->is_pressing = TRUE;
+               if (volume < volume_max) {
+                       sound_manager_set_volume(SOUND_TYPE_RINGTONE, ++volume);
+                       if (volume > 0 && !sound) {
+                               vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
+                                               TRUE);
+                               vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
+                                               FALSE);
+                               ad->data_call_volume->chk_status =
+                                               volume;
+                               setting_sound_update_slider_icon(
+                                               ad->data_call_volume,
+                                               SND_SLIDER_CALL);
+                       }
+                       if (ad->data_call_volume
+                                       && ad->data_call_volume->eo_check) {
+                               ad->data_call_volume->chk_status = volume;
+                               elm_slider_value_set(
+                                               ad->data_call_volume->eo_check,
+                                               volume);
+                               SETTING_TRACE("chk_status : %d",
+                                       ad->data_call_volume->chk_status);
+                       }
+                       ad->updown_timer = ecore_timer_add(0.5,
+                                                       __volume_up_timer_cb,
+                                                       ad);
+               }
+       }
+       if (!safeStrCmp(key, "XF86AudioLowerVolume")) {
+               SETTING_TRACE("Press KEY_VOLUMEDOWN");
+               ad->is_pressing = TRUE;
+               if (!sound)
+                       return EINA_TRUE;
+               if (volume > 0) {
+                       sound_manager_set_volume(SOUND_TYPE_RINGTONE,
+                                       --volume);
+                       if (volume == 0) {
+                               /* change to Vibration mode */
+                               vconf_set_bool(
+                                       VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
+                                       FALSE);
+                               vconf_set_bool(
+                                       VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
+                                       TRUE);
+                               feedback_play_type(FEEDBACK_TYPE_VIBRATION,
+                                               FEEDBACK_PATTERN_VIBRATION_ON);
+                               ad->data_call_volume->chk_status =
+                                               volume;
+                               setting_sound_update_slider_icon(
+                                               ad->data_call_volume,
+                                               SND_SLIDER_CALL);
+                       }
+                       if (ad->data_call_volume
+                                       && ad->data_call_volume->eo_check) {
+                               ad->data_call_volume->chk_status =
+                                               volume;
+                               elm_slider_value_set(
+                                               ad->data_call_volume->eo_check,
+                                               volume);
+                               SETTING_TRACE("ad->data_call_volume->chk_status : %d",
+                                               ad->data_call_volume->chk_status);
+                       }
+                       ad->updown_timer = ecore_timer_add(0.5,
+                                                       __volume_down_timer_cb,
+                                                       ad);
+               }
+       }
+       return EINA_TRUE;
+ }
+ /* ***************************************************
+  *
+  *general func
+  *
+  ***************************************************/
+ static void __calling_popup_cb(void *data, Evas_Object *obj, void *event_info)
+ {
+       ret_if(data == NULL);
+       SettingSoundData *ad = (SettingSoundData *) data;
+       if (ad->calling_popup) {
+               evas_object_del(ad->calling_popup);
+               ad->calling_popup = NULL;
+       }
+ }
+ static void __mm_player_msg_cb(void *user_param)
+ {
+       SETTING_TRACE_BEGIN;
+       ret_if(user_param == NULL);
+       SettingSoundData *ad = (SettingSoundData *)user_param;
+       SETTING_TRACE("completed_cb is called.");
+       setting_sound_stop_sound(ad);
+ }
+ static Eina_Bool __play_timer_cb(void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       int err;
+       player_state_e state = PLAYER_STATE_NONE;
+       retv_if(!data, EINA_FALSE);
+       SettingSoundData *ad = (SettingSoundData *)data;
+       SETTING_TRACE("player (%x)", (unsigned int)ad->mp_prepare_async);
+       err = player_get_state(ad->mp_player, &state);
+       SETTING_TRACE("state:%d", (int)state);
+       if (state != PLAYER_STATE_READY) {
+               SETTING_TRACE_ERROR(
+                               "state of player is invalid (%s), STATE: %d",
+                               get_error_message(err), state);
+               player_unprepare(ad->mp_player);
+               return EINA_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);
+               player_unset_interrupted_cb(ad->mp_player);
+               player_unprepare(ad->mp_player);
+       }
+       return EINA_FALSE;
+ }
+ /* Async cb : to improve slider's performance when creating player */
+ static void __mm_player_prepared_cb(void *user_data)
+ {
+       SETTING_TRACE_BEGIN;
+       ret_if(!user_data);
+       ecore_idler_add(__play_timer_cb, user_data);
+ }
+ static void __sound_stream_focus_state_changed_cb(
+               sound_stream_info_h stream_info,
+               sound_stream_focus_mask_e focus_mask,
+               sound_stream_focus_state_e focus_state,
+               sound_stream_focus_change_reason_e reason,
+               int sound_behavior,
+               const char *extra_info,
+               void *user_data)
+ {
+       player_state_e state = PLAYER_STATE_NONE;
+       SettingSoundData *ad = (SettingSoundData *)user_data;
+       ret_if(ad == NULL);
+       SETTING_TRACE_ERROR("Focus state changed, reason: %d", (int)reason);
+       if (ad->mp_player) {
+               player_get_state(ad->mp_player, &state);
+               SETTING_TRACE("player state : %d", (int)state);
+       }
+ }
+ bool is_call_status_idle(void)
+ {
++      SETTING_TRACE_BEGIN;
++
+       unsigned int i = 0;
+       unsigned int j = 0;
+       unsigned int call_list_count = 0;
+       telephony_handle_list_s handle_list;
+       telephony_call_h *call_list;
+       telephony_call_status_e status = TELEPHONY_CALL_STATUS_IDLE;
+       bool to_return = true;
+       int err = telephony_init(&handle_list);
+       if (err != TELEPHONY_ERROR_NONE) {
+               SETTING_TRACE_ERROR("Function telephony_init() failed. Error: %s", get_error_message(err));
+               return false;
+       }
+       for (i = 0; i < handle_list.count; ++i) {
+               err = telephony_call_get_call_list(handle_list.handle[i], &call_list_count, &call_list);
+               if (err != TELEPHONY_ERROR_NONE) {
+                       SETTING_TRACE_ERROR("Function telephony_call_get_call_list() failed. Error: %s", get_error_message(err));
+                       continue;
+               }
+               for (j = 0; j < call_list_count; ++j) {
+                       err = telephony_call_get_status(call_list[j], &status);
+                       if (err != TELEPHONY_ERROR_NONE) {
+                               SETTING_TRACE_ERROR("Function telephony_call_get_status() failed. Error: %s", get_error_message(err));
+                               continue;
+                       }
+                       if (status != TELEPHONY_CALL_STATUS_IDLE) {
+                               to_return = false;
+                               break;
+                       }
+               }
+               err = telephony_call_release_call_list(call_list_count, &call_list);
+               if (err != TELEPHONY_ERROR_NONE) {
+                       SETTING_TRACE_ERROR("Function telephony_call_release_call_list() failed. Error: %s", get_error_message(err));
+               }
+               if (to_return == false) {
+                       break;
+               }
+       }
+       err = telephony_deinit(&handle_list);
+       if (err != TELEPHONY_ERROR_NONE) {
+               SETTING_TRACE_ERROR("Function telephony_deinit() failed. Error: %s", get_error_message(err));
+               return false;
+       }
++      SETTING_TRACE_DEBUG("is_call_status: %d", (int)to_return);
+       return to_return;
+ }
index c6c35d3f3490eb101b7e0a0d4c316802ea4aec8f,af042775f808f2e9cd1ffa2651d22b9ce03b8f72..af042775f808f2e9cd1ffa2651d22b9ce03b8f72
mode 100755,100644..100755
index a4e7e207dbef2a4a1434de858a3070a6adef8705,59c5efd6c727dd34a6714815b02514e941a19823..e17f9bd6588b9d90e734af942291a90b23fb3cde
@@@ -1,7 -1,7 +1,11 @@@
  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="org.tizen.setting-ringtone2" version="1.0.0">
+ <manifest xmlns="http://tizen.org/ns/packages" api-version="5.0" package="org.tizen.setting-ringtone" version="1.0.0">
      <profile name="mobile"/>
-     <ui-application appid="org.tizen.setting-ringtone2" exec="setting-ringtone" hw-acceleration="on" launch_mode="caller" multiple="true" nodisplay="true" taskmanage="false" type="capp">
+     <ui-application appid="org.tizen.setting-ringtone" exec="setting-ringtone" hw-acceleration="on" launch_mode="caller" multiple="true" nodisplay="true" taskmanage="false" type="capp">
++        <label>Ringtone</label>
++        <label xml:lang="en-gb">Ringtone</label>
++        <label xml:lang="en-ph">Ringtone</label>
++        <label xml:lang="en-us">Ringtone</label>
          <label>Ringtone</label>
          <label xml:lang="en-gb">Ringtone</label>
          <label xml:lang="en-ph">Ringtone</label>
index 42b1b67801ecbe5e1497be348ae6ad6341bd2e55,940130b2245c1d1d54196943ce489142a9f5a591..04d38b12d407cfcd180b6628bfaecf9215ee5011
mode 100755,100644..100644
index 0000000000000000000000000000000000000000,35783d85f21c2b20b698240048faa640e1a74e1d..72ea4e3f9b242936719344ba785ccfa5e2a22406
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,154 +1,154 @@@
 -#include <telephony.h>
+ /*
+  * sm-data-main.h
+  *
+  *  Created on: Aug 24, 2016
+  *      Author: r.kintop
+  */
+ #ifndef SM_DATA_H_
+ #define SM_DATA_H_
+ #include <app.h>
+ #include <dlog.h>
++#include <telephony/telephony.h>
+ #include <stc.h>
+ #include <app_info.h>
+ #include <app_manager.h>
+ #ifdef  LOG_TAG
+ #undef  LOG_TAG
+ #endif
+ #define LOG_TAG "SmartManager-Data"
+ #if !defined(PACKAGE)
+ #define PACKAGE "org.tizen.setting"
+ #endif
+ #include <setting-common-init.h>
+ #include <setting-common-view.h>
+ typedef enum {
+       MV_UPDATE_APPEND_NONE = 0,
+       MV_UPDATE_SIM_STATE_CHANGED,
+       MV_UPDATE_SIM_1_TOTAL_DATA_USAGE,
+       MV_UPDATE_SIM_2_TOTAL_DATA_USAGE,
+       MV_UPDATE_WIFI_TOTAL_DATA_USAGE,
+       MV_UPDATE_SIM_1_WARN_N_LIMIT,
+       MV_UPDATE_SIM_2_WARN_N_LIMIT,
+       MV_UPDATE_WIFI_WARN_N_LIMIT,
+       MV_UPDATE_CLEAR_ALL_SIM_1_APPS,
+       MV_UPDATE_CLEAR_ALL_SIM_2_APPS,
+       MV_UPDATE_CLEAR_ALL_WIFI_APPS,
+       MV_UPDATE_APPEND_SIM_1_APP,
+       MV_UPDATE_APPEND_SIM_2_APP,
+       MV_UPDATE_APPEND_WIFI_APP
+ } mv_update_type;
+ typedef enum {
+       CYCLE_MODE_MONTHLY = 0,
+       CYCLE_MODE_WEEKLY,
+       CYCLE_MODE_DAILY,
+       CYCLE_MODE_CUSTOM
+ } Cycle_Mode_E;
+ typedef struct {
+       long long int total_data_used;
+       long long int warning;
+       long long int limit;
+       Cycle_Mode_E cycle_mode;
+       time_t interval_from;
+       time_t interval_to;
+       int custom_mode_interval;
+       int cycle_start;
+ } Data_Limits_T;
+ typedef struct {
+       MainData md;
+       Evas_Object *toolbar;
+       telephony_handle_list_s telephony_handles;
+       int num_sim_cards_available; /* Number of SIM cards available.
+                                                                       Necessary for the main view. */
+       char *subscriber_id_1; /* Subscriber ID numbers of sim cards*/
+       char *subscriber_id_2;
+       /* These are lists of application items *
+        * returned by Data Usage API (model).
+        * They contain elements of type data_usage_app_item_t :
+        * */
+       Eina_List *sim_1_apps;
+       Eina_List *sim_2_apps;
+       Eina_List *wifi_apps;
+       /* Main view data: */
+       Ecore_Timer *main_view_update_timer;    /* This timer schedules an update
+                                                                                       * for the progress bar item and apps
+                                                                                       * list.
+                                                                                       */
+       mv_update_type main_view_update_type;
+       setting_view *main_view;
+       Elm_Gen_Item_Class gl_header_itc;
+       Elm_Gen_Item_Class gl_data_usage_itc;
+       Elm_Gen_Item_Class gl_text_itc;
+       Elm_Gen_Item_Class gl_application_itc;
+       Elm_Widget_Item *toolbar_item_sim_1; /* Toolbar item for SIM1 */
+       Elm_Widget_Item *toolbar_item_sim_2; /* Toolbar item for SIM2 */
+       Elm_Widget_Item *toolbar_item_wifi; /* Toolbar item for WIFI */
+       Evas_Object *sim_1_genlist; /* Genlist for SIM1 */
+       Elm_Object_Item *item_sim_1_data_amount; /* The genlist item with
+                                                                                               progress bar */
+       Elm_Object_Item *item_sim_1_data_usage_set; /* The genlist item which allows
+                                                                                                       the user to enter data
+                                                                                                       settings view */
+       Elm_Object_Item *item_sim_1_first_app_info; /* The first application */
+                                                                                               /* item on the list */
+       Evas_Object *sim_2_genlist; /* Genlist for SIM2 */
+       Elm_Object_Item *item_sim_2_data_amount; /* The genlist item with
+                                                                                               progress bar */
+       Elm_Object_Item *item_sim_2_data_usage_set; /* The genlist item which
+                                                                                                       allows the user to enter
+                                                                                                       data settings view */
+       Elm_Object_Item *item_sim_2_first_app_info; /* The first application */
+                                                                                               /* item on the list */
+       Evas_Object *wifi_genlist; /* Genlist for WIFI */
+       Elm_Object_Item *item_wifi_data_amount; /* The genlist item with
+                                                                                               progress bar */
+       Elm_Object_Item *item_wifi_data_usage_set;  /* The genlist item which
+                                                                                                       allows the user to enter
+                                                                                                       data settings view */
+       Elm_Object_Item *item_wifi_first_app_info; /* The first application */
+       /* Wifi view data usage settings: */
+       setting_view *wifi_view;
+       Evas_Object *wifi_data_setting_genlist;
+       /* Mobile view data usage settings: */
+       setting_view *mobile_view;
+       const char *selected_sim_subscriber_id;
+       Data_Limits_T *selected_sim_limits;
+       /* Data statistics and settings: */
+       stc_h stc;
+       /* Data limits: */
+       Data_Limits_T sim_1_limits;
+       Data_Limits_T sim_2_limits;
+       Data_Limits_T wifi_limits;
+ } SmartMgrData;
+ typedef struct {
+       char *appid;
+       char *pkgid;
+       char *icon;
+       char *label;
+       long long data_usage_bytes;
+       const SmartMgrData *ad;
+ } data_usage_app_item_t;
+ void smartmanager_stc_get_all_data(void);
+ void smartmanager_stc_get_sim_total_and_apps_data(void);
+ void smartmanager_stc_get_wifi_total_and_apps_data(void);
+ #endif /* SM_DATA_H_ */
index 0000000000000000000000000000000000000000,a1136c59278294ad1b4c002d56c50406509bfba4..b4cd671360210fd336e2e4e9b566a492eb0dc984
mode 000000,100644..100755
--- /dev/null
@@@ -1,0 -1,158 +1,158 @@@
 -#include <telephony.h>
+ /*
+  * setting
+  *
+  * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd.
+  *
+  * Licensed under the Apache License, Version 2.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  * http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  *
+  */
+ #ifndef SMARTMANAGER_UTILS_H_
+ #define SMARTMANAGER_UTILS_H_
+ #include <stc.h>
+ #include <stc_internal.h>
+ #include <stdbool.h>
++#include <telephony/telephony.h>
+ typedef enum {
+       DATA_RESTRICTION_LIMIT,
+       DATA_RESTRICTION_WARNING_LIMIT
+ } data_restriction_type;
+ typedef enum {
+       RESTRICTIONS_OK = 0,
+       RESTRICTIONS_ERROR = 1
+ } restrictions_result;
+ int get_days_in_current_month();
+ void get_data_amount_str(const char *prefix, long long int num_bytes, char *txt_out,
+                                               int len_max);
+ void get_data_int_amount_str(long long int num_bytes, char *int_amount_str,
+       int len_max);
+ void get_data_unit_str(long long int num_bytes, char *unit_str, int len_max);
+ /**
+  * @brief Formats string composed of number and ordinal number postfix
+  *
+  * @param[in] number          Number to format with postfix
+  * @param[in] output          Formatted string composed of number and postfix
+  * @param[in] max_len         Max len of formatted string
+  *
+  * @return
+  */
+ void create_number_with_postfix(int number, char *output, int max_len);
+ /**
+  * @brief Gets total statistics for SIM type interface
+  *
+  * @param[in] stc                     The statistics rule handle
+  * @param[in] stats_cb                Callback to be called asynchronously
+  * @param[in] subscriber_id   The SIM subscriber id to be passed to stats_cb
+  *                                                    in return from STC API calls
+  * @param[in] t_from          The start of the time interval
+  * @param[in] t_to                    The end of the time interval
+  *
+  * @return true on success, otherwise false
+  *
+  */
+ bool get_sim_total_stats(stc_h stc, stc_stats_info_cb stats_cb,
+                                               const char *subscriber_id, time_t t_from, time_t t_to);
+ /**
+  * @brief Gets total statistics for WiFi type interface
+  *
+  * @param[in] stc                     The statistics rule handle
+  * @param[in] stats_cb                Callback to be called asynchronously
+  * @param[in] t_from          The start of the time interval
+  * @param[in] t_to                    The end of the time interval
+  *
+  * @return true on success, otherwise false
+  *
+  */
+ bool get_wifi_total_stats(stc_h stc, stc_stats_info_cb stats_cb, time_t t_from,
+                                               time_t t_to);
+ /**
+  * @brief Gets a list of all apps and their data usage statistics
+  * for SIM type interface.
+  *
+  * @param[in] stc                     The statistics rule handle
+  * @param[in] stats_cb                Callback to be called asynchronously
+  * @param[in] subscriber_id   The SIM subscriber id to be passed to stats_cb
+  *                                                    in return from STC API calls
+  * @param[in] t_from          The start of the time interval
+  * @param[in] t_to                    The end of the time interval
+  *
+  * @return true on success, otherwise false
+  *
+  */
+ bool get_sim_apps_list(stc_h stc, stc_stats_info_cb stats_cb,
+                                               const char *subscriber_id, time_t t_from, time_t t_to);
+ /**
+  * @brief Gets a list of all apps and their data usage statistics
+  * for WiFi type interface.
+  *
+  * @param[in] stc                     The statistics rule handle
+  * @param[in] stats_cb                Callback to be called asynchronously
+  * @param[in] t_from          The start of the time interval
+  * @param[in] t_to                    The end of the time interval
+  *
+  * @return true on success, otherwise false
+  *
+  */
+ bool get_wifi_apps_list(stc_h stc, stc_stats_info_cb stats_cb, time_t t_from,
+                                               time_t t_to);
+ bool get_sim_restrictions(stc_h stc, stc_restriction_rule_cb restrictions_cb);
+ bool get_wifi_restrictions(stc_h stc, stc_restriction_rule_cb restrictions_cb);
+ bool get_subscriber_id_from_telephony_handle(telephony_h handle,
+                                                                                               char **subscriber_id);
+ bool compare_subscriber_ids(const char *id_a, const char *id_b);
+ restrictions_result set_mobile_limit_restrictions(stc_h stc_handle,
+       const char *subscriber_id, long long int limit, long long int warning_limit);
+ restrictions_result set_mobile_restriction_rule_parameters(
+       stc_restriction_rule_h rule, const char *subscriber_id, long long int limit,
+       long long int warning_limit);
+ bool unset_mobile_limit_restrictions(stc_h stc_handle,
+       stc_restriction_rule_cb restrictions_cb, void *data);
+ bool write_sim_1_cycle_start(int cycle_start_value);
+ bool write_sim_1_cycle_interval(int cycle_interval_value);
+ bool write_sim_1_cycle_mode(int cycle_mode);
+ bool write_sim_2_cycle_start(int cycle_start_value);
+ bool write_sim_2_cycle_interval(int cycle_interval_value);
+ bool write_sim_2_cycle_mode(int cycle_mode);
+ bool write_wifi_cycle_start(int cycle_start_value);
+ bool write_wifi_cycle_interval(int cycle_interval_value);
+ bool write_wifi_cycle_mode(int cycle_mode);
+ bool read_sim_1_cycle_start(int *cycle_start_value);
+ bool read_sim_1_cycle_interval(int *cycle_interval_value);
+ bool read_sim_1_cycle_mode(int *cycle_mode);
+ bool read_sim_2_cycle_start(int *cycle_start_value);
+ bool read_sim_2_cycle_interval(int *cycle_interval_value);
+ bool read_sim_2_cycle_mode(int *cycle_mode);
+ bool read_wifi_cycle_start(int *cycle_start_value);
+ bool read_wifi_cycle_interval(int *cycle_interval_value);
+ bool read_wifi_cycle_mode(int *cycle_mode);
+ #endif /* SMARTMANAGER_UTILS_H_ */
index 0000000000000000000000000000000000000000,d6dc751de30ee7886f59ae58e653f5f3e71cd379..186a9a624fe101cee1857ffcf5c801e8e2083163
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,815 +1,815 @@@
 -                      SETTING_TRACE_ERROR("stc_stats_info_get_subscriber_id() error: %s",
+ #include <Elementary.h>
+ #include <system_settings.h>
+ #include <stdlib.h>
+ #include <setting-common-data-type.h>
+ #include "smartmanager-data.h"
+ #include "smartmanager-data-main-view.h"
+ #include "smartmanager-utils.h"
+ static void _lang_changed(app_event_info_h event_info, void *data);
+ static bool _create_app(void *data);
+ static void _pause_app(void *user_data);
+ static void _resume_app(void *user_data);
+ static void _terminate_app(void *data);
+ static void _app_controll(app_control_h app_control, void *user_data);
+ static void _sim_state_change_cb(telephony_h handle, telephony_noti_e noti_id,
+                                                               void *data, void *user_data);
+ static void _count_available_sim_cards(SmartMgrData *ad);
+ static bool _append_stats_list_item(Eina_List **list, char *app_id, long long data_usage_bytes);
+ static void _clear_all_stat_lists(SmartMgrData *ad);
+ static void _delete_stat_item(data_usage_app_item_t *item);
+ static stc_callback_ret_e _stc_stats_info_cb(stc_error_e result,
+                                                               stc_stats_info_h info, void *user_data);
+ static stc_callback_ret_e _total_stats_cb(stc_error_e result,
+                                                               stc_stats_info_h info, void *user_data);
+ static stc_callback_ret_e _get_restrictions_cb(stc_error_e result,
+                                                               stc_restriction_rule_h info, void *user_data);
+ static void _initialize_cycle(Data_Limits_T *limits);
+ static void _read_all_stat_cycles(void);
+ static void _set_stats_time_frame_from_cycle(Data_Limits_T *limits);
+ static Eina_Bool _delayed_timer_cb(void *data);
+ static SmartMgrData ad = {0,};
+ static bool wifi_stats_checked = false;
+ static bool sim_1_stats_checked = false;
+ static bool sim_2_stats_checked = false;
+ static bool wifi_total_stats_checked = false;
+ static bool sim_1_total_stats_checked = false;
+ static bool sim_2_total_stats_checked = false;
+ static bool wifi_restrictions_checked = false;
+ static bool sim_restrictions_checked = false;
+ static bool all_stat_cycles_checked = false;
+ static Ecore_Timer *periodic_update_timer = NULL;
+ static void _lang_changed(app_event_info_h event_info, void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       char *locale = NULL;
+       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+       elm_language_set(locale);
+       free(locale);
+       SETTING_TRACE_END;
+ }
+ static Eina_Bool _delayed_timer_cb(void *data)
+ {
+       data_usage_app_item_t *item = NULL;
+       if (!all_stat_cycles_checked) {
+               _read_all_stat_cycles();
+               all_stat_cycles_checked = true;
+       }
+       if (!sim_1_total_stats_checked) {
+               ad.sim_1_limits.total_data_used = 0;
+               sim_1_total_stats_checked = get_sim_total_stats(ad.stc,
+                                                               _total_stats_cb, ad.subscriber_id_1,
+                                                               ad.sim_1_limits.interval_from,
+                                                               ad.sim_1_limits.interval_to);
+               return ECORE_CALLBACK_RENEW;
+       }
+       if (!sim_2_total_stats_checked) {
+               ad.sim_2_limits.total_data_used = 0;
+               sim_2_total_stats_checked = get_sim_total_stats(ad.stc,
+                                                               _total_stats_cb, ad.subscriber_id_2,
+                                                               ad.sim_2_limits.interval_from,
+                                                               ad.sim_2_limits.interval_to);
+               return ECORE_CALLBACK_RENEW;
+       }
+       if (!wifi_total_stats_checked) {
+               ad.wifi_limits.total_data_used = 0;
+               wifi_total_stats_checked = get_wifi_total_stats(ad.stc, _total_stats_cb,
+                                                                       ad.wifi_limits.interval_from,
+                                                                       ad.wifi_limits.interval_to);
+               return ECORE_CALLBACK_RENEW;
+       }
+       if (!sim_1_stats_checked) {
+               ad.main_view_update_type = MV_UPDATE_CLEAR_ALL_SIM_1_APPS;
+               setting_view_update(ad.main_view, &ad);
+               EINA_LIST_FREE(ad.sim_1_apps, item)
+                       _delete_stat_item(item);
+               sim_1_stats_checked = get_sim_apps_list(ad.stc,
+                                                               _stc_stats_info_cb, ad.subscriber_id_1,
+                                                               ad.sim_1_limits.interval_from,
+                                                               ad.sim_1_limits.interval_to);
+               return ECORE_CALLBACK_RENEW;
+       }
+       if (!sim_2_stats_checked) {
+               ad.main_view_update_type = MV_UPDATE_CLEAR_ALL_SIM_2_APPS;
+               setting_view_update(ad.main_view, &ad);
+               EINA_LIST_FREE(ad.sim_2_apps, item)
+                       _delete_stat_item(item);
+               sim_2_stats_checked = get_sim_apps_list(ad.stc,
+                                                               _stc_stats_info_cb, ad.subscriber_id_2,
+                                                               ad.sim_2_limits.interval_from,
+                                                               ad.sim_2_limits.interval_to);
+               return ECORE_CALLBACK_RENEW;
+       }
+       if (!wifi_stats_checked) {
+               ad.main_view_update_type = MV_UPDATE_CLEAR_ALL_WIFI_APPS;
+               setting_view_update(ad.main_view, &ad);
+               EINA_LIST_FREE(ad.wifi_apps, item)
+                       _delete_stat_item(item);
+               wifi_stats_checked = get_wifi_apps_list(ad.stc, _stc_stats_info_cb,
+                                                               ad.wifi_limits.interval_from,
+                                                               ad.wifi_limits.interval_to);
+               return ECORE_CALLBACK_RENEW;
+       }
+       if (!sim_restrictions_checked) {
+               ad.sim_1_limits.limit = 0;
+               ad.sim_1_limits.warning = 0;
+               ad.sim_2_limits.limit = 0;
+               ad.sim_2_limits.warning = 0;
+               sim_restrictions_checked = get_sim_restrictions(ad.stc,
+                                                               _get_restrictions_cb);
+               return ECORE_CALLBACK_RENEW;
+       }
+       if (!wifi_restrictions_checked) {
+               ad.wifi_limits.limit = 0;
+               ad.wifi_limits.warning = 0;
+               wifi_restrictions_checked = get_wifi_restrictions(ad.stc,
+                                                               _get_restrictions_cb);
+               return ECORE_CALLBACK_RENEW;
+       }
+       periodic_update_timer = NULL;
+       return ECORE_CALLBACK_CANCEL;
+ }
+ void smartmanager_stc_get_all_data(void)
+ {
+       if (periodic_update_timer)
+               return;
+       wifi_stats_checked = false;
+       sim_1_stats_checked = false;
+       sim_2_stats_checked = false;
+       wifi_total_stats_checked = false;
+       sim_1_total_stats_checked = false;
+       sim_2_total_stats_checked = false;
+       wifi_restrictions_checked = false;
+       sim_restrictions_checked = false;
+       all_stat_cycles_checked = false;
+       periodic_update_timer = ecore_timer_add(0.2, _delayed_timer_cb, NULL);
+       if (!periodic_update_timer)
+               SETTING_TRACE_ERROR("delayed_timer creation failure");
+ }
+ void smartmanager_stc_get_sim_total_and_apps_data(void)
+ {
+       if (periodic_update_timer)
+               return;
+       /*sim_stats_checked = false; TODO: figure out way to update without
+        * blinking*/
+       sim_1_total_stats_checked = false;
+       periodic_update_timer = ecore_timer_add(0.2, _delayed_timer_cb, NULL);
+       if (!periodic_update_timer)
+               SETTING_TRACE_ERROR("delayed_timer creation failure");
+ }
+ void smartmanager_stc_get_wifi_total_and_apps_data(void)
+ {
+       if (periodic_update_timer)
+               return;
+       /*wifi_stats_checked = false; TODO: figure out way to update without
+        * blinking*/
+       wifi_total_stats_checked = false;
+       periodic_update_timer = ecore_timer_add(0.2, _delayed_timer_cb, NULL);
+       if (!periodic_update_timer)
+               SETTING_TRACE_ERROR("delayed_timer creation failure");
+ }
+ static bool _create_app(void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       SmartMgrData *ad = data;
+       int ret = TELEPHONY_ERROR_NONE;
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("BUILD: %s %s", __DATE__, __TIME__);
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("==========================================================");
+       if (!ad)
+               return false;
+       SETTING_TRACE("_create_app");
+       bindtextdomain(SETTING_PACKAGE, SETTING_LOCALEDIR);
+       ret = telephony_init(&ad->telephony_handles);
+       if (TELEPHONY_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("telephony init error %s", get_error_message(ret));
+       } else {
+               SETTING_TRACE_DEBUG("telephony init %s", get_error_message(ret));
+               ret = telephony_set_noti_cb(ad->telephony_handles.handle[0],
+                                               TELEPHONY_NOTI_SIM_STATUS, _sim_state_change_cb, ad);
+               SETTING_TRACE_DEBUG("telephony_set_noti_cb[0] %s",
+                                                               get_error_message(ret));
+               if (get_subscriber_id_from_telephony_handle(
+                                       ad->telephony_handles.handle[0], &ad->subscriber_id_1)
+                       )
+                       SETTING_TRACE_DEBUG("SUBSCRIBER_ID_1 %s", ad->subscriber_id_1);
+               if (ad->telephony_handles.count > 1) {
+                       ret = telephony_set_noti_cb(ad->telephony_handles.handle[1],
+                                               TELEPHONY_NOTI_SIM_STATUS, _sim_state_change_cb, ad);
+                       SETTING_TRACE_DEBUG("telephony_set_noti_cb[1] %s",
+                                                                       get_error_message(ret));
+                       if (get_subscriber_id_from_telephony_handle(
+                                       ad->telephony_handles.handle[1], &ad->subscriber_id_2)
+                               )
+                               SETTING_TRACE_DEBUG("SUBSCRIBER_ID_2 %s", ad->subscriber_id_2);
+               }
+               _count_available_sim_cards(ad);
+       }
+       _read_all_stat_cycles();
+       ret = stc_initialize(&ad->stc);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_initialize() error: %s", get_error_message(ret));
+               return false;
+       }
+       SETTING_TRACE("STC INITIALIZED");
+       init_main_view(ad);
+       setting_view_node_table_intialize();
+       setting_view_node_table_register(ad->main_view, NULL);
+       setting_view_create(ad->main_view, ad);
+       setting_view_node_set_cur_view(ad->main_view);
+       ad->main_view_update_type = MV_UPDATE_CLEAR_ALL_WIFI_APPS;
+       setting_view_update(ad->main_view, ad);
+       ad->main_view_update_type = MV_UPDATE_CLEAR_ALL_SIM_1_APPS;
+       setting_view_update(ad->main_view, ad);
+       ad->main_view_update_type = MV_UPDATE_CLEAR_ALL_SIM_2_APPS;
+       setting_view_update(ad->main_view, ad);
+       SETTING_TRACE_END;
+       return true;
+ }
+ static void _pause_app(void *user_data)
+ {
+       SETTING_TRACE_BEGIN;
+       ecore_timer_del(periodic_update_timer);
+       periodic_update_timer = NULL;
+       SETTING_TRACE_END;
+ }
+ static void _resume_app(void *user_data)
+ {
+       SETTING_TRACE_BEGIN;
+       smartmanager_stc_get_all_data();
+       SETTING_TRACE_END;
+ }
+ static void _terminate_app(void *data)
+ {
+       SETTING_TRACE_BEGIN;
+       SmartMgrData *ad = data;
+       if (!ad)
+               return;
+       setting_view_destroy(ad->main_view, ad);
+       stc_deinitialize(ad->stc);
+       telephony_deinit(&ad->telephony_handles);
+       _clear_all_stat_lists(ad);
+       free(ad->subscriber_id_1);
+       free(ad->subscriber_id_2);
+       SETTING_TRACE_END;
+ }
+ static void _app_controll(app_control_h app_control, void *user_data)
+ {
+       SETTING_TRACE_BEGIN;
+       SETTING_TRACE_END;
+ }
+ static void _sim_state_change_cb(telephony_h handle, telephony_noti_e noti_id,
+                                                               void *data, void *user_data)
+ {
+       SETTING_TRACE_BEGIN;
+       SmartMgrData *ad = data;
+       if (!ad)
+               return;
+       _count_available_sim_cards(ad);
+       free(ad->subscriber_id_1);
+       free(ad->subscriber_id_2);
+       ad->subscriber_id_1 = ad->subscriber_id_2 = NULL;
+       if (get_subscriber_id_from_telephony_handle(
+                               ad->telephony_handles.handle[0],
+                               &ad->subscriber_id_1)
+               )
+               SETTING_TRACE_DEBUG("SUBSCRIBER_ID_1 %s", ad->subscriber_id_1);
+       if (ad->num_sim_cards_available > 1)
+               if (get_subscriber_id_from_telephony_handle(
+                               ad->telephony_handles.handle[1],
+                               &ad->subscriber_id_2)
+                       )
+                       SETTING_TRACE_DEBUG("SUBSCRIBER_ID_2 %s", ad->subscriber_id_2);
+       if (setting_view_node_get_cur_view() == ad->main_view) {
+               SETTING_TRACE_DEBUG("_sim_state_change_cb: updating main view");
+               ad->main_view_update_type = MV_UPDATE_SIM_STATE_CHANGED;
+               setting_view_update(ad->main_view, ad);
+       } else {
+               SETTING_TRACE_DEBUG("_sim_state_change_cb: going back to main view");
+               setting_view_change(setting_view_node_get_cur_view(), ad->main_view,
+                                                       ad);
+       }
+       SETTING_TRACE_END;
+ }
+ static void _count_available_sim_cards(SmartMgrData *ad)
+ {
+       SETTING_TRACE_BEGIN;
+       telephony_sim_state_e sim_state = TELEPHONY_SIM_STATE_UNKNOWN;
+       int ret = TELEPHONY_ERROR_NONE;
+       ad->num_sim_cards_available = 0;
+       SETTING_TRACE_DEBUG("Number of available SIM card SLOTS: %d",
+                                               ad->telephony_handles.count);
+       if (ad->telephony_handles.count > 0)
+               ret = telephony_sim_get_state(ad->telephony_handles.handle[0],
+                                                                               &sim_state);
+       SETTING_TRACE_DEBUG("get SIM1 state: %s state: %d",
+                                               get_error_message(ret), sim_state);
+       if (TELEPHONY_ERROR_NONE == ret &&
+                       TELEPHONY_SIM_STATE_AVAILABLE == sim_state)
+               ad->num_sim_cards_available++;
+       sim_state = TELEPHONY_SIM_STATE_UNKNOWN;
+       if (ad->telephony_handles.count > 1)
+               ret = telephony_sim_get_state(ad->telephony_handles.handle[1],
+                                                                               &sim_state);
+       SETTING_TRACE_DEBUG("get SIM2 state: %s state: %d",
+                                               get_error_message(ret), sim_state);
+       if (TELEPHONY_ERROR_NONE == ret &&
+                       TELEPHONY_SIM_STATE_AVAILABLE == sim_state)
+               ad->num_sim_cards_available++;
+       SETTING_TRACE_DEBUG("Number of available SIM cards: %d",
+                                                       ad->num_sim_cards_available);
+       SETTING_TRACE_END;
+ }
+ int main(int argc, char *argv[])
+ {
+       app_event_handler_h handlers[5] = {NULL, };
+       ui_app_lifecycle_callback_s ops = {
+               .create = _create_app,
+               .pause = _pause_app,
+               .resume = _resume_app,
+               .terminate = _terminate_app,
+               .app_control = _app_controll
+       };
+       ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY],
+                       APP_EVENT_LOW_MEMORY, NULL, NULL);
+       ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY],
+                       APP_EVENT_LOW_BATTERY, NULL, NULL);
+       ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
+                       APP_EVENT_LANGUAGE_CHANGED, _lang_changed, NULL);
+       ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
+                       APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL);
+       ui_app_add_event_handler(
+                       &handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED],
+                       APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL);
+       return ui_app_main(argc, argv, &ops, &ad);
+ }
+ static bool _append_stats_list_item(Eina_List **list, char *app_id, long long data_usage_bytes)
+ {
+       SETTING_TRACE_BEGIN;
+       data_usage_app_item_t *dua = calloc(1, sizeof(data_usage_app_item_t));
+       app_info_h app_info = NULL;
+       if (!dua)
+               return false;
+       int ret = app_info_create(app_id, &app_info);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               SETTING_TRACE_ERROR("app_info_create() for %s error: %s",
+                                                       app_id, get_error_message(ret));
+               _delete_stat_item(dua);
+               return false;
+       }
+       dua->ad = &ad;
+       dua->appid = strdup(app_id);
+       dua->data_usage_bytes = data_usage_bytes;
+       ret = app_info_get_package(app_info, &dua->pkgid);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               SETTING_TRACE_ERROR("app_info_get_package() error: %s", get_error_message(ret));
+               _delete_stat_item(dua);
+               return false;
+       }
+       ret = app_info_get_label(app_info, &dua->label);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               SETTING_TRACE_ERROR("app_info_get_label() error: %s", get_error_message(ret));
+               _delete_stat_item(dua);
+               return false;
+       }
+       ret = app_info_get_icon(app_info, &dua->icon);
+       if (ret != APP_MANAGER_ERROR_NONE) {
+               SETTING_TRACE_ERROR("app_info_get_package() error: %s", get_error_message(ret));
+               _delete_stat_item(dua);
+               return false;
+       }
+       *list = eina_list_append(*list, dua);
+       SETTING_TRACE_END;
+       return true;
+ }
+ static void _clear_all_stat_lists(SmartMgrData *ad)
+ {
+       data_usage_app_item_t *item = NULL;
+       EINA_LIST_FREE(ad->sim_1_apps, item)
+               _delete_stat_item(item);
+       EINA_LIST_FREE(ad->sim_2_apps, item)
+               _delete_stat_item(item);
+       EINA_LIST_FREE(ad->wifi_apps, item)
+               _delete_stat_item(item);
+ }
+ static void _delete_stat_item(data_usage_app_item_t *item)
+ {
+       free(item->appid);
+       free(item->pkgid);
+       free(item->icon);
+       free(item->label);
+       free(item);
+ }
+ static stc_callback_ret_e _stc_stats_info_cb(stc_error_e result,
+                                                               stc_stats_info_h info, void *user_data)
+ {
+       char *app_id = NULL;
+       char *subscriber_id = NULL;
+       const char *subscriber_id_to_look_for = user_data;
+       long long int incoming = 0;
+       long long int outgoing = 0;
+       stc_iface_type_e iface = STC_IFACE_UNKNOWN;
+       SETTING_TRACE_DEBUG("per app cb, looking for subscriber id: %s",
+                                               subscriber_id_to_look_for);
+       if (STC_ERROR_NONE != result) {
+               SETTING_TRACE_ERROR("Error in callback: %s", get_error_message(result));
+               return STC_CALLBACK_CONTINUE;
+       }
+       int ret = stc_stats_info_get_app_id(info, &app_id);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_info_get_app_id() error: %s",
+                                                       get_error_message(ret));
+               return STC_CALLBACK_CONTINUE;
+       }
+       SETTING_TRACE_DEBUG("App name: %s", app_id);
+       ret = stc_stats_info_get_counter(info, &incoming, &outgoing);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_info_get_counter() error: %s",
+                                                       get_error_message(ret));
+               free(app_id);
+               return STC_CALLBACK_CONTINUE;
+       }
+       ret = stc_stats_info_get_iface_type(info, &iface);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_info_get_iface_type() error: %s",
+                                                       get_error_message(ret));
+               free(app_id);
+               return STC_CALLBACK_CONTINUE;
+       }
+       SETTING_TRACE_DEBUG("Obtained iface: %d", iface);
+       if (iface == STC_IFACE_WIFI) {
+               if (_append_stats_list_item(&ad.wifi_apps, app_id, incoming + outgoing)
+                       ) {
+                       ad.main_view_update_type = MV_UPDATE_APPEND_WIFI_APP;
+                       setting_view_update(ad.main_view, &ad);
+               }
+       }
+       if (iface == STC_IFACE_DATACALL) {
+               ret = stc_stats_info_get_subscriber_id(info, &subscriber_id);
+               if (STC_ERROR_NONE == ret &&
+                               compare_subscriber_ids(subscriber_id,
+                                                                               subscriber_id_to_look_for)
+                       ) {
+                       SETTING_TRACE_DEBUG("Obtained subscriber ID: %s", subscriber_id);
+                       if (compare_subscriber_ids(ad.subscriber_id_1, subscriber_id))
+                               if (_append_stats_list_item(&ad.sim_1_apps, app_id, incoming + outgoing)) {
+                                       ad.main_view_update_type = MV_UPDATE_APPEND_SIM_1_APP;
+                                       setting_view_update(ad.main_view, &ad);
+                               }
+                       if (compare_subscriber_ids(ad.subscriber_id_2, subscriber_id))
+                               if (_append_stats_list_item(&ad.sim_2_apps, app_id, incoming + outgoing)) {
+                                       ad.main_view_update_type = MV_UPDATE_APPEND_SIM_2_APP;
+                                       setting_view_update(ad.main_view, &ad);
+                               }
+               } else {
+                       SETTING_TRACE_ERROR("stc_stats_info_get_subscriber_id() error:"\
+                                       " %s , subscriber id: %s , subscriber id to look for: %s",
+                                                                               get_error_message(ret),
+                                                                               subscriber_id,
+                                                                               subscriber_id_to_look_for);
+               }
+               free(subscriber_id);
+       }
+       free(app_id);
+       return STC_CALLBACK_CONTINUE;
+ }
+ static stc_callback_ret_e _total_stats_cb(stc_error_e result,
+                                                               stc_stats_info_h info, void *user_data)
+ {
+       long long int incoming = 0;
+       long long int outgoing = 0;
+       char *subscriber_id = NULL;
+       const char *subscriber_id_to_look_for = user_data;
+       int ret = STC_ERROR_NONE;
+       stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+       SETTING_TRACE_DEBUG("total stats cb, looking for subscriber id: %s",
+                                               subscriber_id_to_look_for);
+       if (STC_ERROR_NONE != result) {
+               SETTING_TRACE_ERROR("Error in cb: %s", get_error_message(result));
+               return STC_CALLBACK_CANCEL;
+       }
+       ret = stc_stats_info_get_iface_type(info, &iface_type);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("get interface error: %s", get_error_message(ret));
+               return STC_CALLBACK_CANCEL;
+       }
+       SETTING_TRACE_DEBUG("Obtained iface: %d", iface_type);
+       ret = stc_stats_info_get_counter(info, &incoming, &outgoing);
+       if (STC_ERROR_NONE == ret) {
+               if (iface_type == STC_IFACE_DATACALL) {
+                       ret = stc_stats_info_get_subscriber_id(info, &subscriber_id);
+                       if (STC_ERROR_NONE == ret &&
+                               compare_subscriber_ids(subscriber_id,
+                                                                               subscriber_id_to_look_for)
+                               ) {
+                               SETTING_TRACE_DEBUG("Obtained SUBSCRIBER ID: %s",
+                                                                       subscriber_id);
+                               if (compare_subscriber_ids(ad.subscriber_id_1, subscriber_id)) {
+                                       ad.main_view_update_type = MV_UPDATE_SIM_1_TOTAL_DATA_USAGE;
+                                       ad.sim_1_limits.total_data_used = incoming + outgoing;
+                                       SETTING_TRACE("SIM 1 total in: %lld out: %lld", incoming, outgoing);
+                               }
+                               if (compare_subscriber_ids(ad.subscriber_id_2, subscriber_id)) {
+                                       ad.main_view_update_type = MV_UPDATE_SIM_2_TOTAL_DATA_USAGE;
+                                       ad.sim_2_limits.total_data_used = incoming + outgoing;
+                                       SETTING_TRACE("SIM 2 total in: %lld out: %lld", incoming, outgoing);
+                               }
+                       } else {
+                               SETTING_TRACE_ERROR("stc_stats_info_get_subscriber_id() error: %s",
+                                                                                       get_error_message(ret));
+                       }
+                       free(subscriber_id);
+               }
+               if (iface_type == STC_IFACE_WIFI) {
+                       ad.main_view_update_type = MV_UPDATE_WIFI_TOTAL_DATA_USAGE;
+                       ad.wifi_limits.total_data_used = incoming + outgoing;
+                       SETTING_TRACE("WIFI total in: %lld out: %lld", incoming, outgoing);
+               }
+               setting_view_update(ad.main_view, &ad);
+       } else {
+               SETTING_TRACE_ERROR("get counter error: %s", get_error_message(ret));
+               return STC_CALLBACK_CANCEL;
+       }
+       return STC_CALLBACK_CONTINUE;
+ }
+ static stc_callback_ret_e _get_restrictions_cb(stc_error_e result,
+                                                               stc_restriction_rule_h info, void *user_data)
+ {
+       int ret = STC_ERROR_NONE;
+       char *app_id = NULL;
+       char *subscriber_id = NULL;
+       stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+       SETTING_TRACE_DEBUG("restriction cb:");
+       if (STC_ERROR_NONE != result) {
+               SETTING_TRACE_ERROR("_get_restrictions_cb error: %s",
+                                                       get_error_message(result));
+               return STC_CALLBACK_CONTINUE;
+       }
+       stc_restriction_rule_get_app_id(info, &app_id);
+       if (!app_id ||
+               (strcmp("TOTAL_DATACALL", app_id) && strcmp("TOTAL_WIFI", app_id))) {
+               free(app_id);
+               return STC_CALLBACK_CONTINUE;
+       }
+       SETTING_TRACE_DEBUG("Obtaining restrictions for: %s", app_id);
+       free(app_id);
+       ret = stc_restriction_rule_get_iface_type(info, &iface_type);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_get_iface_type error: %s",
+                                                       get_error_message(ret));
+               return STC_CALLBACK_CONTINUE;
+       }
+       SETTING_TRACE_DEBUG("Obtained iface: %d", iface_type);
+       if (iface_type == STC_IFACE_DATACALL) {
+               ret = stc_restriction_rule_get_subscriber_id(info, &subscriber_id);
+               if (STC_ERROR_NONE == ret) {
+                       SETTING_TRACE_DEBUG("Obtained Subscriber ID: %s", subscriber_id);
+                       if (compare_subscriber_ids(ad.subscriber_id_1, subscriber_id)) {
+                               (void)stc_restriction_rule_get_limit(info,
+                                                                                                       &(ad.sim_1_limits.limit));
+                               (void)stc_restriction_rule_get_warning_limit(info,
+                                                                                                       &(ad.sim_1_limits.warning));
+                               ad.main_view_update_type = MV_UPDATE_SIM_1_WARN_N_LIMIT;
+                       }
+                       if (compare_subscriber_ids(ad.subscriber_id_2, subscriber_id)) {
+                               (void)stc_restriction_rule_get_limit(info,
+                                                                                                       &(ad.sim_2_limits.limit));
+                               (void)stc_restriction_rule_get_warning_limit(info,
+                                                                                                       &(ad.sim_2_limits.warning));
+                               ad.main_view_update_type = MV_UPDATE_SIM_2_WARN_N_LIMIT;
+                       }
+                       setting_view_update(ad.main_view, &ad);
+               } else {
++                      SETTING_TRACE_ERROR("stc_stats_rule_get_subscriber_id() error: %s",
+                                                                               get_error_message(ret));
+               }
+               free(subscriber_id);
+       }
+       if (iface_type == STC_IFACE_WIFI) {
+               (void)stc_restriction_rule_get_limit(info,
+                                                                                               &(ad.wifi_limits.limit));
+               (void)stc_restriction_rule_get_warning_limit(info,
+                                                                                               &(ad.wifi_limits.warning));
+               ad.main_view_update_type = MV_UPDATE_WIFI_WARN_N_LIMIT;
+               setting_view_update(ad.main_view, &ad);
+       }
+       return STC_CALLBACK_CONTINUE;
+ }
+ static void _initialize_cycle(Data_Limits_T *limits)
+ {
+       limits->custom_mode_interval = 1;
+       limits->cycle_mode = CYCLE_MODE_MONTHLY;
+       limits->cycle_start = 1;
+ }
+ static void _read_all_stat_cycles(void)
+ {
+       _initialize_cycle(&ad.sim_1_limits);
+       _initialize_cycle(&ad.sim_2_limits);
+       _initialize_cycle(&ad.wifi_limits);
+       if (!read_sim_1_cycle_mode((int *)&(ad.sim_1_limits.cycle_mode)))
+               SETTING_TRACE_ERROR("sim1 cycle mode read error");
+       read_sim_1_cycle_start(&(ad.sim_1_limits.cycle_start));
+       read_sim_1_cycle_interval(&(ad.sim_1_limits.custom_mode_interval));
+       if (!read_sim_2_cycle_mode((int *)&(ad.sim_2_limits.cycle_mode)))
+               SETTING_TRACE_ERROR("sim2 cycle mode read error");
+       read_sim_2_cycle_start(&(ad.sim_2_limits.cycle_start));
+       read_sim_2_cycle_interval(&(ad.sim_2_limits.custom_mode_interval));
+       if (!read_wifi_cycle_mode((int *)&(ad.wifi_limits.cycle_mode)))
+               SETTING_TRACE_ERROR("wifi cycle mode read error");
+       read_wifi_cycle_start(&(ad.wifi_limits.cycle_start));
+       read_wifi_cycle_interval(&(ad.wifi_limits.custom_mode_interval));
+       _set_stats_time_frame_from_cycle(&ad.sim_1_limits);
+       _set_stats_time_frame_from_cycle(&ad.sim_2_limits);
+       _set_stats_time_frame_from_cycle(&ad.wifi_limits);
+ }
+ static void _set_stats_time_frame_from_cycle(Data_Limits_T *limits)
+ {
+       time_t now = 0;
+       long long custom_cycles_reminder = 0;
+       struct tm tm_past_delta = {0,};
+       struct tm tm_future_delta = {0,};
+       time(&now);
+       struct tm *tm_now = localtime(&now);
+       tm_now->tm_sec = 1;
+       tm_now->tm_min = 0;
+       tm_now->tm_hour = 0;
+       tm_past_delta = *tm_now;
+       tm_future_delta = *tm_now;
+       switch (limits->cycle_mode) {
+       case CYCLE_MODE_MONTHLY:
+               tm_past_delta.tm_mday = limits->cycle_start;
+               if (tm_now->tm_mday >= limits->cycle_start) {
+                       tm_future_delta.tm_mon++;
+                       tm_future_delta.tm_sec = 0;
+                       tm_future_delta.tm_min = 0;
+                       tm_future_delta.tm_hour = 0;
+                       tm_future_delta.tm_mday = limits->cycle_start + 1;
+               } else {
+                       tm_past_delta.tm_mon--;
+                       tm_future_delta.tm_mday = limits->cycle_start;
+               }
+               break;
+       case CYCLE_MODE_WEEKLY:
+               tm_now->tm_wday--;
+               if (tm_now->tm_wday < 0)
+                       tm_now->tm_wday = 6;
+               if (tm_now->tm_wday >= limits->cycle_start) {
+                       tm_past_delta.tm_mday -= (tm_now->tm_wday + 1 - limits->cycle_start);
+                       tm_future_delta.tm_mday += (7 + limits->cycle_start - tm_now->tm_wday);
+               } else {
+                       tm_past_delta.tm_mday -= (7 + tm_now->tm_wday - limits->cycle_start);
+                       tm_future_delta.tm_mday += (limits->cycle_start - tm_now->tm_wday);
+               }
+               break;
+       case CYCLE_MODE_DAILY:
+               tm_future_delta.tm_sec = 0;
+               tm_future_delta.tm_min = 0;
+               tm_future_delta.tm_hour = 0;
+               tm_future_delta.tm_mday++;
+               break;
+       case CYCLE_MODE_CUSTOM:
+               if (limits->custom_mode_interval <= 0) {
+                       SETTING_TRACE_ERROR("Error: custom mode interval is %d",
+                                                               limits->custom_mode_interval);
+                       return;
+               }
+               custom_cycles_reminder = (now - (time_t)limits->cycle_start) %
+               (limits->custom_mode_interval * 24 * 60 * 60);
+               limits->interval_from = now - custom_cycles_reminder;
+               limits->interval_to = limits->interval_from +
+                                       (((time_t)limits->custom_mode_interval) * 24 * 60 * 60);
+               return;
+       default:
+               return;
+       }
+       limits->interval_from = mktime(&tm_past_delta);
+       limits->interval_to = mktime(&tm_future_delta);
+ }