aboot: add support for charger screen enable/disable
fastboot can now be used to enable/disable the charger screen dynamically.
CRs-fixed: 511751
Change-Id: I15a4481680bf6ad8275b16c808c8688ac0bb0775
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 50e1425..7e177db 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -121,7 +121,7 @@
/* Assuming unauthorized kernel image by default */
static int auth_kernel_img = 0;
-static device_info device = {DEVICE_MAGIC, 0, 0};
+static device_info device = {DEVICE_MAGIC, 0, 0, 0};
struct atag_ptbl_entry
{
@@ -155,6 +155,7 @@
};
char max_download_size[MAX_RSP_SIZE];
+char charger_screen_enabled[MAX_RSP_SIZE];
char sn_buf[13];
extern int emmc_recovery_init(void);
@@ -213,7 +214,8 @@
cmdline_len += strlen(ffbm_mode_string);
/* reduce kernel console messages to speed-up boot */
cmdline_len += strlen(loglevel);
- } else if (target_pause_for_battery_charge()) {
+ } else if (device.charger_screen_enabled &&
+ target_pause_for_battery_charge()) {
pause_at_bootup = 1;
cmdline_len += strlen(battchg_pause);
}
@@ -1194,6 +1196,7 @@
memcpy(info->magic, DEVICE_MAGIC, DEVICE_MAGIC_SIZE);
info->is_unlocked = 0;
info->is_tampered = 0;
+ info->charger_screen_enabled = 0;
write_device_info_mmc(info);
}
@@ -1836,6 +1839,22 @@
reboot_device(FASTBOOT_MODE);
}
+void cmd_oem_enable_charger_screen(const char *arg, void *data, unsigned size)
+{
+ dprintf(INFO, "Enabling charger screen check\n");
+ device.charger_screen_enabled = 1;
+ write_device_info(&device);
+ fastboot_okay("");
+}
+
+void cmd_oem_disable_charger_screen(const char *arg, void *data, unsigned size)
+{
+ dprintf(INFO, "Disabling charger screen check\n");
+ device.charger_screen_enabled = 0;
+ write_device_info(&device);
+ fastboot_okay("");
+}
+
void cmd_oem_unlock(const char *arg, void *data, unsigned sz)
{
if(!device.is_unlocked)
@@ -1849,9 +1868,11 @@
void cmd_oem_devinfo(const char *arg, void *data, unsigned sz)
{
char response[64];
- snprintf(response, 64, "\tDevice tampered: %s", (device.is_tampered ? "true" : "false"));
+ snprintf(response, sizeof(response), "\tDevice tampered: %s", (device.is_tampered ? "true" : "false"));
fastboot_info(response);
- snprintf(response, 64, "\tDevice unlocked: %s", (device.is_unlocked ? "true" : "false"));
+ snprintf(response, sizeof(response), "\tDevice unlocked: %s", (device.is_unlocked ? "true" : "false"));
+ fastboot_info(response);
+ snprintf(response, sizeof(response), "\tCharger screen enabled: %s", (device.charger_screen_enabled ? "true" : "false"));
fastboot_info(response);
fastboot_okay("");
}
@@ -1971,7 +1992,10 @@
fastboot_register("oem unlock", cmd_oem_unlock);
fastboot_register("oem device-info", cmd_oem_devinfo);
fastboot_register("preflash", cmd_preflash);
-
+ fastboot_register("oem enable-charger-screen",
+ cmd_oem_enable_charger_screen);
+ fastboot_register("oem disable-charger-screen",
+ cmd_oem_disable_charger_screen);
/* publish variables and their values */
fastboot_publish("product", TARGET(BOARD));
fastboot_publish("kernel", "lk");
@@ -1987,8 +2011,14 @@
publish_getvar_partition_info(part_info, ARRAY_SIZE(part_info));
/* Max download size supported */
- snprintf(max_download_size, MAX_RSP_SIZE, "\t0x%x", target_get_max_flash_size());
+ snprintf(max_download_size, MAX_RSP_SIZE, "\t0x%x",
+ target_get_max_flash_size());
fastboot_publish("max-download-size", (const char *) max_download_size);
+ /* Is the charger screen check enabled */
+ snprintf(charger_screen_enabled, MAX_RSP_SIZE, "%d",
+ device.charger_screen_enabled);
+ fastboot_publish("charger-screen-enabled",
+ (const char *) charger_screen_enabled);
}
void aboot_init(const struct app_descriptor *app)
@@ -2010,11 +2040,7 @@
ASSERT((MEMBASE + MEMSIZE) > MEMBASE);
- if(target_use_signed_kernel())
- {
- read_device_info(&device);
-
- }
+ read_device_info(&device);
target_serialno((unsigned char *) sn_buf);
dprintf(SPEW,"serial number: %s\n",sn_buf);