summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandeep Singh <randeep.s@samsung.com>2020-09-27 12:10:58 +0000
committerGerrit Code Review <gerrit@review>2020-09-27 12:10:58 +0000
commit1a7511d1609eeb1b04adbbc2e817376e5c512ee7 (patch)
tree88740e4d0aa26a75d62721ea12e2e1acd738bfde
parent226df3de7521bc06debcbba80ce75ceb2c8d579d (diff)
parentd4fdb324e7fb07074c93ee998668417f3979cee7 (diff)
downloadbatterymonitor-1a7511d1609eeb1b04adbbc2e817376e5c512ee7.tar.gz
batterymonitor-1a7511d1609eeb1b04adbbc2e817376e5c512ee7.tar.bz2
batterymonitor-1a7511d1609eeb1b04adbbc2e817376e5c512ee7.zip
Merge "Return before if Hash is NULL" into tizen
-rw-r--r--src/battery_dump/bd_history_item.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/battery_dump/bd_history_item.c b/src/battery_dump/bd_history_item.c
index f3c7114..569b7eb 100644
--- a/src/battery_dump/bd_history_item.c
+++ b/src/battery_dump/bd_history_item.c
@@ -285,33 +285,34 @@ static int bd_get_and_print_battery_usage_from_dump(int fd, long int duration)
g_string_free(dump_p, TRUE);
- g_hash_table_iter_init(&iter, app_map);
- while (g_hash_table_iter_next(&iter, &key, &value)) {
- uid_n = (int *)key; appid = (char *)value;
- _DBG("%d %s", *uid_n, appid); usageMAh = 0;
- // Currently giving app usage of last one week;
- // Modify it wrt to time
- appid_usage_s *app_use = bm_server_query_app_usage_by_appid_ci(appid, duration, end_t, &ret);
- if (app_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) {
- _ERR("For appid %s", appid);
- continue;
+ if (app_map != NULL) {
+ g_hash_table_iter_init(&iter, app_map);
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ uid_n = (int *)key; appid = (char *)value;
+ _DBG("%d %s", *uid_n, appid); usageMAh = 0;
+ appid_usage_s *app_use = bm_server_query_app_usage_by_appid_ci(appid, duration, end_t, &ret);
+ if (app_use == NULL || ret != BATTERY_MONITOR_ERROR_NONE) {
+ _ERR("For appid %s", appid);
+ continue;
+ }
+ usageMAh = (app_use->rId_ble + app_use->rId_wifi + app_use->rId_cpu +
+ app_use->rId_display + app_use->rId_device_network +
+ app_use->rId_gps);
+ // usage stored as mAs changed to mAh
+ usageMAh = (usageMAh/3600);
+ dump_p = g_string_sized_new(30);
+ BM_CHECK_MEM_ALLOC(dump_p, { BM_FREE(app_use); });
+ g_string_append_printf(dump_p, "%s,%d,l,pwi,uid,%0.2f\n",
+ TIZEN_DUMP_VERSION, *uid_n, usageMAh);
+
+ bm_appid_usage_free(app_use);
+ _DBG("%s", dump_p->str);
+ if (write(fd, dump_p->str, dump_p->len) < 0)
+ _WARN("write error");
+ g_string_free(dump_p, TRUE);
}
- usageMAh = (app_use->rId_ble + app_use->rId_wifi + app_use->rId_cpu +
- app_use->rId_display + app_use->rId_device_network +
- app_use->rId_gps);
- // usage stored as mAs changed to mAh
- usageMAh = (usageMAh/3600);
- dump_p = g_string_sized_new(30);
- BM_CHECK_MEM_ALLOC(dump_p, { BM_FREE(app_use); });
- g_string_append_printf(dump_p, "%s,%d,l,pwi,uid,%0.2f\n",
- TIZEN_DUMP_VERSION, *uid_n, usageMAh);
-
- bm_appid_usage_free(app_use);
- _DBG("%s", dump_p->str);
- if (write(fd, dump_p->str, dump_p->len) < 0)
- _WARN("write error");
- g_string_free(dump_p, TRUE);
}
+
// Resource usage;
const char *rid_str = NULL;
for (int i = 0; i < 6; i++) {