GUI: Add countdown & cancel to install auto-reboot
Provide a countdown from 5 sec for the automated reboot after install. Include a cancel button to interrupt the process. Change-Id: Ib5e1447918adfde45eba361c088800812b690890
This commit is contained in:
@@ -716,6 +716,8 @@ void DataManager::SetDefaultValues()
|
||||
#endif
|
||||
mData.SetValue("tw_gui_done", "0");
|
||||
mData.SetValue("tw_encrypt_backup", "0");
|
||||
mData.SetValue("tw_sleep_total", "5");
|
||||
mData.SetValue("tw_sleep", "5");
|
||||
|
||||
// Brightness handling
|
||||
string findbright;
|
||||
|
||||
+18
-6
@@ -180,6 +180,7 @@ GUIAction::GUIAction(xml_node<>* node)
|
||||
ADD_ACTION(cancelzip);
|
||||
ADD_ACTION(queueclear);
|
||||
ADD_ACTION(sleep);
|
||||
ADD_ACTION(sleepcounter);
|
||||
ADD_ACTION(appenddatetobackupname);
|
||||
ADD_ACTION(generatebackupname);
|
||||
ADD_ACTION(checkpartitionlist);
|
||||
@@ -779,6 +780,23 @@ int GUIAction::sleep(std::string arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GUIAction::sleepcounter(std::string arg)
|
||||
{
|
||||
operation_start("SleepCounter");
|
||||
// Ensure user notices countdown in case it needs to be cancelled
|
||||
blankTimer.resetTimerAndUnblank();
|
||||
int total = atoi(arg.c_str());
|
||||
for (int t = total; t > 0; t--) {
|
||||
int progress = (int)(((float)(total-t)/(float)total)*100.0);
|
||||
DataManager::SetValue("ui_progress", progress);
|
||||
::sleep(1);
|
||||
DataManager::SetValue("tw_sleep", t-1);
|
||||
}
|
||||
DataManager::SetValue("ui_progress", 100);
|
||||
operation_end(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GUIAction::appenddatetobackupname(std::string arg __unused)
|
||||
{
|
||||
operation_start("AppendDateToBackupName");
|
||||
@@ -1024,12 +1042,6 @@ int GUIAction::flash(std::string arg)
|
||||
|
||||
reinject_after_flash();
|
||||
PartitionManager.Update_System_Details();
|
||||
if (DataManager::GetIntValue("tw_install_reboot") > 0 && ret_val == 0) {
|
||||
gui_msg("install_reboot=Rebooting in 5 seconds");
|
||||
usleep(5000000);
|
||||
TWFunc::tw_reboot(rb_system);
|
||||
usleep(5000000); // another sleep while we wait for the reboot to occur
|
||||
}
|
||||
operation_end(ret_val);
|
||||
// This needs to be after the operation_end call so we change pages before we change variables that we display on the screen
|
||||
DataManager::SetValue(TW_ZIP_QUEUE_COUNT, zip_queue_index);
|
||||
|
||||
@@ -313,6 +313,7 @@ protected:
|
||||
int cancelzip(std::string arg);
|
||||
int queueclear(std::string arg);
|
||||
int sleep(std::string arg);
|
||||
int sleepcounter(std::string arg);
|
||||
int appenddatetobackupname(std::string arg);
|
||||
int generatebackupname(std::string arg);
|
||||
int checkpartitionlist(std::string arg);
|
||||
|
||||
@@ -578,6 +578,66 @@
|
||||
<action function="page">clear_vars</action>
|
||||
</actions>
|
||||
</action>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
<condition var1="tw_operation_status" var2="0"/>
|
||||
<condition var1="tw_reboot_system" var2="1"/>
|
||||
</conditions>
|
||||
<actions>
|
||||
<action function="set">tw_sleep=%tw_sleep_total%</action>
|
||||
<action function="page">flash_sleep_and_reboot</action>
|
||||
</actions>
|
||||
</action>
|
||||
</page>
|
||||
|
||||
<page name="flash_sleep_and_reboot">
|
||||
<template name="page"/>
|
||||
|
||||
<text style="text_l">
|
||||
<placement x="%col1_x_header%" y="%row3_header_y%"/>
|
||||
<text>{@install_zip_hdr=Install Zip}</text>
|
||||
</text>
|
||||
|
||||
<text style="text_m">
|
||||
<placement x="%col1_x_header%" y="%row4_header_y%"/>
|
||||
<text>{@install_reboot=Rebooting in %tw_sleep% second(s)}</text>
|
||||
</text>
|
||||
|
||||
<template name="console"/>
|
||||
|
||||
<template name="progress_bar"/>
|
||||
|
||||
<button style="main_button_half_width">
|
||||
<condition var1="tw_sleep" op=">" var2="0"/>
|
||||
<placement x="%center_x%" y="%row15a_y%"/>
|
||||
<text>{@cancel_btn=Cancel}</text>
|
||||
<actions>
|
||||
<action function="set">tw_install_reboot=0</action>
|
||||
<action function="page">flash_done</action>
|
||||
</actions>
|
||||
</button>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_sleep" var2="tw_sleep_total"/>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
</conditions>
|
||||
<action function="sleepcounter">%tw_sleep_total%</action>
|
||||
</action>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_sleep" var2="0"/>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
</conditions>
|
||||
<actions>
|
||||
<action function="sleep">50000</action>
|
||||
<action function="set">tw_back=main2</action>
|
||||
<action function="page">reboot_system_routine</action>
|
||||
</actions>
|
||||
</action>
|
||||
</page>
|
||||
|
||||
<page name="flashimage_confirm">
|
||||
|
||||
@@ -667,7 +667,7 @@
|
||||
<string name="change_fs_err">Error changing file system.</string>
|
||||
<string name="theme_ver_err">Custom theme version does not match TWRP version. Using stock theme.</string>
|
||||
<string name="up_a_level">(Up A Level)</string>
|
||||
<string name="install_reboot">Rebooting in 5 seconds</string>
|
||||
<string name="install_reboot" version="2">Rebooting in %tw_sleep% second(s)</string>
|
||||
<string name="adbbackup_error">Error with ADB Backup. Quitting..."</string>
|
||||
<string name="adbbackup_control_error">Cannot write to adb control channel</string>
|
||||
<string name="twrp_adbbu_option">--twrp option is required to enable twrp adb backup</string>
|
||||
|
||||
@@ -530,6 +530,66 @@
|
||||
<action function="page">clear_vars</action>
|
||||
</actions>
|
||||
</action>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
<condition var1="tw_operation_status" var2="0"/>
|
||||
<condition var1="tw_reboot_system" var2="1"/>
|
||||
</conditions>
|
||||
<actions>
|
||||
<action function="set">tw_sleep=%tw_sleep_total%</action>
|
||||
<action function="page">flash_sleep_and_reboot</action>
|
||||
</actions>
|
||||
</action>
|
||||
</page>
|
||||
|
||||
<page name="flash_sleep_and_reboot">
|
||||
<template name="page"/>
|
||||
|
||||
<text style="text_l">
|
||||
<placement x="%col1_x_header%" y="%row3_header_y%"/>
|
||||
<text>{@install_zip_hdr=Install Zip}</text>
|
||||
</text>
|
||||
|
||||
<text style="text_m">
|
||||
<placement x="%col1_x_header%" y="%row4_header_y%"/>
|
||||
<text>{@install_reboot=Rebooting in %tw_sleep% second(s)}</text>
|
||||
</text>
|
||||
|
||||
<template name="console"/>
|
||||
|
||||
<template name="progress_bar"/>
|
||||
|
||||
<button style="main_button_half_height">
|
||||
<condition var1="tw_sleep" op=">" var2="0"/>
|
||||
<placement x="%center_x%" y="%row21a_y%"/>
|
||||
<text>{@cancel_btn=Cancel}</text>
|
||||
<actions>
|
||||
<action function="set">tw_install_reboot=0</action>
|
||||
<action function="page">flash_done</action>
|
||||
</actions>
|
||||
</button>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_sleep" var2="tw_sleep_total"/>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
</conditions>
|
||||
<action function="sleepcounter">%tw_sleep_total%</action>
|
||||
</action>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_sleep" var2="0"/>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
</conditions>
|
||||
<actions>
|
||||
<action function="sleep">50000</action>
|
||||
<action function="set">tw_back=main2</action>
|
||||
<action function="page">reboot_system_routine</action>
|
||||
</actions>
|
||||
</action>
|
||||
</page>
|
||||
|
||||
<page name="flashimage_confirm">
|
||||
|
||||
@@ -734,6 +734,63 @@
|
||||
<action function="page">clear_vars</action>
|
||||
</actions>
|
||||
</action>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
<condition var1="tw_operation_status" var2="0"/>
|
||||
<condition var1="tw_reboot_system" var2="1"/>
|
||||
</conditions>
|
||||
<actions>
|
||||
<action function="set">tw_sleep=%tw_sleep_total%</action>
|
||||
<action function="page">flash_sleep_and_reboot</action>
|
||||
</actions>
|
||||
</action>
|
||||
</page>
|
||||
|
||||
<page name="flash_sleep_and_reboot">
|
||||
<template name="page"/>
|
||||
|
||||
<template name="statusbar"/>
|
||||
|
||||
<text style="text_m">
|
||||
<placement x="%col1_x_left%" y="%row1_header_y%"/>
|
||||
<text>{@install_reboot=Rebooting in %tw_sleep% second(s)}</text>
|
||||
</text>
|
||||
|
||||
<template name="console"/>
|
||||
|
||||
<template name="progress_bar"/>
|
||||
|
||||
<button style="main_button_half_height">
|
||||
<condition var1="tw_sleep" op=">" var2="0"/>
|
||||
<placement x="%col1_x_right%" y="%row13_y%"/>
|
||||
<text>{@cancel_btn=Cancel}</text>
|
||||
<actions>
|
||||
<action function="set">tw_install_reboot=0</action>
|
||||
<action function="page">flash_done</action>
|
||||
</actions>
|
||||
</button>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_sleep" var2="tw_sleep_total"/>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
</conditions>
|
||||
<action function="sleepcounter">%tw_sleep_total%</action>
|
||||
</action>
|
||||
|
||||
<action>
|
||||
<conditions>
|
||||
<condition var1="tw_sleep" var2="0"/>
|
||||
<condition var1="tw_install_reboot" var2="1"/>
|
||||
</conditions>
|
||||
<actions>
|
||||
<action function="sleep">50000</action>
|
||||
<action function="set">tw_back=main2</action>
|
||||
<action function="page">reboot_system_routine</action>
|
||||
</actions>
|
||||
</action>
|
||||
</page>
|
||||
|
||||
<page name="flashimage_type">
|
||||
|
||||
Reference in New Issue
Block a user