static bool sim_restrictions_checked = false;
bool tmp = false;
+ if (!sim_stats_checked) {
+ tmp = get_sim_apps_list(ad.stc, _stc_stats_info_cb);
+ if (tmp)
+ sim_stats_checked = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
if (!wifi_stats_checked) {
- ad.wifi_limits.total_data_used = 0;
tmp = get_wifi_apps_list(ad.stc, _stc_stats_info_cb);
if (tmp)
wifi_stats_checked = true;
return ECORE_CALLBACK_RENEW;
}
- if (!sim_stats_checked) {
+ if (!sim_total_stats_checked) {
ad.sim_1_limits.total_data_used = 0;
ad.sim_2_limits.total_data_used = 0;
- tmp = get_sim_apps_list(ad.stc, _stc_stats_info_cb);
+ tmp = get_sim_total_stats(ad.stc, _total_stats_cb);
if (tmp)
- sim_stats_checked = true;
+ sim_total_stats_checked = true;
return ECORE_CALLBACK_RENEW;
}
if (!wifi_total_stats_checked) {
+ ad.wifi_limits.total_data_used = 0;
tmp = get_wifi_total_stats(ad.stc, _total_stats_cb);
if (tmp)
wifi_total_stats_checked = true;
return ECORE_CALLBACK_RENEW;
}
- if (!sim_total_stats_checked) {
- tmp = get_sim_total_stats(ad.stc, _total_stats_cb);
+ 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;
+ tmp = get_sim_restrictions(ad.stc, _get_restrictions_cb);
if (tmp)
- sim_total_stats_checked = true;
+ sim_restrictions_checked = true;
return ECORE_CALLBACK_RENEW;
}
if (!wifi_restrictions_checked) {
+ ad.wifi_limits.limit = 0;
+ ad.wifi_limits.warning = 0;
tmp = get_wifi_restrictions(ad.stc, _get_restrictions_cb);
if (tmp)
wifi_restrictions_checked = true;
return ECORE_CALLBACK_RENEW;
}
- if (!sim_restrictions_checked) {
- tmp = get_sim_restrictions(ad.stc, _get_restrictions_cb);
- if (tmp)
- sim_restrictions_checked = true;
- return ECORE_CALLBACK_RENEW;
- }
-
return ECORE_CALLBACK_CANCEL;
}
TELEPHONY_NOTI_SIM_STATUS, _sim_state_change_cb, ad);
SETTING_TRACE_DEBUG("telephony_set_noti_cb[0] %s",
get_error_message(ret));
+ if (get_imsi_from_telephony_handle(
+ ad->telephony_handles.handle[0],
+ ad->imsi_1, sizeof(ad->imsi_1))
+ )
+ SETTING_TRACE_DEBUG("IMSI_1 %s", ad->imsi_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_imsi_from_telephony_handle(
+ ad->telephony_handles.handle[1],
+ ad->imsi_1, sizeof(ad->imsi_1))
+ )
+ SETTING_TRACE_DEBUG("IMSI_2 %s", ad->imsi_2);
}
_count_available_sim_cards(ad);
}
return;
_count_available_sim_cards(ad);
+
+ if (get_imsi_from_telephony_handle(
+ ad->telephony_handles.handle[0],
+ ad->imsi_1, sizeof(ad->imsi_1))
+ )
+ SETTING_TRACE_DEBUG("IMSI_1 %s", ad->imsi_1);
+
+ if (ad->num_sim_cards_available)
+ if (get_imsi_from_telephony_handle(
+ ad->telephony_handles.handle[1],
+ ad->imsi_1, sizeof(ad->imsi_1))
+ )
+ SETTING_TRACE_DEBUG("IMSI_2 %s", ad->imsi_2);
+
ad->main_view_update_type = MV_UPDATE_SIM_STATE_CHANGED;
if (setting_view_node_get_cur_view() == ad->main_view) {
SETTING_TRACE_DEBUG("_sim_state_change_cb: updating main view");
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;
+ char *imsi = NULL;
int64_t incoming = 0;
int64_t outgoing = 0;
stc_iface_type_e iface = STC_IFACE_UNKNOWN;
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);
}
- } else if (iface == STC_IFACE_DATACALL) {
- 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 (iface == STC_IFACE_DATACALL) {
+
+ ret = stc_stats_info_get_imsi(info, &imsi);
+ if (STC_ERROR_NONE == ret) {
+
+ SETTING_TRACE_DEBUG("Obtained IMSI: %s", imsi);
+ /* TODO: uncomment when api stc works: */
+ /*if (compare_imsis(ad.imsi_1, imsi))*/
+ 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_imsis(ad.imsi_2, imsi))
+ 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_imsi() error: %s",
+ get_error_message(ret));
}
- } else {
- SETTING_TRACE_ERROR("Unknown interface: %d", iface);
+ free(imsi);
}
- SETTING_TRACE_END;
return STC_CALLBACK_CONTINUE;
}
{
int64_t incoming = 0;
int64_t outgoing = 0;
+ char *imsi = NULL;
int ret = STC_ERROR_NONE;
stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
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) {
- ad.main_view_update_type = MV_UPDATE_SIM_1_TOTAL_DATA_USAGE;
- ad.sim_1_limits.total_data_used = incoming + outgoing;
- SETTING_TRACE("SIM total in: %lld out: %lld", incoming, outgoing);
+ ret = stc_stats_info_get_imsi(info, &imsi);
+ if (STC_ERROR_NONE == ret) {
+
+ SETTING_TRACE_DEBUG("Obtained IMSI: %s", imsi);
+ /* TODO: uncomment when api stc works: */
+ /*if (compare_imsis(ad.imsi_1, imsi)) {*/
+ 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_imsis(ad.imsi_2, imsi)) {
+ 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_imsi() error: %s",
+ get_error_message(ret));
+ }
+ free(imsi);
}
if (iface_type == STC_IFACE_WIFI) {
ad.main_view_update_type = MV_UPDATE_WIFI_TOTAL_DATA_USAGE;
{
int ret = STC_ERROR_NONE;
char *app_id = NULL;
+ char *imsi = NULL;
stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
stc_restriction_status_e status = STC_RESTRICTION_UNKNOWN;
}
*/
(void)stc_restriction_info_get_iface_type(info, &iface_type);
-
+ SETTING_TRACE_DEBUG("Obtained iface: %d", iface_type);
if (iface_type == STC_IFACE_DATACALL) {
- (void)stc_restriction_info_get_limit(info,
- &(ad.sim_1_limits.limit));
- (void)stc_restriction_info_get_warning_limit(info,
- &(ad.sim_1_limits.warning));
- ad.main_view_update_type = MV_UPDATE_SIM_1_WARN_N_LIMIT;
- setting_view_update(ad.main_view, &ad);
+
+ ret = stc_restriction_info_get_imsi(info, &imsi);
+ if (STC_ERROR_NONE == ret) {
+ SETTING_TRACE_DEBUG("Obtained IMSI: %s", imsi);
+ /* TODO: uncomment when api stc works: */
+ /*if (compare_imsis(ad.imsi_1, imsi)) {*/
+ (void)stc_restriction_info_get_limit(info,
+ &(ad.sim_1_limits.limit));
+ (void)stc_restriction_info_get_warning_limit(info,
+ &(ad.sim_1_limits.warning));
+ ad.main_view_update_type = MV_UPDATE_SIM_1_WARN_N_LIMIT;
+ /*}
+ if (compare_imsis(ad.imsi_2, imsi)) {
+ (void)stc_restriction_info_get_limit(info,
+ &(ad.sim_2_limits.limit));
+ (void)stc_restriction_info_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_info_get_imsi() error: %s",
+ get_error_message(ret));
+ }
+ free(imsi);
}
if (iface_type == STC_IFACE_WIFI) {
#include "smartmanager-utils.h"
+#include "setting-common-general-func.h"
#include "setting-debug.h"
#include <stdio.h>
+#include <stdlib.h>
static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
stc_stats_info_cb stats_cb);
void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out, int len_max)
{
- SETTING_TRACE_BEGIN;
-
float amount = 0.0;
if (num_bytes < 1024) {
} else {
snprintf(txt_out, len_max, "%s%0.2fKB", prefix, amount);
}
-
- SETTING_TRACE_END;
}
bool get_sim_total_stats(stc_h stc, stc_stats_info_cb stats_cb)
return true;
}
- SETTING_TRACE_DEBUG("Obtaining per app data usage for ifce: %d", iface);
+ SETTING_TRACE_DEBUG("\033[1;33mObtaining per app data usage for ifce: %d", iface);
ret = stc_foreach_stats(stc, rule, stats_cb, NULL);
if (ret != STC_ERROR_NONE) {
SETTING_TRACE_ERROR("stc_get_stats() error: %s",
return true;
}
- SETTING_TRACE_DEBUG("Obtaining total stats for ifce: %d", iface_type);
+ SETTING_TRACE_DEBUG("\033[1;34mObtaining total stats for ifce: %d", iface_type);
ret = stc_get_total_stats(stc, rule, stats_cb, NULL);
if (ret != STC_ERROR_NONE) {
SETTING_TRACE_ERROR("stc_get_total_stats() error: %s",
return true;
}
- SETTING_TRACE_DEBUG("Obtaining restrictions for ifce: %d", iface_type);
+ SETTING_TRACE_DEBUG("\033[1;35mObtaining restrictions for ifce: %d", iface_type);
ret = stc_foreach_restriction(stc, rule, restrictions_cb, NULL);
if (STC_ERROR_NONE != ret) {
SETTING_TRACE_ERROR("SIM stc_foreach_restriction() error: %s",
return true;
}
+bool get_imsi_from_telephony_handle(telephony_h handle,
+ char out_buff[], int len_max)
+{
+ char *mcc_mnc = NULL;
+ char *msin = NULL;
+
+ if (!handle || len_max <= 0 || !out_buff)
+ return false;
+
+ if (telephony_sim_get_operator(handle, &mcc_mnc) < 0) {
+ SETTING_TRACE_ERROR("telephony_sim_get_operator(%p) error", handle);
+ return false;
+ }
+
+ if (telephony_sim_get_msin(handle, &msin) < 0) {
+ SETTING_TRACE_ERROR("telephony_sim_get_msin(%p) error", handle);
+ free(mcc_mnc);
+ return false;
+ }
+
+ snprintf(out_buff, len_max, "%s%s", mcc_mnc, msin);
+
+ free(mcc_mnc);
+ free(msin);
+ return true;
+}
+
+bool compare_imsis(const char *imsi_a, const char *imsi_b)
+{
+ return (0 == safeStrNCmp(imsi_a, imsi_b, 15));
+}