[SM][DATA] Storing apps that used network transfer. 65/135665/4
authorMichal Skorupinski <m.skorupinsk@samsung.com>
Fri, 23 Jun 2017 18:48:57 +0000 (20:48 +0200)
committerMichal Skorupinski <m.skorupinsk@samsung.com>
Thu, 6 Jul 2017 13:41:30 +0000 (15:41 +0200)
Change-Id: I55fe3a83701d70961e99aed49ca0a59767673207
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
setting-smartmanager/smartmanager-data/src/smartmanager-data-main-view.c
setting-smartmanager/smartmanager-data/src/smartmanager-data.c

index d78a938b97ac41476e310e29ca63b62dcceeaa04..b80e52a4bcbc4fb696ad7e0c069d4787efe1d7dd 100644 (file)
@@ -334,7 +334,7 @@ static void _append_app_list(SmartMgrData *ad, Elm_Object_Item **first_app_item,
        Eina_List *iterator = NULL;
 
        if (!genlist || !ad || !model_list) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "NULL argument");
+               SETTING_TRACE_ERROR("NULL argument");
                return;
        }
 
index b625f30528006f7f4e013b6e8c87a798abd3ba80..09c6e7167d394e657f25147a7a113cb22ab74327 100644 (file)
@@ -34,52 +34,71 @@ static stc_callback_ret_e _stc_stats_info_cb(stc_error_e result, stc_stats_info_
        char *app_id = NULL;
        int64_t incoming = 0;
        int64_t outgoing = 0;
-       stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+       Eina_List **list = NULL;
+       stc_iface_type_e iface = (stc_iface_type_e)user_data;
 
        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));
+               SETTING_TRACE_ERROR("stc_stats_info_get_app_id() error: %s", 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));
+               SETTING_TRACE_ERROR("stc_stats_info_get_counter() error: %s", get_error_message(ret));
                free(app_id);
                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));
-               free(app_id);
-               return STC_CALLBACK_CONTINUE;
-       }
-
-       if (iface_type == STC_IFACE_WIFI) {
+       if (iface == STC_IFACE_WIFI) {
+               list = &ad.wifi_apps;
                ad.total_data_wifi += incoming + outgoing;
-               _append_stats_list_item(&ad.wifi_apps, app_id, incoming + outgoing);
-       } else if (iface_type == STC_IFACE_DATACALL) {
+       } else if (iface == STC_IFACE_DATACALL) {
+               list = &ad.sim_1_apps;
                ad.total_data_sim += incoming + outgoing;
-               _append_stats_list_item(&ad.sim_1_apps, app_id, incoming + outgoing);
+       } else {
+               SETTING_TRACE_ERROR("Unknown interface: %d", iface);
        }
 
+       _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)
+//Test only
+void _dbg_app_list(Eina_List *list, char *title)
+{
+       SETTING_TRACE_BEGIN;
+       Eina_List *l;
+       data_usage_app_item_t *test_dua;
+
+       SETTING_TRACE("=============================== %s: [%p] %d ===============================", title, list, eina_list_count(list));
+
+       EINA_LIST_FOREACH(list, l, test_dua)
+       {
+               if (!test_dua) {
+                       SETTING_TRACE_ERROR("[%s:%d] test_dua == NULL");
+                       continue;
+               }
+
+               SETTING_TRACE("APP: %s PKG: %s icon: %s label: %s data: %lld",
+                                test_dua->appid, test_dua->pkgid, test_dua->icon, test_dua->label, test_dua->data_usage_bytes);
+       }
+
+       SETTING_TRACE("===============================-------------===============================");
+
+       SETTING_TRACE_END;
+}
+
+static void _create_stats_list(stc_iface_type_e iface)
 {
        SETTING_TRACE_BEGIN;
 
        stc_stats_rule_h rule = NULL;
        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));
+               SETTING_TRACE_ERROR("stc_stats_rule_create() error: %s", get_error_message(ret));
                return;
        }
 
@@ -93,19 +112,19 @@ static void _create_stats_list(Eina_List *list, stc_iface_type_e iface)
 
        ret = stc_stats_rule_set_time_interval(rule, now - STC_TIME_PERIOD_MONTH, now);
        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));
+               SETTING_TRACE_ERROR("stc_stats_rule_set_time_interval() error: %s", 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));
+               SETTING_TRACE_ERROR("stc_stats_rule_set_iface_type() error: %s", get_error_message(ret));
                return;
        }
 
-       ret = stc_foreach_stats(ad.stc, rule, _stc_stats_info_cb, list);
+       ret = stc_foreach_stats(ad.stc, rule, _stc_stats_info_cb, (void *)iface);
        if (ret != STC_ERROR_NONE) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] stc_get_stats() error: %s", __FILE__, __LINE__, get_error_message(ret));
+               SETTING_TRACE_ERROR("stc_get_stats() error: %s", get_error_message(ret));
                return;
        }
 
@@ -114,23 +133,37 @@ static void _create_stats_list(Eina_List *list, stc_iface_type_e iface)
        SETTING_TRACE_END;
 }
 
+static Eina_Bool _timer_cb(void *data)
+{
+       SETTING_TRACE_BEGIN;
+
+       _dbg_app_list(ad.wifi_apps, "WIFI APPS");
+       _dbg_app_list(ad.sim_1_apps, "SIM APPS");
+
+       SETTING_TRACE_END;
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
 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__);
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("BUILD: %s %s", __DATE__, __TIME__);
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("==========================================================");
+       SETTING_TRACE("==========================================================");
 
        if (!ad)
                return false;
 
-       dlog_print(DLOG_INFO, LOG_TAG, "_create_app");
+       SETTING_TRACE("_create_app");
+
+
        bindtextdomain(SETTING_PACKAGE, SETTING_LOCALEDIR);
 
        ret = telephony_init(&ad->telephony_handles);
@@ -153,14 +186,14 @@ static bool _create_app(void *data)
 
        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));
+               SETTING_TRACE_ERROR("stc_initialize() error: %s", 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);
+       _create_stats_list(STC_IFACE_WIFI);
+       _create_stats_list(STC_IFACE_DATACALL);
 
-       dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] STC INITIALIZED", basename(__FILE__), __LINE__);
+       SETTING_TRACE("STC INITIALIZED");
 
        init_main_view(ad);
        setting_view_node_table_intialize();
@@ -168,6 +201,8 @@ static bool _create_app(void *data)
        setting_view_create(ad->main_view, ad);
        setting_view_node_set_cur_view(ad->main_view);
 
+       ecore_timer_add(3.0, _timer_cb, NULL);
+
        return true;
 }