RESTRICTIONS_OTHER_ERROR = 3
} restrictions_result;
-void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out, int len_max);
+void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out,
+ int len_max);
+
+/**
+ * @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_total_stats(stc_h stc, stc_stats_info_cb stats_cb);
-bool get_wifi_total_stats(stc_h stc, stc_stats_info_cb stats_cb);
-bool get_sim_apps_list(stc_h stc, stc_stats_info_cb stats_cb);
-bool get_wifi_apps_list(stc_h stc, stc_stats_info_cb stats_cb);
bool get_sim_restrictions(stc_h stc, stc_restriction_info_cb restrictions_cb);
bool get_wifi_restrictions(stc_h stc, stc_restriction_info_cb restrictions_cb);
bool get_subscriber_id_from_telephony_handle(telephony_h handle,
static SmartMgrData ad = {0,};
static bool wifi_stats_checked = false;
-static bool sim_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_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 Eina_Bool _delayed_timer_cb(void *data)
{
data_usage_app_item_t *item = NULL;
- bool tmp = false;
if (!all_stat_cycles_checked) {
_read_all_stat_cycles();
all_stat_cycles_checked = true;
}
- if (!sim_total_stats_checked) {
+ if (!sim_1_total_stats_checked) {
ad.sim_1_limits.total_data_used = 0;
- ad.sim_2_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;
+ }
- tmp = get_sim_total_stats(ad.stc, _total_stats_cb);
- if (tmp)
- sim_total_stats_checked = true;
+ 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;
- tmp = get_wifi_total_stats(ad.stc, _total_stats_cb);
- if (tmp)
- wifi_total_stats_checked = true;
+ 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_stats_checked) {
+ if (!sim_1_stats_checked) {
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);
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);
-
- tmp = get_sim_apps_list(ad.stc, _stc_stats_info_cb);
- if (tmp)
- sim_stats_checked = true;
+ 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;
}
EINA_LIST_FREE(ad.wifi_apps, item)
_delete_stat_item(item);
- tmp = get_wifi_apps_list(ad.stc, _stc_stats_info_cb);
- if (tmp)
- wifi_stats_checked = true;
+ 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;
}
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_restrictions_checked = true;
+ 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;
- tmp = get_wifi_restrictions(ad.stc, _get_restrictions_cb);
- if (tmp)
- wifi_restrictions_checked = true;
+ wifi_restrictions_checked = get_wifi_restrictions(ad.stc,
+ _get_restrictions_cb);
return ECORE_CALLBACK_RENEW;
}
return;
wifi_stats_checked = false;
- sim_stats_checked = false;
+ sim_1_stats_checked = false;
+ sim_2_stats_checked = false;
wifi_total_stats_checked = false;
- sim_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;
/*sim_stats_checked = false; TODO: figure out way to update without
* blinking*/
- sim_total_stats_checked = false;
+ sim_1_total_stats_checked = false;
periodic_update_timer = ecore_timer_add(0.2, _delayed_timer_cb, NULL);
if (!periodic_update_timer)
{
char *app_id = NULL;
char *subscriber_id = NULL;
+ const char *subscriber_id_to_look_for = user_data;
int64_t incoming = 0;
int64_t outgoing = 0;
stc_iface_type_e iface = STC_IFACE_UNKNOWN;
- SETTING_TRACE_DEBUG("per app cb");
+ 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));
}
if (iface == STC_IFACE_DATACALL) {
ret = stc_stats_info_get_subscriber_id(info, &subscriber_id);
- if (STC_ERROR_NONE == ret) {
+ 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)) {
setting_view_update(ad.main_view, &ad);
}
} else {
- SETTING_TRACE_ERROR("stc_stats_info_get_subscriber_id() error: %s",
- get_error_message(ret));
+ 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);
}
int64_t incoming = 0;
int64_t 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");
+ 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));
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) {
+
+ if (STC_ERROR_NONE == ret &&
+ compare_subscriber_ids(subscriber_id,
+ subscriber_id_to_look_for)
+ ) {
SETTING_TRACE_DEBUG("Obtained SUBSCRIBER ID: %s",
subscriber_id);
#include <app_preference.h>
static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
- stc_stats_info_cb stats_cb);
+ stc_stats_info_cb stats_cb,
+ void *cb_data, time_t t_from,
+ time_t t_to);
static bool _get_total_stats(stc_h stc, stc_iface_type_e iface_type,
- stc_stats_info_cb stats_cb);
+ stc_stats_info_cb stats_cb, void *cb_data,
+ time_t t_from, time_t t_to);
static bool _get_restrictions(stc_h stc, stc_iface_type_e iface_type,
stc_restriction_info_cb restrictions_cb,
void *restriction_info_cb_data);
}
}
-bool get_sim_total_stats(stc_h stc, stc_stats_info_cb stats_cb)
+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)
{
- return _get_total_stats(stc, STC_IFACE_DATACALL, stats_cb);
+ return _get_total_stats(stc, STC_IFACE_DATACALL, stats_cb,
+ (void *)subscriber_id, t_from, t_to);
}
-bool get_wifi_total_stats(stc_h stc, stc_stats_info_cb stats_cb)
+bool get_wifi_total_stats(stc_h stc, stc_stats_info_cb stats_cb, time_t t_from,
+ time_t t_to)
{
- return _get_total_stats(stc, STC_IFACE_WIFI, stats_cb);
+ return _get_total_stats(stc, STC_IFACE_WIFI, stats_cb, NULL, t_from, t_to);
}
-bool get_sim_apps_list(stc_h stc, stc_stats_info_cb stats_cb)
+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)
{
- return _create_stats_list(stc, STC_IFACE_DATACALL, stats_cb);
+ return _create_stats_list(stc, STC_IFACE_DATACALL, stats_cb,
+ (void *)subscriber_id, t_from, t_to);
}
-bool get_wifi_apps_list(stc_h stc, stc_stats_info_cb stats_cb)
+bool get_wifi_apps_list(stc_h stc, stc_stats_info_cb stats_cb, time_t t_from,
+ time_t t_to)
{
- return _create_stats_list(stc, STC_IFACE_WIFI, stats_cb);
+ return _create_stats_list(stc, STC_IFACE_WIFI, stats_cb,
+ NULL, t_from, t_to);
}
bool get_sim_restrictions(stc_h stc, stc_restriction_info_cb restrictions_cb)
}
static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
- stc_stats_info_cb stats_cb)
+ stc_stats_info_cb stats_cb,
+ void *cb_data, time_t t_from,
+ time_t t_to)
{
stc_stats_rule_h rule = NULL;
return true;
}
- time_t now = time(NULL);
-
- ret = stc_stats_rule_set_time_interval(rule,
- now - STC_TIME_PERIOD_MONTH, now);
+ ret = stc_stats_rule_set_time_interval(rule, t_from, t_to);
if (ret != STC_ERROR_NONE) {
SETTING_TRACE_ERROR("stc_stats_rule_set_time_interval() error: %s",
get_error_message(ret));
}
SETTING_TRACE_DEBUG("\033[1;33mObtaining per app data usage for ifce: %d", iface);
- ret = stc_foreach_stats(stc, rule, stats_cb, NULL);
+ ret = stc_foreach_stats(stc, rule, stats_cb, cb_data);
if (ret != STC_ERROR_NONE) {
SETTING_TRACE_ERROR("stc_get_stats() error: %s",
get_error_message(ret));
}
static bool _get_total_stats(stc_h stc, stc_iface_type_e iface_type,
- stc_stats_info_cb stats_cb)
+ stc_stats_info_cb stats_cb, void *cb_data,
+ time_t t_from, time_t t_to)
{
stc_stats_rule_h rule = NULL;
- time_t now = time(NULL);
int ret = STC_ERROR_NONE;
ret = stc_stats_rule_create(stc, &rule);
return true;
}
- ret = stc_stats_rule_set_time_interval(rule,
- now - STC_TIME_PERIOD_MONTH, now);
+ ret = stc_stats_rule_set_time_interval(rule, t_from, t_to);
if (ret != STC_ERROR_NONE) {
SETTING_TRACE_ERROR("stc_stats_rule_set_time_interval() error: %s",
get_error_message(ret));
}
SETTING_TRACE_DEBUG("\033[1;34mObtaining total stats for ifce: %d", iface_type);
- ret = stc_get_total_stats(stc, rule, stats_cb, NULL);
+ ret = stc_get_total_stats(stc, rule, stats_cb, cb_data);
if (ret != STC_ERROR_NONE) {
SETTING_TRACE_ERROR("stc_get_total_stats() error: %s",
get_error_message(ret));