[ADDING]Battery Dump: UID support 03/220903/2
authorDewal Agarwal <d1.agarwal@samsung.com>
Tue, 24 Dec 2019 10:24:35 +0000 (15:54 +0530)
committerKichan Kwon <k_c.kwon@samsung.com>
Thu, 26 Dec 2019 01:03:57 +0000 (10:03 +0900)
Change-Id: Id904cde9d6f79adb8525411988a7422daa816f1d
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
src/battery_dump/bd_history_item.c

index 1077a79..e44f356 100644 (file)
@@ -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;
 }