From 1346855a3a9ce1bfb4ce731fb761e19e9f4c3837 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Thu, 2 Jul 2015 14:58:06 +0900 Subject: [PATCH] Code sync from tizen_2.4 Change-Id: Ie3acd482219a45bb751c2727cb11c5b0a2baa0c7 --- include/s_indi_log.h | 8 ++--- include/s_indi_util.h | 8 ++--- packaging/tel-plugin-indicator.spec | 2 +- src/s_indi_main.c | 62 +++++++++++++++++++++++++------------ 4 files changed, 51 insertions(+), 29 deletions(-) diff --git a/include/s_indi_log.h b/include/s_indi_log.h index 8fc92f4..6d47532 100644 --- a/include/s_indi_log.h +++ b/include/s_indi_log.h @@ -33,7 +33,7 @@ enum { #else #define s_indi_log_v(...) \ do { \ - } while (0); + } while (0) #endif #ifdef FEATURE_LOG_TX_RX_DATA @@ -41,11 +41,11 @@ enum { do { \ const char *tag = s_indi_get_log_tag_with_id(id); \ info_ex(tag, __VA_ARGS__); \ - } while (0); + } while (0) #else #define s_indi_log_txrx(id,...) \ do { \ - } while (0); + } while (0) #endif #define s_indi_log_ex(name,...) \ @@ -53,7 +53,7 @@ enum { gchar *tag = s_indi_get_log_tag_with_cp_name(name); \ dbg_ex(tag, __VA_ARGS__); \ g_free(tag); \ - } while (0); + } while (0) inline const char *s_indi_get_log_tag_with_id(unsigned int modem_id); inline char *s_indi_get_log_tag_with_cp_name(const char *cp_name); diff --git a/include/s_indi_util.h b/include/s_indi_util.h index 95805c8..b69b347 100644 --- a/include/s_indi_util.h +++ b/include/s_indi_util.h @@ -88,8 +88,8 @@ struct s_indi_cp_state_info_type_struct{ typedef struct { CoreObject *ps_context; s_indi_cp_state_info_type *parent; - unsigned long prev_rx; - unsigned long prev_tx; - unsigned long curr_rx; - unsigned long curr_tx; + unsigned long long prev_rx; + unsigned long long prev_tx; + unsigned long long curr_rx; + unsigned long long curr_tx; } s_indi_dev_state_info_type; diff --git a/packaging/tel-plugin-indicator.spec b/packaging/tel-plugin-indicator.spec index 93b7bf3..6977d77 100755 --- a/packaging/tel-plugin-indicator.spec +++ b/packaging/tel-plugin-indicator.spec @@ -1,6 +1,6 @@ %define major 0 %define minor 1 -%define patchlevel 66 +%define patchlevel 67 Name: tel-plugin-indicator Version: %{major}.%{minor}.%{patchlevel} diff --git a/src/s_indi_main.c b/src/s_indi_main.c index 7714637..472bcf0 100644 --- a/src/s_indi_main.c +++ b/src/s_indi_main.c @@ -257,7 +257,7 @@ gboolean __s_indi_update_callback(__s_indi_cb_user_data *data) FILE *pf = NULL; gchar *rv = NULL; unsigned long long rx_curr_total = S_INDI_ZERO, tx_curr_total = S_INDI_ZERO, rx_prev_total = S_INDI_ZERO, tx_prev_total = S_INDI_ZERO; - unsigned long rx_changes_total = S_INDI_ZERO, tx_changes_total = S_INDI_ZERO; + unsigned long long rx_changes_total = S_INDI_ZERO, tx_changes_total = S_INDI_ZERO; s_indi_transfer_state cp_state = S_INDI_TRANSFER_NORMAL; /* Assume no activity */ enum tcore_storage_key key_last_rcv, key_last_snt, key_total_rcv, key_total_snt, key_service_state; s_indi_private_info *priv_info = __s_indi_get_priv_info(indi_plugin); @@ -336,7 +336,7 @@ gboolean __s_indi_update_callback(__s_indi_cb_user_data *data) /* Takes care of the fix: Fix the PLM p131003-03182. Sha-ID: 65544f0be8e60ae3f964921755a1e83fa8e71441*/ if ((dev_state = g_hash_table_lookup(state_info->device_info, ifname)) != NULL) { gint result = S_INDI_ZERO; - unsigned long rx_pkt = S_INDI_ZERO, tx_pkt = S_INDI_ZERO; + unsigned long long rx_pkt = S_INDI_ZERO, tx_pkt = S_INDI_ZERO; /************************************************************************ Sample Input of S_INDI_PROC_FILE ************************************************************************ @@ -346,7 +346,7 @@ gboolean __s_indi_update_callback(__s_indi_cb_user_data *data) eth0: 2714004148 6475059 0 0 0 0 0 0 72595891 8726308 0 0 0 0 0 0 ************************************************************************/ s_indi_log_v("Reading stats of interface %s", ifname); - result = sscanf(entry, "%lu %*s %*s %*s %*s %*s %*s %*s %lu %*s %*s %*s %*s %*s %*s %*s", &rx_pkt, &tx_pkt); + result = sscanf(entry, "%llu %*s %*s %*s %*s %*s %*s %*s %llu %*s %*s %*s %*s %*s %*s %*s", &rx_pkt, &tx_pkt); if (result <= S_INDI_ZERO) { err("stats fail to get proc field => %d", result); goto EXIT; /** @todo: REMOVE or CONTINUE ? */ @@ -376,7 +376,8 @@ gboolean __s_indi_update_callback(__s_indi_cb_user_data *data) cp_state |= S_INDI_TRANSFER_TX; if (cp_state > 0) - s_indi_log_txrx(modem_id, "Transfer State: [%d] RX: [%10lu] TX: [%10lu]", cp_state, rx_changes_total, tx_changes_total); + s_indi_log_txrx(modem_id, "Transfer State:[%d] RX: [%llu / %llu] TX: [%llu / %llu]", + cp_state, rx_changes_total, rx_curr_total, tx_changes_total, tx_curr_total); if (state_info->dormant_info.lcd_state < S_INDI_LCD_OFF) { if (state_info->cp_trans_state != cp_state) { /* New Transfer State */ @@ -386,10 +387,11 @@ gboolean __s_indi_update_callback(__s_indi_cb_user_data *data) state_info->cp_trans_state = cp_state; tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_INDICATOR_STATE, cp_state); if (cp_state != S_INDI_TRANSFER_NORMAL) { /* Data activity */ - s_indi_log_txrx(modem_id, "pkt_state[%d] rx_changes [%lu] tx_changes [%lu]", - cp_state, rx_changes_total, tx_changes_total); - tcore_storage_set_int(strg_vconf, key_last_rcv, rx_curr_total/1000); - tcore_storage_set_int(strg_vconf, key_last_snt, tx_curr_total/1000); + /** @todo: VCONF needs upgrade to support llu */ + tcore_storage_set_int(strg_vconf, key_last_rcv, (int)(rx_curr_total/1000ULL)); + tcore_storage_set_int(strg_vconf, key_last_snt, (int)(tx_curr_total/1000ULL)); + + s_indi_log_txrx(modem_id, "VCONF LAST- RX: [%d] TX: [%d]", (int)(rx_curr_total/1000ULL), (int)(tx_curr_total/1000ULL)); } } } @@ -418,8 +420,12 @@ EXIT: tcore_storage_set_int(strg_vconf, key_total_rcv, tcore_storage_get_int(strg_vconf, key_total_rcv) + state_info->rx_total); tcore_storage_set_int(strg_vconf, key_total_snt, tcore_storage_get_int(strg_vconf, key_total_snt) + state_info->tx_total); + /* After updating total vconf key, last vconf key needs to be reset */ + tcore_storage_set_int(strg_vconf, key_last_rcv, 0); + tcore_storage_set_int(strg_vconf, key_last_snt, 0); + /** @todo: VCONF needs upgrade to support llu */ - s_indi_log_txrx(modem_id, "RX-TOTAL [%d] TX-TOTAL [%d]", + s_indi_log_txrx(modem_id, "VCONF TOTAL- RX: [%d] TX: [%d]", tcore_storage_get_int(strg_vconf, key_total_rcv), tcore_storage_get_int(strg_vconf, key_total_snt)); state_info->rx_total = S_INDI_ZERO; state_info->tx_total = S_INDI_ZERO; @@ -434,7 +440,8 @@ void __s_indi_state_info_value_destroy_notification(gpointer data) s_indi_cp_state_info_type *state_info = data; const char *cp_name = NULL; Storage *strg_vconf = NULL; - enum tcore_storage_key key_total_rcv, key_total_snt; + enum tcore_storage_key key_last_rcv, key_last_snt, key_total_rcv, key_total_snt; + unsigned int modem_id; s_indi_assert(NULL != state_info); s_indi_assert(NULL != state_info->co_ps); @@ -444,11 +451,17 @@ void __s_indi_state_info_value_destroy_notification(gpointer data) /* VCONF Mapper */ if (s_indi_str_has_suffix(cp_name, "0")) { + key_last_rcv = STORAGE_KEY_CELLULAR_PKT_LAST_RCV; + key_last_snt = STORAGE_KEY_CELLULAR_PKT_LAST_SNT; key_total_rcv = STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV; key_total_snt = STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT; + modem_id = MODEM_ID_PRIMARY; } else if (s_indi_str_has_suffix(cp_name, "1")) { + key_last_rcv = STORAGE_KEY_CELLULAR_PKT_LAST_RCV2; + key_last_snt = STORAGE_KEY_CELLULAR_PKT_LAST_SNT2; key_total_rcv = STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV2; key_total_snt = STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT2; + modem_id = MODEM_ID_SECONDARY; } else { err("Unhandled CP Name %s", cp_name); s_indi_assert_not_reached(); @@ -463,8 +476,13 @@ void __s_indi_state_info_value_destroy_notification(gpointer data) /* Update VCONF before dying */ tcore_storage_set_int(strg_vconf, key_total_rcv, tcore_storage_get_int(strg_vconf, key_total_rcv) + state_info->rx_total); tcore_storage_set_int(strg_vconf, key_total_snt, tcore_storage_get_int(strg_vconf, key_total_snt) + state_info->tx_total); - dbg("CP [%s] RX-TOTAL [%10llu] TX-TOTAL [%10llu]", cp_name, - tcore_storage_get_int(strg_vconf, key_total_rcv), tcore_storage_get_int(strg_vconf, key_total_snt)); + + /* After updating total vconf key, last vconf key needs to be reset */ + tcore_storage_set_int(strg_vconf, key_last_rcv, 0); + tcore_storage_set_int(strg_vconf, key_last_snt, 0); + + s_indi_log_txrx(modem_id, "VCONF TOTAL -RX: [%d] TX: [%d]", + tcore_storage_get_int(strg_vconf, key_total_rcv), tcore_storage_get_int(strg_vconf, key_total_snt)); OUT: s_indi_free(data); @@ -479,11 +497,11 @@ void __s_indi_dev_info_value_destroy_notification(gpointer data) s_indi_assert(NULL != state_info); /* Update parent before dying */ - state_info->rx_total += dev_state->curr_rx/1000; - state_info->tx_total += dev_state->curr_tx/1000; + state_info->rx_total += dev_state->curr_rx/1000ULL; + state_info->tx_total += dev_state->curr_tx/1000ULL; - s_indi_log_v("DYING after contributing [RX: %lu][TX: %lu] OUT OF [RX: %llu][TX: %llu]", - dev_state->curr_rx/1000, dev_state->curr_tx/1000, + dbg("DYING after contributing [RX: %llu][TX: %llu] OUT OF [RX: %llu][TX: %llu]", + dev_state->curr_rx/1000ULL, dev_state->curr_tx/1000ULL, state_info->rx_total, state_info->tx_total); s_indi_free(data); @@ -493,7 +511,7 @@ void __s_indi_refresh_modems(TcorePlugin *indi_plugin) { GSList *mp_list = tcore_server_get_modem_plugin_list(tcore_plugin_ref_server(indi_plugin)); GSList *tmp; - s_indi_log_v("Processing %u present modems", g_slist_length(mp_list)); + dbg("Processing %u present modems", g_slist_length(mp_list)); for (tmp = mp_list; tmp; tmp = tmp->next) __s_indi_add_modem_plugin(indi_plugin, tmp->data); @@ -593,8 +611,10 @@ enum tcore_hook_return s_indi_on_hook_ps_call_status(Server *server, CoreObject s_indi_log_ex(cp_name, "cid(%d) state(%d) reason(%d)", cstatus->context_id, cstatus->state, cstatus->result); - if (cstatus->state == S_INDI_PS_CALL_OK) + if (cstatus->state == S_INDI_PS_CALL_OK) { + s_indi_log_ex(cp_name, "PS Call state - [PS_CALL_OK]"); return TCORE_HOOK_RETURN_CONTINUE; + } if ((state_info = g_hash_table_lookup(priv_info->state_info, cp_name)) == NULL) { warn("BAILING OUT: [%s] not found", cp_name); @@ -614,6 +634,8 @@ enum tcore_hook_return s_indi_on_hook_ps_call_status(Server *server, CoreObject gboolean data_allowed = FALSE; gboolean roaming_allowed = FALSE; + s_indi_log_ex(cp_name, "PS Call state - [PS_CALL_CONNECT]"); + /* Fetch context with internet/tethering role */ l_context = tcore_ps_ref_context_by_id(source, cstatus->context_id); while (l_context) { @@ -678,8 +700,6 @@ enum tcore_hook_return s_indi_on_hook_ps_call_status(Server *server, CoreObject tcore_storage_set_int(strg_vconf, STORAGE_KEY_PACKET_INDICATOR_STATE, S_INDI_TRANSFER_NORMAL); state_info->cp_trans_state = S_INDI_TRANSFER_NORMAL; - s_indi_log_ex(cp_name, "PS Call status - [CONNECTED]"); - /* Create new dev state */ dev_state = __s_indi_alloc_device_state(co_context, state_info); g_hash_table_insert(state_info->device_info, dev_name, dev_state); @@ -691,6 +711,8 @@ enum tcore_hook_return s_indi_on_hook_ps_call_status(Server *server, CoreObject gchar *dev_name = NULL; GSList *l_context = tcore_ps_ref_context_by_id(source, cstatus->context_id); + s_indi_log_ex(cp_name, "PS Call state - [PS_CALL_NO_CARRIER]"); + /* Remove all related contexts */ while (l_context) { dev_name = tcore_context_get_ipv4_devname(l_context->data); -- 2.7.4