summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2015-01-05 21:58:36 +0100
committerDees Troy <dees_troy@teamw.in>2015-01-09 23:07:07 +0100
commit96af84a4094c2018d35c792e33813c07344f553c (patch)
tree025b4d6f6d5d7c517ef32370661cbf9147a58bb6
parentgui: fix action threading if background thread is busy (diff)
downloadandroid_bootable_recovery-96af84a4094c2018d35c792e33813c07344f553c.tar
android_bootable_recovery-96af84a4094c2018d35c792e33813c07344f553c.tar.gz
android_bootable_recovery-96af84a4094c2018d35c792e33813c07344f553c.tar.bz2
android_bootable_recovery-96af84a4094c2018d35c792e33813c07344f553c.tar.lz
android_bootable_recovery-96af84a4094c2018d35c792e33813c07344f553c.tar.xz
android_bootable_recovery-96af84a4094c2018d35c792e33813c07344f553c.tar.zst
android_bootable_recovery-96af84a4094c2018d35c792e33813c07344f553c.zip
-rw-r--r--gui/action.cpp19
-rw-r--r--gui/devices/1024x600/res/ui.xml1
-rw-r--r--gui/devices/1024x768/res/ui.xml1
-rw-r--r--gui/devices/1080x1920/res/ui.xml1
-rw-r--r--gui/devices/1200x1920/res/ui.xml1
-rw-r--r--gui/devices/1280x800/res/ui.xml1
-rw-r--r--gui/devices/1440x2560/res/ui.xml1
-rw-r--r--gui/devices/1600x2560/res/ui.xml1
-rw-r--r--gui/devices/1920x1200/res/ui.xml1
-rw-r--r--gui/devices/240x240/res/ui.xml1
-rw-r--r--gui/devices/2560x1600/res/ui.xml1
-rw-r--r--gui/devices/280x280/res/ui.xml1
-rw-r--r--gui/devices/320x320/res/ui.xml1
-rw-r--r--gui/devices/320x480/res/ui.xml1
-rw-r--r--gui/devices/480x800/res/ui.xml1
-rw-r--r--gui/devices/480x854/res/ui.xml1
-rw-r--r--gui/devices/540x960/res/ui.xml13
-rw-r--r--gui/devices/720x1280/res/ui.xml1
-rw-r--r--gui/devices/800x1280/res/ui.xml1
-rw-r--r--gui/devices/800x480/res/ui.xml1
-rw-r--r--gui/devices/landscape/res/landscape.xml177
-rw-r--r--gui/devices/portrait/res/portrait.xml161
-rw-r--r--gui/devices/watch/res/watch.xml183
-rw-r--r--gui/objects.hpp1
-rw-r--r--gui/partitionlist.cpp4
-rw-r--r--partition.cpp123
-rw-r--r--partitionmanager.cpp63
-rw-r--r--partitions.hpp8
28 files changed, 713 insertions, 57 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index 750d73b8d..96f620957 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -201,6 +201,7 @@ GUIAction::GUIAction(xml_node<>* node)
mf["decrypt_backup"] = &GUIAction::decrypt_backup;
mf["repair"] = &GUIAction::repair;
mf["changefilesystem"] = &GUIAction::changefilesystem;
+ mf["flashimage"] = &GUIAction::flashimage;
}
// First, get the action
@@ -1651,6 +1652,24 @@ int GUIAction::stopmtp(std::string arg)
return 0;
}
+int GUIAction::flashimage(std::string arg)
+{
+ int op_status = 0;
+
+ operation_start("Flash Image");
+ string path, filename, full_filename;
+ DataManager::GetValue("tw_zip_location", path);
+ DataManager::GetValue("tw_file", filename);
+ full_filename = path + "/" + filename;
+ if (PartitionManager.Flash_Image(full_filename))
+ op_status = 0; // success
+ else
+ op_status = 1; // fail
+
+ operation_end(op_status);
+ return 0;
+}
+
int GUIAction::getKeyByName(std::string key)
{
if (key == "home") return KEY_HOME;
diff --git a/gui/devices/1024x600/res/ui.xml b/gui/devices/1024x600/res/ui.xml
index 7b7ad8ce7..1669d4586 100644
--- a/gui/devices/1024x600/res/ui.xml
+++ b/gui/devices/1024x600/res/ui.xml
@@ -192,6 +192,7 @@
<variable name="button_fill_half_height" value="50" />
<variable name="button_fill_quarter_height" value="30" />
<variable name="button_full_center_x" value="256" />
+ <variable name="flash_list_height" value="200" />
<variable name="backup_list_x" value="23" />
<variable name="backup_list_y" value="105" />
<variable name="backup_list_width" value="486" />
diff --git a/gui/devices/1024x768/res/ui.xml b/gui/devices/1024x768/res/ui.xml
index b5ce1b40b..253ae07e5 100644
--- a/gui/devices/1024x768/res/ui.xml
+++ b/gui/devices/1024x768/res/ui.xml
@@ -192,6 +192,7 @@
<variable name="button_fill_half_height" value="50" />
<variable name="button_fill_quarter_height" value="30" />
<variable name="button_full_center_x" value="256" />
+ <variable name="flash_list_height" value="200" />
<variable name="backup_list_x" value="23" />
<variable name="backup_list_y" value="105" />
<variable name="backup_list_width" value="486" />
diff --git a/gui/devices/1080x1920/res/ui.xml b/gui/devices/1080x1920/res/ui.xml
index 1367015bf..ddab4f317 100644
--- a/gui/devices/1080x1920/res/ui.xml
+++ b/gui/devices/1080x1920/res/ui.xml
@@ -81,6 +81,7 @@
<variable name="row17_text_y" value="1455" />
<variable name="row18_text_y" value="1530" />
<variable name="zip_status_y" value="922" />
+ <variable name="flash_list_height" value="500" />
<variable name="tz_selected_y" value="240" />
<variable name="tz_set_y" value="1500" />
<variable name="tz_current_y" value="1425" />
diff --git a/gui/devices/1200x1920/res/ui.xml b/gui/devices/1200x1920/res/ui.xml
index 77af05ba7..c02032fbd 100644
--- a/gui/devices/1200x1920/res/ui.xml
+++ b/gui/devices/1200x1920/res/ui.xml
@@ -84,6 +84,7 @@
<variable name="row17_text_y" value="1455" />
<variable name="row18_text_y" value="1530" />
<variable name="zip_status_y" value="922" />
+ <variable name="flash_list_height" value="500" />
<variable name="tz_selected_y" value="240" />
<variable name="tz_set_y" value="1500" />
<variable name="tz_current_y" value="1425" />
diff --git a/gui/devices/1280x800/res/ui.xml b/gui/devices/1280x800/res/ui.xml
index 716dadc1e..94d0bf981 100644
--- a/gui/devices/1280x800/res/ui.xml
+++ b/gui/devices/1280x800/res/ui.xml
@@ -192,6 +192,7 @@
<variable name="button_fill_half_height" value="53" />
<variable name="button_fill_quarter_height" value="40" />
<variable name="button_full_center_x" value="320" />
+ <variable name="flash_list_height" value="220" />
<variable name="backup_list_x" value="28" />
<variable name="backup_list_y" value="105" />
<variable name="backup_list_width" value="609" />
diff --git a/gui/devices/1440x2560/res/ui.xml b/gui/devices/1440x2560/res/ui.xml
index 4fc699645..52bf20776 100644
--- a/gui/devices/1440x2560/res/ui.xml
+++ b/gui/devices/1440x2560/res/ui.xml
@@ -81,6 +81,7 @@
<variable name="row17_text_y" value="1935" />
<variable name="row18_text_y" value="2035" />
<variable name="zip_status_y" value="1375" />
+ <variable name="flash_list_height" value="650" />
<variable name="tz_selected_y" value="319" />
<variable name="tz_set_y" value="1995" />
<variable name="tz_current_y" value="1895" />
diff --git a/gui/devices/1600x2560/res/ui.xml b/gui/devices/1600x2560/res/ui.xml
index 76217921b..b85803bb3 100644
--- a/gui/devices/1600x2560/res/ui.xml
+++ b/gui/devices/1600x2560/res/ui.xml
@@ -84,6 +84,7 @@
<variable name="row17_text_y" value="1935" />
<variable name="row18_text_y" value="2035" />
<variable name="zip_status_y" value="1250" />
+ <variable name="flash_list_height" value="650" />
<variable name="tz_selected_y" value="319" />
<variable name="tz_set_y" value="1995" />
<variable name="tz_current_y" value="1895" />
diff --git a/gui/devices/1920x1200/res/ui.xml b/gui/devices/1920x1200/res/ui.xml
index e36d0ae76..4bd85a27a 100644
--- a/gui/devices/1920x1200/res/ui.xml
+++ b/gui/devices/1920x1200/res/ui.xml
@@ -192,6 +192,7 @@
<variable name="button_fill_half_height" value="80" />
<variable name="button_fill_quarter_height" value="60" />
<variable name="button_full_center_x" value="480" />
+ <variable name="flash_list_height" value="300" />
<variable name="backup_list_x" value="50" />
<variable name="backup_list_y" value="160" />
<variable name="backup_list_width" value="900" />
diff --git a/gui/devices/240x240/res/ui.xml b/gui/devices/240x240/res/ui.xml
index d157f85c1..7448ae5ec 100644
--- a/gui/devices/240x240/res/ui.xml
+++ b/gui/devices/240x240/res/ui.xml
@@ -75,6 +75,7 @@
<variable name="row12_text_y" value="192" />
<variable name="row13_text_y" value="208" />
<variable name="zip_status_y" value="224" />
+ <variable name="flash_list_height" value="120" />
<variable name="backup_text_y" value="60" />
<variable name="tz_set_y" value="200" />
<variable name="tz_current_y" value="184" />
diff --git a/gui/devices/2560x1600/res/ui.xml b/gui/devices/2560x1600/res/ui.xml
index 12a2d5536..6da373e56 100644
--- a/gui/devices/2560x1600/res/ui.xml
+++ b/gui/devices/2560x1600/res/ui.xml
@@ -192,6 +192,7 @@
<variable name="button_fill_half_height" value="107" />
<variable name="button_fill_quarter_height" value="80" />
<variable name="button_full_center_x" value="640" />
+ <variable name="flash_list_height" value="450" />
<variable name="backup_list_x" value="50" />
<variable name="backup_list_y" value="210" />
<variable name="backup_list_width" value="1200" />
diff --git a/gui/devices/280x280/res/ui.xml b/gui/devices/280x280/res/ui.xml
index 971e6371f..ae8c27d3f 100644
--- a/gui/devices/280x280/res/ui.xml
+++ b/gui/devices/280x280/res/ui.xml
@@ -74,6 +74,7 @@
<variable name="row11_text_y" value="209" />
<variable name="row12_text_y" value="228" />
<variable name="row13_text_y" value="237" />
+ <variable name="flash_list_height" value="140" />
<variable name="zip_status_y" value="265" />
<variable name="backup_text_y" value="50" />
<variable name="col_progressbar_x" value="31" />
diff --git a/gui/devices/320x320/res/ui.xml b/gui/devices/320x320/res/ui.xml
index 4678e855f..4a03855ef 100644
--- a/gui/devices/320x320/res/ui.xml
+++ b/gui/devices/320x320/res/ui.xml
@@ -75,6 +75,7 @@
<variable name="row12_text_y" value="284" />
<variable name="row13_text_y" value="306" />
<variable name="zip_status_y" value="300" />
+ <variable name="flash_list_height" value="160" />
<variable name="backup_text_y" value="60" />
<variable name="col_progressbar_x" value="34" />
<variable name="row_progressbar_y" value="285" />
diff --git a/gui/devices/320x480/res/ui.xml b/gui/devices/320x480/res/ui.xml
index dd4cdbc36..70d33e601 100644
--- a/gui/devices/320x480/res/ui.xml
+++ b/gui/devices/320x480/res/ui.xml
@@ -77,6 +77,7 @@
<variable name="row17_text_y" value="389" />
<variable name="row18_text_y" value="408" />
<variable name="zip_status_y" value="350" />
+ <variable name="flash_list_height" value="150" />
<variable name="tz_selected_y" value="66" />
<variable name="tz_set_y" value="348" />
<variable name="tz_current_y" value="438" />
diff --git a/gui/devices/480x800/res/ui.xml b/gui/devices/480x800/res/ui.xml
index 0e0f65d70..895cfaa48 100644
--- a/gui/devices/480x800/res/ui.xml
+++ b/gui/devices/480x800/res/ui.xml
@@ -77,6 +77,7 @@
<variable name="row17_text_y" value="620" />
<variable name="row18_text_y" value="650" />
<variable name="zip_status_y" value="585" />
+ <variable name="flash_list_height" value="210" />
<variable name="tz_selected_y" value="110" />
<variable name="tz_set_y" value="580" />
<variable name="tz_current_y" value="730" />
diff --git a/gui/devices/480x854/res/ui.xml b/gui/devices/480x854/res/ui.xml
index 26d8b28d0..dd7efd720 100644
--- a/gui/devices/480x854/res/ui.xml
+++ b/gui/devices/480x854/res/ui.xml
@@ -76,6 +76,7 @@
<variable name="row17_text_y" value="630" />
<variable name="row18_text_y" value="660" />
<variable name="zip_status_y" value="585" />
+ <variable name="flash_list_height" value="210" />
<variable name="tz_selected_y" value="110" />
<variable name="tz_set_y" value="580" />
<variable name="tz_current_y" value="730" />
diff --git a/gui/devices/540x960/res/ui.xml b/gui/devices/540x960/res/ui.xml
index dc647ce60..eb6d671bc 100644
--- a/gui/devices/540x960/res/ui.xml
+++ b/gui/devices/540x960/res/ui.xml
@@ -77,6 +77,7 @@
<variable name="row17_text_y" value="780" />
<variable name="row18_text_y" value="820" />
<variable name="zip_status_y" value="696" />
+ <variable name="flash_list_height" value="260" />
<variable name="tz_selected_y" value="110" />
<variable name="tz_set_y" value="720" />
<variable name="tz_current_y" value="895" />
@@ -311,7 +312,7 @@
<object type="button">
<placement x="%sort_col1_button_x%" y="%sort_asc_button_y%" />
- <font resource="UItext" color="%button_text_color%" />
+ <font resource="mediumfont" color="%button_text_color%" />
<text>Name</text>
<image resource="sort_button" />
<action function="set">tw_gui_sort_order=1</action>
@@ -319,7 +320,7 @@
<object type="button">
<placement x="%sort_col2_button_x%" y="%sort_asc_button_y%" />
- <font resource="UItext" color="%button_text_color%" />
+ <font resource="mediumfont" color="%button_text_color%" />
<text>Date</text>
<image resource="sort_button" />
<action function="set">tw_gui_sort_order=2</action>
@@ -327,7 +328,7 @@
<object type="button">
<placement x="%sort_col3_button_x%" y="%sort_asc_button_y%" />
- <font resource="UItext" color="%button_text_color%" />
+ <font resource="mediumfont" color="%button_text_color%" />
<text>Size</text>
<image resource="sort_button" />
<action function="set">tw_gui_sort_order=3</action>
@@ -341,7 +342,7 @@
<object type="button">
<placement x="%sort_col1_button_x%" y="%sort_desc_button_y%" />
- <font resource="UItext" color="%button_text_color%" />
+ <font resource="mediumfont" color="%button_text_color%" />
<text>Name</text>
<image resource="sort_button" />
<action function="set">tw_gui_sort_order=-1</action>
@@ -349,7 +350,7 @@
<object type="button">
<placement x="%sort_col2_button_x%" y="%sort_desc_button_y%" />
- <font resource="UItext" color="%button_text_color%" />
+ <font resource="mediumfont" color="%button_text_color%" />
<text>Date</text>
<image resource="sort_button" />
<action function="set">tw_gui_sort_order=-2</action>
@@ -357,7 +358,7 @@
<object type="button">
<placement x="%sort_col3_button_x%" y="%sort_desc_button_y%" />
- <font resource="UItext" color="%button_text_color%" />
+ <font resource="mediumfont" color="%button_text_color%" />
<text>Size</text>
<image resource="sort_button" />
<action function="set">tw_gui_sort_order=-3</action>
diff --git a/gui/devices/720x1280/res/ui.xml b/gui/devices/720x1280/res/ui.xml
index 2f1fbc7c5..3020daa4f 100644
--- a/gui/devices/720x1280/res/ui.xml
+++ b/gui/devices/720x1280/res/ui.xml
@@ -81,6 +81,7 @@
<variable name="row17_text_y" value="970" />
<variable name="row18_text_y" value="1020" />
<variable name="zip_status_y" value="615" />
+ <variable name="flash_list_height" value="330" />
<variable name="tz_selected_y" value="160" />
<variable name="tz_set_y" value="950" />
<variable name="tz_current_y" value="1180" />
diff --git a/gui/devices/800x1280/res/ui.xml b/gui/devices/800x1280/res/ui.xml
index 03b6144fc..6f49bf7ff 100644
--- a/gui/devices/800x1280/res/ui.xml
+++ b/gui/devices/800x1280/res/ui.xml
@@ -78,6 +78,7 @@
<variable name="row17_text_y" value="%row16_text_y%+%text_row_height%" />
<variable name="row18_text_y" value="%row17_text_y%+%text_row_height%" />
<variable name="zip_status_y" value="640" />
+ <variable name="flash_list_height" value="330" />
<variable name="tz_selected_y" value="160" />
<variable name="tz_set_y" value="955" />
<variable name="tz_current_y" value="1185" />
diff --git a/gui/devices/800x480/res/ui.xml b/gui/devices/800x480/res/ui.xml
index ed1c84271..b80ed3be1 100644
--- a/gui/devices/800x480/res/ui.xml
+++ b/gui/devices/800x480/res/ui.xml
@@ -192,6 +192,7 @@
<variable name="button_fill_half_height" value="40" />
<variable name="button_fill_quarter_height" value="30" />
<variable name="button_full_center_x" value="200" />
+ <variable name="flash_list_height" value="140" />
<variable name="backup_list_x" value="23" />
<variable name="backup_list_y" value="80" />
<variable name="backup_list_width" value="367" />
diff --git a/gui/devices/landscape/res/landscape.xml b/gui/devices/landscape/res/landscape.xml
index 8f557aa33..f66eb8bb6 100644
--- a/gui/devices/landscape/res/landscape.xml
+++ b/gui/devices/landscape/res/landscape.xml
@@ -148,6 +148,17 @@
<object type="template" name="sort_options" />
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%filemanager_select_x%" y="%filemanager_select_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Images...</text>
+ <image resource="main_button" />
+ <actions>
+ <action function="page">install_image</action>
+ </actions>
+ </object>
+
<object type="action">
<condition var1="tw_filename" op="modified" />
<actions>
@@ -390,6 +401,172 @@
</object>
</page>
+ <page name="install_image">
+ <object type="template" name="header" />
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row1_text_y%" placement="5" />
+ <text>Select Image to Flash</text>
+ </object>
+
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <fill color="%button_fill_color%" />
+ <placement x="%button_full_center_x%" y="%zipstorage_text_y%" w="%button_fill_full_width%" h="%button_fill_quarter_height%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Storage: %tw_storage_display_name% (%tw_storage_free_size% MB)</text>
+ <actions>
+ <action function="set">tw_back=install_image</action>
+ <action function="page">selectstorage</action>
+ </actions>
+ </object>
+
+ <object type="fileselector">
+ <highlight color="%fileselector_highlight_color%" />
+ <placement x="%fileselector_folder_x%" y="%fileselector_install_y%" w="%fileselector_folder_width%" h="%fileselector_install_height%" />
+ <header background="%fileselector_header_background%" textcolor="%fileselector_header_textcolor%" separatorcolor="%fileselector_header_separatorcolor%" separatorheight="%fileselector_header_separatorheight%" />
+ <fastscroll linecolor="%fastscroll_linecolor%" rectcolor="%fastscroll_rectcolor%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%" />
+ <text>Folders:</text>
+ <separator color="%fileselector_separatorcolor%" height="%fileselector_separatorheight%" />
+ <sort name="tw_gui_sort_order" />
+ <icon folder="folder_icon" file="file_icon" />
+ <background color="%fileselector_background%" />
+ <font resource="font" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%fileselector_highlight_font_color%" />
+ <filter folders="1" files="0" />
+ <path name="tw_zip_location" default="/sdcard" />
+ <data name="select" />
+ </object>
+
+ <object type="fileselector">
+ <highlight color="%fileselector_highlight_color%" />
+ <placement x="%fileselector_file_x%" y="%fileselector_install_y%" w="%fileselector_file_width%" h="%fileselector_install_height%" />
+ <header background="%fileselector_header_background%" textcolor="%fileselector_header_textcolor%" separatorcolor="%fileselector_header_separatorcolor%" separatorheight="%fileselector_header_separatorheight%" />
+ <fastscroll linecolor="%fastscroll_linecolor%" rectcolor="%fastscroll_rectcolor%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%" />
+ <text>%tw_zip_location%</text>
+ <separator color="%fileselector_separatorcolor%" height="%fileselector_separatorheight%" />
+ <sort name="tw_gui_sort_order" />
+ <icon folder="folder_icon" file="file_icon" />
+ <background color="%fileselector_background%" />
+ <font resource="font" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%fileselector_highlight_font_color%" />
+ <filter extn=".img" folders="0" files="1" />
+ <path name="tw_zip_location" />
+ <data name="tw_filename" />
+ <selection name="tw_file" />
+ </object>
+
+ <object type="template" name="sort_options" />
+
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%filemanager_select_x%" y="%filemanager_select_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Zips...</text>
+ <image resource="main_button" />
+ <actions>
+ <action function="page">install</action>
+ </actions>
+ </object>
+
+ <object type="action">
+ <condition var1="tw_filename" op="modified" />
+ <action function="page">flashimage_confirm</action>
+ </object>
+
+ <object type="action">
+ <touch key="back" />
+ <action function="page">install</action>
+ </object>
+
+ <object type="action">
+ <touch key="home" />
+ <action function="page">main</action>
+ </object>
+
+ <object type="template" name="footer" />
+ </page>
+
+ <page name="flashimage_confirm">
+ <object type="template" name="header" />
+
+ <object type="partitionlist">
+ <highlight color="%fileselector_highlight_color%" />
+ <placement x="%col2_x%" y="%row1_text_y%" w="%listbox_width%" h="%flash_list_height%" />
+ <header background="%fileselector_header_background%" textcolor="%fileselector_header_textcolor%" separatorcolor="%fileselector_header_separatorcolor%" separatorheight="%fileselector_header_separatorheight%" />
+ <fastscroll linecolor="%fastscroll_linecolor%" rectcolor="%fastscroll_rectcolor%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%" />
+ <text>Select Partition to Flash Image:</text>
+ <icon selected="radio_true" unselected="radio_false" />
+ <separator color="%fileselector_separatorcolor%" height="%fileselector_separatorheight%" />
+ <background color="%listbox_background%" />
+ <font resource="font" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%fileselector_highlight_font_color%" />
+ <data name="tw_flash_partition" />
+ <listtype name="flashimg" />
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row8_text_y%" placement="5" />
+ <text>Folder:</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row9_text_y%" placement="5" />
+ <text>%tw_zip_location%</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row10_text_y%" placement="5" />
+ <text>File to flash:</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row11_text_y%" placement="5" />
+ <text>%tw_file%</text>
+ </object>
+
+ <object type="slider">
+ <placement x="%slider_x%" y="%slider_y%" placement="5" />
+ <resource base="slider" used="slider-used" touch="slider-touch" />
+ <actions>
+ <action function="set">tw_back=flashimage_confirm</action>
+ <action function="set">tw_action=flashimage</action>
+ <action function="set">tw_has_action2=0</action>
+ <action function="set">tw_action_text1=Flashing Image...</action>
+ <action function="set">tw_action_text2=</action>
+ <action function="set">tw_complete_text1=Image Flashed</action>
+ <action function="page">action_page</action>
+ </actions>
+ <action function="flashimage"></action>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%slider_text_y%" placement="4" />
+ <text>Swipe to Confirm Flash</text>
+ </object>
+
+ <object type="action">
+ <touch key="back" />
+ <actions>
+ <action function="set">tw_clear_destination=install_image</action>
+ <action function="page">clear_vars</action>
+ </actions>
+ </object>
+
+ <object type="action">
+ <touch key="home" />
+ <actions>
+ <action function="set">tw_clear_destination=main2</action>
+ <action function="page">clear_vars</action>
+ </actions>
+ </object>
+
+ <object type="template" name="footer" />
+ </page>
+
<page name="clear_vars">
<object type="action">
<action function="set">tw_operation_state=0</action>
diff --git a/gui/devices/portrait/res/portrait.xml b/gui/devices/portrait/res/portrait.xml
index 0642c30b0..b73297411 100644
--- a/gui/devices/portrait/res/portrait.xml
+++ b/gui/devices/portrait/res/portrait.xml
@@ -133,6 +133,17 @@
<object type="template" name="sort_options" />
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%filemanager_select_x%" y="%filemanager_select_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Images...</text>
+ <image resource="medium_button" />
+ <actions>
+ <action function="page">install_image</action>
+ </actions>
+ </object>
+
<object type="action">
<condition var1="tw_filename" op="modified" />
<actions>
@@ -403,6 +414,156 @@
</object>
</page>
+ <page name="install_image">
+ <object type="template" name="header" />
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row1_header_y%" placement="5" />
+ <text>Select Image to Install</text>
+ </object>
+
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <fill color="%button_fill_color%" />
+ <placement x="%col1_x%" y="%row1_text_y%" w="%button_fill_full_width%" h="%button_fill_quarter_height%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Storage: %tw_storage_display_name% (%tw_storage_free_size% MB)</text>
+ <actions>
+ <action function="set">tw_back=install_image</action>
+ <action function="page">selectstorage</action>
+ </actions>
+ </object>
+
+ <object type="fileselector">
+ <highlight color="%fileselector_highlight_color%" />
+ <placement x="%fileselector_x%" y="%row3_text_y%" w="%fileselector_width%" h="%fileselector_install_height%" />
+ <header background="%fileselector_header_background%" textcolor="%fileselector_header_textcolor%" separatorcolor="%fileselector_header_separatorcolor%" separatorheight="%fileselector_header_separatorheight%" />
+ <fastscroll linecolor="%fastscroll_linecolor%" rectcolor="%fastscroll_rectcolor%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%" />
+ <text>%tw_zip_location%</text>
+ <separator color="%fileselector_separatorcolor%" height="%fileselector_separatorheight%" />
+ <sort name="tw_gui_sort_order" />
+ <icon folder="folder_icon" file="file_icon" />
+ <background color="%fileselector_background%" />
+ <font resource="filelist" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%fileselector_highlight_font_color%" />
+ <filter extn=".img" folders="1" files="1" />
+ <path name="tw_zip_location" default="/sdcard" />
+ <data name="tw_filename" />
+ <selection name="tw_file" />
+ </object>
+
+ <object type="template" name="sort_options" />
+
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%filemanager_select_x%" y="%filemanager_select_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Zips...</text>
+ <image resource="medium_button" />
+ <actions>
+ <action function="page">install</action>
+ </actions>
+ </object>
+
+ <object type="action">
+ <condition var1="tw_filename" op="modified" />
+ <action function="page">flashimage_confirm</action>
+ </object>
+
+ <object type="action">
+ <touch key="back" />
+ <action function="page">install</action>
+ </object>
+
+ <object type="action">
+ <touch key="home" />
+ <action function="page">main</action>
+ </object>
+
+ <object type="template" name="footer" />
+ </page>
+
+ <page name="flashimage_confirm">
+ <object type="template" name="header" />
+
+ <object type="partitionlist">
+ <highlight color="%fileselector_highlight_color%" />
+ <placement x="%listbox_x%" y="%row1_header_y%" w="%listbox_width%" h="%flash_list_height%" />
+ <header background="%fileselector_header_background%" textcolor="%fileselector_header_textcolor%" separatorcolor="%fileselector_header_separatorcolor%" separatorheight="%fileselector_header_separatorheight%" />
+ <fastscroll linecolor="%fastscroll_linecolor%" rectcolor="%fastscroll_rectcolor%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%" />
+ <text>Select Partition to Flash Image:</text>
+ <icon selected="radio_true" unselected="radio_false" />
+ <separator color="%fileselector_separatorcolor%" height="%fileselector_separatorheight%" />
+ <background color="%listbox_background%" />
+ <font resource="filelist" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%fileselector_highlight_font_color%" />
+ <data name="tw_flash_partition" />
+ <listtype name="flashimg" />
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row8_text_y%" placement="5" />
+ <text>Folder:</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="mediumfont" />
+ <placement x="%center_x%" y="%row9_text_y%" placement="5" />
+ <text>%tw_zip_location%</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row10_text_y%" placement="5" />
+ <text>File to flash:</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="mediumfont" />
+ <placement x="%center_x%" y="%row11_text_y%" placement="5" />
+ <text>%tw_file%</text>
+ </object>
+
+ <object type="slider">
+ <placement x="%slider_x%" y="%slider_y%" placement="5" />
+ <resource base="slider" used="slider-used" touch="slider-touch" />
+ <actions>
+ <action function="set">tw_back=flashimage_confirm</action>
+ <action function="set">tw_action=flashimage</action>
+ <action function="set">tw_has_action2=0</action>
+ <action function="set">tw_action_text1=Flashing Image...</action>
+ <action function="set">tw_action_text2=</action>
+ <action function="set">tw_complete_text1=Image Flashed</action>
+ <action function="page">action_page</action>
+ </actions>
+ <action function="flashimage"></action>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%slider_text_y%" placement="4" />
+ <text>Swipe to Confirm Flash</text>
+ </object>
+
+ <object type="action">
+ <touch key="back" />
+ <actions>
+ <action function="set">tw_clear_destination=install_image</action>
+ <action function="page">clear_vars</action>
+ </actions>
+ </object>
+
+ <object type="action">
+ <touch key="home" />
+ <actions>
+ <action function="set">tw_clear_destination=main2</action>
+ <action function="page">clear_vars</action>
+ </actions>
+ </object>
+
+ <object type="template" name="footer" />
+ </page>
+
<page name="clear_vars">
<object type="action">
<action function="set">tw_operation_state=0</action>
diff --git a/gui/devices/watch/res/watch.xml b/gui/devices/watch/res/watch.xml
index 38de230c4..03effde31 100644
--- a/gui/devices/watch/res/watch.xml
+++ b/gui/devices/watch/res/watch.xml
@@ -22,10 +22,7 @@
<font resource="font" color="%button_text_color%" />
<text>Install</text>
<image resource="main_button" />
- <actions>
- <action function="queueclear"></action>
- <action function="page">install</action>
- </actions>
+ <action function="page">install_select</action>
</object>
<object type="button">
@@ -95,6 +92,45 @@
<object type="template" name="footer" />
</page>
+ <page name="install_select">
+ <object type="template" name="twrpheader" />
+
+ <object type="template" name="header" />
+
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%col1_x%" y="%row1_home_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Install Zips</text>
+ <image resource="main_button" />
+ <actions>
+ <action function="queueclear"></action>
+ <action function="page">install</action>
+ </actions>
+ </object>
+
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <placement x="%col2_x%" y="%row1_home_y%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Install Images</text>
+ <image resource="main_button" />
+ <action function="page">install_image</action>
+ </object>
+
+ <object type="action">
+ <touch key="back" />
+ <action function="page">main</action>
+ </object>
+
+ <object type="action">
+ <touch key="home" />
+ <action function="page">main</action>
+ </object>
+
+ <object type="template" name="footer" />
+ </page>
+
<page name="install">
<object type="template" name="header" />
@@ -145,7 +181,7 @@
<object type="action">
<touch key="back" />
- <action function="page">main</action>
+ <action function="page">install_select</action>
</object>
<object type="action">
@@ -385,6 +421,143 @@
</object>
</page>
+ <page name="install_image">
+ <object type="template" name="header" />
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row1_header_y%" placement="5" />
+ <text>Select Image to Install</text>
+ </object>
+
+ <object type="button">
+ <highlight color="%highlight_color%" />
+ <fill color="%button_fill_color%" />
+ <placement x="%col1_x%" y="%row1_text_y%" w="%button_fill_full_width%" h="%button_fill_quarter_height%" />
+ <font resource="font" color="%button_text_color%" />
+ <text>Storage: %tw_storage_display_name% (%tw_storage_free_size% MB)</text>
+ <actions>
+ <action function="set">tw_back=install_image</action>
+ <action function="page">selectstorage</action>
+ </actions>
+ </object>
+
+ <object type="fileselector">
+ <highlight color="%fileselector_highlight_color%" />
+ <placement x="%fileselector_x%" y="%row3_text_y%" w="%fileselector_width%" h="%fileselector_install_height%" />
+ <header background="%fileselector_header_background%" textcolor="%fileselector_header_textcolor%" separatorcolor="%fileselector_header_separatorcolor%" separatorheight="%fileselector_header_separatorheight%" />
+ <fastscroll linecolor="%fastscroll_linecolor%" rectcolor="%fastscroll_rectcolor%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%" />
+ <text>%tw_zip_location%</text>
+ <separator color="%fileselector_separatorcolor%" height="%fileselector_separatorheight%" />
+ <sort name="tw_gui_sort_order" />
+ <icon folder="folder_icon" file="file_icon" />
+ <background color="%fileselector_background%" />
+ <font resource="filelist" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%fileselector_highlight_font_color%" />
+ <filter extn=".img" folders="1" files="1" />
+ <path name="tw_zip_location" default="/sdcard" />
+ <data name="tw_filename" />
+ <selection name="tw_file" />
+ </object>
+
+ <object type="template" name="sort_options" />
+
+ <object type="action">
+ <condition var1="tw_filename" op="modified" />
+ <action function="page">flashimage_confirm</action>
+ </object>
+
+ <object type="action">
+ <touch key="back" />
+ <action function="page">install_select</action>
+ </object>
+
+ <object type="action">
+ <touch key="home" />
+ <action function="page">main</action>
+ </object>
+
+ <object type="template" name="footer" />
+ </page>
+
+ <page name="flashimage_confirm">
+ <object type="template" name="header" />
+
+ <object type="partitionlist">
+ <highlight color="%fileselector_highlight_color%" />
+ <placement x="%listbox_x%" y="%row1_header_y%" w="%listbox_width%" h="%flash_list_height%" />
+ <header background="%fileselector_header_background%" textcolor="%fileselector_header_textcolor%" separatorcolor="%fileselector_header_separatorcolor%" separatorheight="%fileselector_header_separatorheight%" />
+ <fastscroll linecolor="%fastscroll_linecolor%" rectcolor="%fastscroll_rectcolor%" w="%fastscroll_w%" linew="%fastscroll_linew%" rectw="%fastscroll_rectw%" recth="%fastscroll_recth%" />
+ <text>Select Partition to Flash Image:</text>
+ <icon selected="radio_true" unselected="radio_false" />
+ <separator color="%fileselector_separatorcolor%" height="%fileselector_separatorheight%" />
+ <background color="%listbox_background%" />
+ <font resource="filelist" spacing="%fileselector_spacing%" color="%text_color%" highlightcolor="%fileselector_highlight_font_color%" />
+ <data name="tw_flash_partition" />
+ <listtype name="flashimg" />
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row8_text_y%" placement="5" />
+ <text>Folder:</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="mediumfont" />
+ <placement x="%center_x%" y="%row9_text_y%" placement="5" />
+ <text>%tw_zip_location%</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%row10_text_y%" placement="5" />
+ <text>File to flash:</text>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="mediumfont" />
+ <placement x="%center_x%" y="%row11_text_y%" placement="5" />
+ <text>%tw_file%</text>
+ </object>
+
+ <object type="slider">
+ <placement x="%slider_x%" y="%slider_y%" placement="5" />
+ <resource base="slider" used="slider-used" touch="slider-touch" />
+ <actions>
+ <action function="set">tw_back=flashimage_confirm</action>
+ <action function="set">tw_action=flashimage</action>
+ <action function="set">tw_has_action2=0</action>
+ <action function="set">tw_action_text1=Flashing Image...</action>
+ <action function="set">tw_action_text2=</action>
+ <action function="set">tw_complete_text1=Image Flashed</action>
+ <action function="page">action_page</action>
+ </actions>
+ <action function="flashimage"></action>
+ </object>
+
+ <object type="text" color="%text_color%">
+ <font resource="font" />
+ <placement x="%center_x%" y="%slider_text_y%" placement="4" />
+ <text>Swipe to Confirm Flash</text>
+ </object>
+
+ <object type="action">
+ <touch key="back" />
+ <actions>
+ <action function="set">tw_clear_destination=install_image</action>
+ <action function="page">clear_vars</action>
+ </actions>
+ </object>
+
+ <object type="action">
+ <touch key="home" />
+ <actions>
+ <action function="set">tw_clear_destination=main2</action>
+ <action function="page">clear_vars</action>
+ </actions>
+ </object>
+ </page>
+
<page name="clear_vars">
<object type="action">
<action function="set">tw_operation_state=0</action>
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 76dbb4625..bb3edb398 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -352,6 +352,7 @@ protected:
int changefilesystem(std::string arg);
int startmtp(std::string arg);
int stopmtp(std::string arg);
+ int flashimage(std::string arg);
int simulate;
};
diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp
index 9cc6a777b..3ec15488a 100644
--- a/gui/partitionlist.cpp
+++ b/gui/partitionlist.cpp
@@ -793,6 +793,10 @@ int GUIPartitionList::NotifyTouch(TOUCH_STATE state, int x, int y)
DataManager::SetValue(mVariable, str);
}
} else {
+ if (ListType == "flashimg") { // only one item can be selected for flashing images
+ for (int i=0; i<listSize; i++)
+ mList.at(i).selected = 0;
+ }
if (mList.at(actualSelection).selected)
mList.at(actualSelection).selected = 0;
else
diff --git a/partition.cpp b/partition.cpp
index 8edf54a5d..434115979 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -154,6 +154,7 @@ TWPartition::TWPartition() {
Retain_Layout_Version = false;
Crypto_Key_Location = "footer";
MTP_Storage_ID = 0;
+ Can_Flash_Img = false;
}
TWPartition::~TWPartition(void) {
@@ -382,9 +383,11 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Display_Name = "Boot";
Backup_Display_Name = Display_Name;
Can_Be_Backed_Up = true;
+ Can_Flash_Img = true;
} else if (Mount_Point == "/recovery") {
Display_Name = "Recovery";
Backup_Display_Name = Display_Name;
+ Can_Flash_Img = true;
}
}
@@ -560,6 +563,17 @@ bool TWPartition::Process_Flags(string Flags, bool Display_Error) {
}
} else if (ptr_len > 8 && strncmp(ptr, "mounttodecrypt", 14) == 0) {
Mount_To_Decrypt = true;
+ } else if (strncmp(ptr, "flashimg", 8) == 0) {
+ if (ptr_len == 8) {
+ Can_Flash_Img = true;
+ } else if (ptr_len == 10) {
+ ptr += 9;
+ if (*ptr == '1' || *ptr == 'y' || *ptr == 'Y') {
+ Can_Flash_Img = true;
+ } else {
+ Can_Flash_Img = false;
+ }
+ }
} else {
if (Display_Error)
LOGERR("Unhandled flag: '%s'\n", ptr);
@@ -1313,9 +1327,7 @@ bool TWPartition::Restore(string restore_folder, const unsigned long long *total
else if (Is_Image(Restore_File_System)) {
*already_restored_size += TWFunc::Get_File_Size(Backup_Name);
if (Restore_File_System == "emmc")
- return Restore_DD(restore_folder, total_restore_size, already_restored_size);
- else if (Restore_File_System == "mtd" || Restore_File_System == "bml")
- return Restore_Flash_Image(restore_folder, total_restore_size, already_restored_size);
+ return Restore_Image(restore_folder, total_restore_size, already_restored_size, Restore_File_System);
}
LOGERR("Unknown restore method for '%s'\n", Mount_Point.c_str());
@@ -1888,53 +1900,21 @@ bool TWPartition::Restore_Tar(string restore_folder, string Restore_File_System,
return ret;
}
-bool TWPartition::Restore_DD(string restore_folder, const unsigned long long *total_restore_size, unsigned long long *already_restored_size) {
- string Full_FileName, Command;
+bool TWPartition::Restore_Image(string restore_folder, const unsigned long long *total_restore_size, unsigned long long *already_restored_size, string Restore_File_System) {
+ string Full_FileName;
double display_percent, progress_percent;
char size_progress[1024];
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, "Restoring");
Full_FileName = restore_folder + "/" + Backup_FileName;
- if (!Find_Partition_Size()) {
- LOGERR("Unable to find partition size for '%s'\n", Mount_Point.c_str());
- return false;
- }
- unsigned long long backup_size = TWFunc::Get_File_Size(Full_FileName);
- if (backup_size > Size) {
- LOGERR("Size (%iMB) of backup '%s' is larger than target device '%s' (%iMB)\n",
- (int)(backup_size / 1048576LLU), Full_FileName.c_str(),
- Actual_Block_Device.c_str(), (int)(Size / 1048576LLU));
- return false;
+ if (Restore_File_System == "emmc") {
+ if (!Flash_Image_DD(Full_FileName))
+ return false;
+ } else if (Restore_File_System == "mtd" || Restore_File_System == "bml") {
+ if (!Flash_Image_FI(Full_FileName))
+ return false;
}
-
- gui_print("Restoring %s...\n", Display_Name.c_str());
- Command = "dd bs=4096 if='" + Full_FileName + "' of=" + Actual_Block_Device;
- LOGINFO("Restore command: '%s'\n", Command.c_str());
- TWFunc::Exec_Cmd(Command);
- display_percent = (double)(Restore_Size + *already_restored_size) / (double)(*total_restore_size) * 100;
- sprintf(size_progress, "%lluMB of %lluMB, %i%%", (Restore_Size + *already_restored_size) / 1048576, *total_restore_size / 1048576, (int)(display_percent));
- DataManager::SetValue("tw_size_progress", size_progress);
- progress_percent = (display_percent / 100);
- DataManager::SetProgress((float)(progress_percent));
- *already_restored_size += Restore_Size;
- return true;
-}
-
-bool TWPartition::Restore_Flash_Image(string restore_folder, const unsigned long long *total_restore_size, unsigned long long *already_restored_size) {
- string Full_FileName, Command;
- double display_percent, progress_percent;
- char size_progress[1024];
-
- gui_print("Restoring %s...\n", Display_Name.c_str());
- Full_FileName = restore_folder + "/" + Backup_FileName;
- // Sometimes flash image doesn't like to flash due to the first 2KB matching, so we erase first to ensure that it flashes
- Command = "erase_image " + MTD_Name;
- LOGINFO("Erase command: '%s'\n", Command.c_str());
- TWFunc::Exec_Cmd(Command);
- Command = "flash_image " + MTD_Name + " '" + Full_FileName + "'";
- LOGINFO("Restore command: '%s'\n", Command.c_str());
- TWFunc::Exec_Cmd(Command);
display_percent = (double)(Restore_Size + *already_restored_size) / (double)(*total_restore_size) * 100;
sprintf(size_progress, "%lluMB of %lluMB, %i%%", (Restore_Size + *already_restored_size) / 1048576, *total_restore_size / 1048576, (int)(display_percent));
DataManager::SetValue("tw_size_progress", size_progress);
@@ -2070,7 +2050,62 @@ uint64_t TWPartition::Get_Max_FileSize() {
maxFileSize = 3.94 * constTB; //3.94 TB
else
maxFileSize = 100000000L;
- LOGINFO("Get_Max_FileSize::maxFileSize: %\n", maxFileSize);
+ LOGINFO("Get_Max_FileSize::maxFileSize: %llu\n", maxFileSize);
return maxFileSize - 1;
}
+bool TWPartition::Flash_Image(string Filename) {
+ string Restore_File_System;
+
+ LOGINFO("Image filename is: %s\n", Filename.c_str());
+
+ if (Backup_Method == FILES) {
+ LOGERR("Cannot flash images to file systems\n");
+ return false;
+ } else if (!Can_Flash_Img) {
+ LOGERR("Cannot flash images to partitions %s\n", Display_Name.c_str());
+ return false;
+ } else {
+ if (!Find_Partition_Size()) {
+ LOGERR("Unable to find partition size for '%s'\n", Mount_Point.c_str());
+ return false;
+ }
+ unsigned long long image_size = TWFunc::Get_File_Size(Filename);
+ if (image_size > Size) {
+ LOGERR("Size (%llu bytes) of image '%s' is larger than target device '%s' (%llu bytes)\n",
+ image_size, Filename.c_str(), Actual_Block_Device.c_str(), Size);
+ return false;
+ }
+ if (Backup_Method == DD)
+ return Flash_Image_DD(Filename);
+ else if (Backup_Method == FLASH_UTILS)
+ return Flash_Image_FI(Filename);
+ }
+
+ LOGERR("Unknown flash method for '%s'\n", Mount_Point.c_str());
+ return false;
+}
+
+bool TWPartition::Flash_Image_DD(string Filename) {
+ string Command;
+
+ gui_print("Flashing %s...\n", Display_Name.c_str());
+ Command = "dd bs=4096 if='" + Filename + "' of=" + Actual_Block_Device;
+ LOGINFO("Flash command: '%s'\n", Command.c_str());
+ TWFunc::Exec_Cmd(Command);
+ return true;
+}
+
+bool TWPartition::Flash_Image_FI(string Filename) {
+ string Command;
+
+ gui_print("Flashing %s...\n", Display_Name.c_str());
+ // Sometimes flash image doesn't like to flash due to the first 2KB matching, so we erase first to ensure that it flashes
+ Command = "erase_image " + MTD_Name;
+ LOGINFO("Erase command: '%s'\n", Command.c_str());
+ TWFunc::Exec_Cmd(Command);
+ Command = "flash_image " + MTD_Name + " '" + Filename + "'";
+ LOGINFO("Flash command: '%s'\n", Command.c_str());
+ TWFunc::Exec_Cmd(Command);
+ return true;
+}
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 5d0fb018e..09ae5d2be 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -268,6 +268,8 @@ void TWPartitionManager::Output_Partition(TWPartition* Part) {
printf("Retain_Layout_Version ");
if (Part->Mount_To_Decrypt)
printf("Mount_To_Decrypt ");
+ if (Part->Can_Flash_Img)
+ printf("Can_Flash_Img ");
printf("\n");
if (!Part->SubPartition_Of.empty())
printf(" SubPartition_Of: %s\n", Part->SubPartition_Of.c_str());
@@ -1848,6 +1850,16 @@ void TWPartitionManager::Get_Partition_List(string ListType, std::vector<Partiti
Partition_List->push_back(datamedia);
}
}
+ } else if (ListType == "flashimg") {
+ for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+ if ((*iter)->Can_Flash_Img && (*iter)->Is_Present) {
+ struct PartitionList part;
+ part.Display_Name = (*iter)->Backup_Display_Name;
+ part.Mount_Point = (*iter)->Backup_Path;
+ part.selected = 0;
+ Partition_List->push_back(part);
+ }
+ }
} else {
LOGERR("Unknown list type '%s' requested for TWPartitionManager::Get_Partition_List\n", ListType.c_str());
}
@@ -2111,3 +2123,54 @@ bool TWPartitionManager::Remove_MTP_Storage(unsigned int Storage_ID) {
#endif
return false;
}
+
+bool TWPartitionManager::Flash_Image(string Filename) {
+ int check, partition_count = 0;
+ TWPartition* flash_part = NULL;
+ string Flash_List, flash_path;
+ size_t start_pos = 0, end_pos = 0;
+
+ gui_print("\n[IMAGE FLASH STARTED]\n\n");
+ gui_print("Image to flash: '%s'\n", Filename.c_str());
+
+ if (!Mount_Current_Storage(true))
+ return false;
+
+ gui_print("Calculating restore details...\n");
+ DataManager::GetValue("tw_flash_partition", Flash_List);
+ if (!Flash_List.empty()) {
+ end_pos = Flash_List.find(";", start_pos);
+ while (end_pos != string::npos && start_pos < Flash_List.size()) {
+ flash_path = Flash_List.substr(start_pos, end_pos - start_pos);
+ flash_part = Find_Partition_By_Path(flash_path);
+ if (flash_part != NULL) {
+ partition_count++;
+ if (partition_count > 1) {
+ LOGERR("Too many partitions selected for flashing.\n");
+ return false;
+ }
+ } else {
+ LOGERR("Unable to locate '%s' partition for flashing (flash list).\n", flash_path.c_str());
+ return false;
+ }
+ start_pos = end_pos + 1;
+ end_pos = Flash_List.find(";", start_pos);
+ }
+ }
+
+ if (partition_count == 0) {
+ LOGERR("No partitions selected for flashing.\n");
+ return false;
+ }
+
+ DataManager::SetProgress(0.0);
+ if (flash_part) {
+ if (!flash_part->Flash_Image(Filename))
+ return false;
+ } else {
+ LOGERR("Invalid flash partition specified.\n");
+ return false;
+ }
+ gui_print_color("highlight", "[IMAGE FLASH COMPLETED]\n\n");
+ return true;
+}
diff --git a/partitions.hpp b/partitions.hpp
index 43f553547..f26d8e5d8 100644
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -68,6 +68,7 @@ public:
void Check_FS_Type(); // Checks the fs type using blkid, does not do anything on MTD / yaffs2 because this crashes on some devices
bool Update_Size(bool Display_Error); // Updates size information
void Recreate_Media_Folder(); // Recreates the /data/media folder
+ bool Flash_Image(string Filename); // Flashes an image to the partition
public:
string Current_File_System; // Current file system
@@ -108,14 +109,15 @@ private:
bool Backup_Dump_Image(string backup_folder); // Backs up using dump_image for MTD memory types
string Get_Restore_File_System(string restore_folder); // Returns the file system that was in place at the time of the backup
bool Restore_Tar(string restore_folder, string Restore_File_System, const unsigned long long *total_restore_size, unsigned long long *already_restored_size); // Restore using tar for file systems
- bool Restore_DD(string restore_folder, const unsigned long long *total_restore_size, unsigned long long *already_restored_size); // Restore using dd for emmc memory types
- bool Restore_Flash_Image(string restore_folder, const unsigned long long *total_restore_size, unsigned long long *already_restored_size); // Restore using flash_image for MTD memory types
+ bool Restore_Image(string restore_folder, const unsigned long long *total_restore_size, unsigned long long *already_restored_size, string Restore_File_System); // Restore using dd for images
bool Get_Size_Via_statfs(bool Display_Error); // Get Partition size, used, and free space using statfs
bool Get_Size_Via_df(bool Display_Error); // Get Partition size, used, and free space using df command
bool Make_Dir(string Path, bool Display_Error); // Creates a directory if it doesn't already exist
bool Find_MTD_Block_Device(string MTD_Name); // Finds the mtd block device based on the name from the fstab
void Recreate_AndSec_Folder(void); // Recreates the .android_secure folder
void Mount_Storage_Retry(void); // Tries multiple times with a half second delay to mount a device in case storage is slow to mount
+ bool Flash_Image_DD(string Filename); // Flashes an image to the partition using dd
+ bool Flash_Image_FI(string Filename); // Flashes an image to the partition using flash_image for mtd nand
private:
bool Can_Be_Mounted; // Indicates that the partition can be mounted
@@ -163,6 +165,7 @@ private:
int Format_Block_Size; // Block size for formatting
bool Ignore_Blkid; // Ignore blkid results due to superblocks lying to us on certain devices / partitions
bool Retain_Layout_Version; // Retains the .layout_version file during a wipe (needed on devices like Sony Xperia T where /data and /data/media are separate partitions)
+ bool Can_Flash_Img; // Indicates if this partition can have images flashed to it via the GUI
friend class TWPartitionManager;
friend class DataManager;
@@ -219,6 +222,7 @@ public:
bool Add_MTP_Storage(unsigned int Storage_ID); // Adds or removes an MTP Storage partition
bool Remove_MTP_Storage(string Mount_Point); // Adds or removes an MTP Storage partition
bool Remove_MTP_Storage(unsigned int Storage_ID); // Adds or removes an MTP Storage partition
+ bool Flash_Image(string Filename); // Flashes an image to a selected partition from the partition list
private:
void Setup_Settings_Storage_Partition(TWPartition* Part); // Sets up settings storage