free(locale);
}
+static void _append_stats_list_item(Evas_Object *list, char *app_id, long long data_usage_bytes)
+{
+ data_usage_app_item_t *dua = calloc(1, sizeof(data_usage_app_item_t));
+ app_info_h app_info;
+ int ret = app_info_create(app_id, &app_info);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] cause error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ dua->appid = app_id;
+ dua->data_usage_bytes = data_usage_bytes;
+
+ ret = app_info_get_package(app_info, &dua->pkgid);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] app_info_get_package() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ ret = app_info_get_label(app_info, &dua->label);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] app_info_get_label() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ ret = app_info_get_icon(app_info, &dua->icon);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] app_info_get_package() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ eina_list_append(list, dua);
+}
+
+static stc_callback_ret_e _stc_stats_info_cb(stc_error_e result, stc_stats_info_h info, void *user_data)
+{
+ SETTING_TRACE_BEGIN;
+ char *app_id = NULL;
+ int64_t incoming = 0;
+ int64_t outgoing = 0;
+ stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+ Evas_Object *list = NULL;
+
+ int ret = stc_stats_info_get_app_id(info, &app_id);
+ if (ret != STC_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_stats_info_get_app_id() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ ret = stc_stats_info_get_counter(info, &incoming, &outgoing);
+ if (ret != STC_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_stats_info_get_counter() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] APP: %s in: %lld out: %lld",
+ basename(__FILE__), __LINE__,
+ app_id, incoming, outgoing);
+
+
+ ret = stc_stats_info_get_iface_type(info, &iface_type);
+ if (ret != STC_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_stats_info_get_iface_type() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return STC_CALLBACK_CONTINUE;
+ }
+
+ if (iface_type == STC_IFACE_WIFI) {
+ list = ad.wifi_apps;
+ ad.total_data_wifi += incoming + outgoing;
+ } else if (iface_type == STC_IFACE_DATACALL) {
+ list = ad.sim_1_apps;
+ ad.total_data_sim += incoming + outgoing;
+ }
+
+ _append_stats_list_item(list, app_id, incoming + outgoing);
+
+ SETTING_TRACE_END;
+ return STC_CALLBACK_CONTINUE;
+}
+
+static void _create_stats_list(Eina_List *list, stc_iface_type_e iface)
+{
+ SETTING_TRACE_BEGIN;
+
+ stc_stats_rule_h rule;
+ int ret = stc_stats_rule_create(ad.stc, &rule);
+ if (ret != STC_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_stats_rule_create() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ time_t now = time(NULL);
+
+ ret = stc_stats_rule_set_time_interval(rule, now - STC_TIME_PERIOD_MONTH, now - 1);
+ if (ret != STC_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_stats_rule_set_time_interval() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ ret = stc_stats_rule_set_iface_type(rule, iface);
+ if (ret != STC_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_stats_rule_set_iface_type() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ ret = stc_foreach_stats(ad.stc, rule, _stc_stats_info_cb, list);
+ if (ret != STC_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_get_stats() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return;
+ }
+
+ SETTING_TRACE_END;
+}
+
static bool _create_app(void *data)
{
SmartMgrData *ad = data;
int ret = TELEPHONY_ERROR_NONE;
+ dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] ==========================================================", basename(__FILE__), __LINE__);
+ dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] ==========================================================", basename(__FILE__), __LINE__);
+ dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] ==========================================================", basename(__FILE__), __LINE__);
+ dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] BUILD: %s %s", basename(__FILE__), __LINE__, __DATE__, __TIME__);
+ dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] ==========================================================", basename(__FILE__), __LINE__);
+ dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] ==========================================================", basename(__FILE__), __LINE__);
+ dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] ==========================================================", basename(__FILE__), __LINE__);
+
if (!ad)
return false;
}
_count_available_sim_cards(ad);
}
-/* test only:
- data_usage_app_item_t *tmp = calloc (1, sizeof(data_usage_app_item_t));
- ad->sim_1_apps = eina_list_append(ad->sim_1_apps, tmp);
- tmp->label = strdup("App1");
- tmp->icon = strdup("/usr/apps/org.tizen.setting/shared/res/org.tizen.setting.png");
- tmp->data_usage_bytes = 666;
- tmp->percent = 15;
-
- tmp = calloc (1, sizeof(data_usage_app_item_t));
- ad->sim_1_apps = eina_list_append(ad->sim_1_apps, tmp);
- tmp->label = strdup("App2");
- tmp->icon = strdup("/usr/apps/org.tizen.setting/shared/res/org.tizen.setting.png");
- tmp->data_usage_bytes = 1024;
- tmp->percent = 40;
-
- tmp = calloc (1, sizeof(data_usage_app_item_t));
- ad->sim_1_apps = eina_list_append(ad->sim_1_apps, tmp);
- tmp->label = strdup("App3");
- tmp->icon = strdup("/usr/apps/org.tizen.setting/shared/res/org.tizen.setting.png");
- tmp->data_usage_bytes = 6612354456;
- tmp->percent = 97;
-*/
+
+ ret = stc_initialize(&ad->stc);
+ if (ret != STC_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_initialize() error: %s", __FILE__, __LINE__, get_error_message(ret));
+ return false;
+ }
+
+ _create_stats_list(ad->wifi_apps, STC_IFACE_WIFI);
+ _create_stats_list(ad->sim_1_apps, STC_IFACE_DATACALL);
+
+ dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] STC INITIALIZED", basename(__FILE__), __LINE__);
+
init_main_view(ad);
setting_view_node_table_intialize();
setting_view_node_table_register(ad->main_view, NULL);