From: Dewal Agarwal Date: Tue, 24 Dec 2019 10:24:35 +0000 (+0530) Subject: [ADDING]Battery Dump: UID support X-Git-Tag: accepted/tizen/unified/20200120.133125~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e017d569a2109801d82b86d30e8618c401eb9fd;p=platform%2Fcore%2Fsystem%2Fbatterymonitor.git [ADDING]Battery Dump: UID support Change-Id: Id904cde9d6f79adb8525411988a7422daa816f1d Signed-off-by: Dewal Agarwal --- diff --git a/src/battery_dump/bd_history_item.c b/src/battery_dump/bd_history_item.c index 1077a79..e44f356 100644 --- a/src/battery_dump/bd_history_item.c +++ b/src/battery_dump/bd_history_item.c @@ -106,6 +106,66 @@ static int bd_get_pool_entry_from_dump(void) return BATTERY_MONITOR_ERROR_NONE; } +static int bd_print_uid_entry(int idx, history_tag_s *pool_info) +{ + ENTER; + + GString *dump_p = g_string_sized_new(30); + g_string_append_printf(dump_p, "%d,", pool_info->uid); + if (pool_info->string_info != NULL) { + gchar *temp = g_strdup(pool_info->string_info->str); + dump_p = g_string_append(dump_p, temp); + g_free(temp); + } + dump_p = g_string_append(dump_p, "\n"); + _DBG("%s", dump_p->str);//write + g_free(dump_p->str); + + EXIT; + return BATTERY_MONITOR_ERROR_NONE; +} +static int bd_get_uid_entry_from_dump(void) +{ + ENTER; + + // should be maintained at listeners for uniqueness + // move there and modify + GString *dump_p = g_string_sized_new(30); + dump_p = g_string_append(dump_p, TIZEN_DUMP_VERSION); + dump_p = g_string_append(dump_p, ",0"); + dump_p = g_string_append(dump_p, ",i"); + dump_p = g_string_append(dump_p, ",uid,"); + int ret = BATTERY_MONITOR_ERROR_NONE; + int log_count = h_count; + for (int i = 0; i < log_count; i++) { + history_tag_s *pool_info = NULL; + if (history_data[i].event_tag != NULL) { + pool_info = history_data[i].event_tag; + _DBG("%s", dump_p->str);//write + ret = bd_print_uid_entry(i, pool_info); + if (ret != BATTERY_MONITOR_ERROR_NONE) + return BATTERY_MONITOR_ERROR_INTERNAL; + } + if (history_data[i].wakelock_tag != NULL) { + pool_info = history_data[i].wakelock_tag; + _DBG("%s", dump_p->str);//write + ret = bd_print_uid_entry(i, pool_info); + if (ret != BATTERY_MONITOR_ERROR_NONE) + return BATTERY_MONITOR_ERROR_INTERNAL; + } + if (history_data[i].wakereason_tag != NULL) { + pool_info = history_data[i].wakereason_tag; + _DBG("%s", dump_p->str);//write + ret = bd_print_uid_entry(i, pool_info); + if (ret != BATTERY_MONITOR_ERROR_NONE) + return BATTERY_MONITOR_ERROR_INTERNAL; + } + } + g_free(dump_p->str); + + EXIT; + return BATTERY_MONITOR_ERROR_NONE; +} // The index passed in the fn should be preferrably continuous, // Other things should be implemented at dumping function. static int bd_get_history_detail_from_dump(int index, history_item_s* dump_node) @@ -493,6 +553,12 @@ int bd_print_history_item_main(int num_h_items, long base_time, bool chkin) // fputs(dump_p->str, fp);//TEMP g_free(dump_p->str); } + + //Dump i & l values after this + ret = bd_get_uid_entry_from_dump(); + if (ret != BATTERY_MONITOR_ERROR_NONE) + _ERR("UID data dump failed"); + h_flag = true; // fclose(fp);//TEMP EXIT; @@ -585,6 +651,16 @@ int bd_store_history_item(history_item_s* nrec) } /* +int bd_set_old_state_to_history_item(history_item_s* nrec) +{ + ENTER; + //Move this with listeners + EXIT; + return BATTERY_MONITOR_ERROR_NONE; +} +*/ + +/* //: remove this static int bd_test_fn() { @@ -656,7 +732,7 @@ int bd_initialize_battery_dump() h_count = 0; h_flag = true; _INFO("Battery Dump Init Successful"); //Remove -// bd_make_string_maps(); + //bd_make_string_maps(); EXIT; return BATTERY_MONITOR_ERROR_NONE; }