app: aboot: update battery voltage value timely for getvar command
The buf which store the battery voltage is not a latest value. So
update the value before read it.
Change-Id: If2f233786d4ddcafeeba144c3d75c80c9d9f76bd
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 44b0858..98006bd 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -253,7 +253,12 @@
char sn_buf[13];
char display_panel_buf[MAX_PANEL_BUF_SIZE];
char panel_display_mode[MAX_RSP_SIZE];
+
+#if CHECK_BAT_VOLTAGE
char battery_voltage[MAX_RSP_SIZE];
+char battery_soc_ok [MAX_RSP_SIZE];
+#endif
+
char get_variant[MAX_RSP_SIZE];
extern int emmc_recovery_init(void);
@@ -288,6 +293,14 @@
*ptr += sizeof(struct atag_ptbl_entry) / sizeof(unsigned);
}
+#if CHECK_BAT_VOLTAGE
+void update_battery_status(void)
+{
+ snprintf(battery_voltage,MAX_RSP_SIZE, "%d",target_get_battery_voltage());
+ snprintf(battery_soc_ok ,MAX_RSP_SIZE, "%s",target_battery_soc_ok()? "yes":"no");
+}
+#endif
+
unsigned char *update_cmdline(const char * cmdline)
{
int cmdline_len = 0;
@@ -3511,10 +3524,9 @@
target_is_emmc_boot()? "eMMC":"UFS");
fastboot_publish("variant", (const char *) get_variant);
#if CHECK_BAT_VOLTAGE
- snprintf(battery_voltage, MAX_RSP_SIZE, "%d",
- target_get_battery_voltage());
+ update_battery_status();
fastboot_publish("battery-voltage", (const char *) battery_voltage);
- fastboot_publish("battery-soc-ok", target_battery_soc_ok()? "yes":"no");
+ fastboot_publish("battery-soc-ok", (const char *) battery_soc_ok);
#endif
}
diff --git a/app/aboot/fastboot.c b/app/aboot/fastboot.c
index 545a24d..f99ed03 100644
--- a/app/aboot/fastboot.c
+++ b/app/aboot/fastboot.c
@@ -448,6 +448,10 @@
{
struct fastboot_var *var;
+#if CHECK_BAT_VOLTAGE
+ update_battery_status();
+#endif
+
if (!strncmp("all", arg, strlen(arg)))
{
getvar_all();
diff --git a/include/target.h b/include/target.h
index 6f83b6f..1778dd2 100644
--- a/include/target.h
+++ b/include/target.h
@@ -92,6 +92,10 @@
uint32_t get_vibration_type();
#endif
+#if CHECK_BAT_VOLTAGE
+void update_battery_status(void);
+#endif
+
uint32_t target_get_battery_voltage();
bool target_battery_soc_ok();
bool target_battery_is_present();