Adding Edl button in reboot menu

Edl mode is available only on qualcomm devices and it used to fully
restore the bricked devices. I made the button available only if
TW_HAS_EDL_MODE := true like the download button. I set the edl
button to the right of the download button, so devices can support
edl button and download button. I also added the translation for
all languages.

Change-Id: I69d1058b8c050b722395c7b3da6dce1ccfbe7a91
diff --git a/Android.mk b/Android.mk
index df18d7a..12b0769 100755
--- a/Android.mk
+++ b/Android.mk
@@ -281,6 +281,9 @@
 ifeq ($(TW_HAS_DOWNLOAD_MODE), true)
     LOCAL_CFLAGS += -DTW_HAS_DOWNLOAD_MODE
 endif
+ifeq ($(TW_HAS_EDL_MODE), true)
+    LOCAL_CFLAGS += -DTW_HAS_EDL_MODE
+endif
 ifeq ($(TW_NO_SCREEN_BLANK), true)
     LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK
 endif
diff --git a/data.cpp b/data.cpp
index 0ece4e7..cf9dd24 100755
--- a/data.cpp
+++ b/data.cpp
@@ -722,6 +722,10 @@
 	printf("TW_HAS_DOWNLOAD_MODE := true\n");
 	mConst.SetValue(TW_DOWNLOAD_MODE, "1");
 #endif
+#ifdef TW_HAS_EDL_MODE
+	printf("TW_HAS_EDL_MODE := true\n");
+	mConst.SetValue(TW_EDL_MODE, "1");
+#endif
 #ifdef TW_INCLUDE_CRYPTO
 	mConst.SetValue(TW_HAS_CRYPTO, "1");
 	printf("TW_INCLUDE_CRYPTO := true\n");
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index d1bce16..6df8862 100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -2705,6 +2705,25 @@
 				</actions>
 			</button>
 
+			<button style="main_button">
+				<condition var1="tw_edl_mode" var2="1"/>
+				<placement x="%center_x%" y="%row11_y%"/>
+				<text>{@rb_edl_btn=Edl}</text>
+				<actions>
+					<action function="set">tw_back=reboot</action>
+					<action function="set">tw_action=reboot</action>
+					<action function="set">tw_action_param=edl</action>
+					<action function="set">tw_reboot_param=edl</action>
+					<action function="set">tw_has_action2=0</action>
+					<action function="set">tw_text1={@no_os1=No OS Installed! Are you}</action>
+					<action function="set">tw_text2={@no_osrb=sure you wish to reboot?}</action>
+					<action function="set">tw_action_text1={@rebooting=Rebooting...}</action>
+					<action function="set">tw_complete_text1={@rebooting=Rebooting...}</action>
+					<action function="set">tw_slider_text={@swipe_reboot=Swipe to Reboot}</action>
+					<action function="page">rebootcheck</action>
+				</actions>
+			</button>
+
 			<action>
 				<touch key="home"/>
 				<action function="page">main</action>
diff --git a/gui/theme/common/languages/cz.xml b/gui/theme/common/languages/cz.xml
index 4ba5c2c..7f7fc3c 100644
--- a/gui/theme/common/languages/cz.xml
+++ b/gui/theme/common/languages/cz.xml
@@ -262,6 +262,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Stáhnout</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Vypínání...</string>
 		<string name="swipe_power_off">Potáhnout pro vypnutí</string>
 		<string name="swipe_power_off_s">Vypnout</string>
diff --git a/gui/theme/common/languages/de.xml b/gui/theme/common/languages/de.xml
index 6ff8014..56f7ebd 100644
--- a/gui/theme/common/languages/de.xml
+++ b/gui/theme/common/languages/de.xml
@@ -283,6 +283,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Ausschalten...</string>
 		<string name="swipe_power_off">Gerät ausschalten</string>
 		<string name="swipe_power_off_s">Ausschalten</string>
diff --git a/gui/theme/common/languages/el.xml b/gui/theme/common/languages/el.xml
index ffb960f..8ac681d 100644
--- a/gui/theme/common/languages/el.xml
+++ b/gui/theme/common/languages/el.xml
@@ -273,6 +273,7 @@
         <string name="rb_recovery_btn">Recovery</string>
         <string name="rb_bootloader_btn">Bootloader</string>
         <string name="rb_download_btn">Λήψη</string>
+		<string name="rb_edl_btn">Edl</string>
         <string name="turning_off">Απενεργοποίηση...</string>
         <string name="swipe_power_off">Σύρετε για Απενεργοποίηση</string>
         <string name="swipe_power_off_s">Απενεργοποίηση</string>
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index f8de662..e61f6c0 100755
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -288,6 +288,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Turning Off...</string>
 		<string name="swipe_power_off">Swipe to Power Off</string>
 		<string name="swipe_power_off_s">Power Off</string>
diff --git a/gui/theme/common/languages/es.xml b/gui/theme/common/languages/es.xml
index 1f20061..e096e66 100644
--- a/gui/theme/common/languages/es.xml
+++ b/gui/theme/common/languages/es.xml
@@ -263,6 +263,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Descarga</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Apagando...</string>
 		<string name="swipe_power_off">Deslice para Apagar</string>
 		<string name="swipe_power_off_s">Apagar</string>
diff --git a/gui/theme/common/languages/fr.xml b/gui/theme/common/languages/fr.xml
index 61516a8..6ae3298 100644
--- a/gui/theme/common/languages/fr.xml
+++ b/gui/theme/common/languages/fr.xml
@@ -260,6 +260,7 @@
         <string name="rb_recovery_btn">Récupération</string>
         <string name="rb_bootloader_btn">Amorçage</string>
         <string name="rb_download_btn">Télécharger</string>
+		<string name="rb_edl_btn">Edl</string>
         <string name="turning_off">Arrêt en cours...</string>
         <string name="swipe_power_off">Glisser pour éteindre</string>
         <string name="swipe_power_off_s">Éteindre</string>
diff --git a/gui/theme/common/languages/hu.xml b/gui/theme/common/languages/hu.xml
index 6141cde..96557ac 100644
--- a/gui/theme/common/languages/hu.xml
+++ b/gui/theme/common/languages/hu.xml
@@ -283,6 +283,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download mód</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Kikapcsolás...</string>
 		<string name="swipe_power_off">Csúsztasson a kikapcsoláshoz</string>
 		<string name="swipe_power_off_s">Kikapcsolás</string>
diff --git a/gui/theme/common/languages/it.xml b/gui/theme/common/languages/it.xml
index 6d56e80..ec74d59 100644
--- a/gui/theme/common/languages/it.xml
+++ b/gui/theme/common/languages/it.xml
@@ -283,6 +283,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Spegnimento in corso...</string>
 		<string name="swipe_power_off">Scorri per spegnere</string>
 		<string name="swipe_power_off_s">Spegni</string>
diff --git a/gui/theme/common/languages/nl.xml b/gui/theme/common/languages/nl.xml
index f5ec9bb..8dadd40 100644
--- a/gui/theme/common/languages/nl.xml
+++ b/gui/theme/common/languages/nl.xml
@@ -270,6 +270,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Uitschakelen...</string>
 		<string name="swipe_power_off">Veeg om uit te schakelen</string>
 		<string name="swipe_power_off_s">Uitschakelen</string>
diff --git a/gui/theme/common/languages/pl.xml b/gui/theme/common/languages/pl.xml
index a67de06..e337455 100644
--- a/gui/theme/common/languages/pl.xml
+++ b/gui/theme/common/languages/pl.xml
@@ -270,6 +270,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Wyłączanie...</string>
 		<string name="swipe_power_off">Przesuń, aby wyłączyć</string>
 		<string name="swipe_power_off_s">Wyłącz</string>
diff --git a/gui/theme/common/languages/pt_BR.xml b/gui/theme/common/languages/pt_BR.xml
index 88deb0c..f540e4c 100644
--- a/gui/theme/common/languages/pt_BR.xml
+++ b/gui/theme/common/languages/pt_BR.xml
@@ -262,6 +262,7 @@
 		<string name="rb_recovery_btn">Recuperação</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Baixar</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Desligar...</string>
 		<string name="swipe_power_off">Deslize para desligar</string>
 		<string name="swipe_power_off_s">Desligar</string>
diff --git a/gui/theme/common/languages/pt_PT.xml b/gui/theme/common/languages/pt_PT.xml
index 6b5bc6c..40ef41f 100644
--- a/gui/theme/common/languages/pt_PT.xml
+++ b/gui/theme/common/languages/pt_PT.xml
@@ -284,6 +284,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Descarregar</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">A desligar...</string>
 		<string name="swipe_power_off">      Deslize para desligar</string>
 		<string name="swipe_power_off_s">Desligar</string>
diff --git a/gui/theme/common/languages/ru.xml b/gui/theme/common/languages/ru.xml
index ba4d930..95fd371 100644
--- a/gui/theme/common/languages/ru.xml
+++ b/gui/theme/common/languages/ru.xml
@@ -280,6 +280,7 @@
 		<string name="rb_recovery_btn">Рекавери</string>
 		<string name="rb_bootloader_btn">Загрузчик</string>
 		<string name="rb_download_btn">Режим загрузки</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Выключение...</string>
 		<string name="swipe_power_off">Свайп для выключения</string>
 		<string name="swipe_power_off_s">Выключение</string>
diff --git a/gui/theme/common/languages/sk.xml b/gui/theme/common/languages/sk.xml
index b8e2fc5..f4e56ef 100644
--- a/gui/theme/common/languages/sk.xml
+++ b/gui/theme/common/languages/sk.xml
@@ -262,6 +262,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Stiahnuť</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Vypínanie...</string>
 		<string name="swipe_power_off">Potiahnite pre vypnutie</string>
 		<string name="swipe_power_off_s">Vypnúť</string>
diff --git a/gui/theme/common/languages/sl.xml b/gui/theme/common/languages/sl.xml
index 5b0853e..4259e62 100644
--- a/gui/theme/common/languages/sl.xml
+++ b/gui/theme/common/languages/sl.xml
@@ -262,6 +262,7 @@
 		<string name="rb_recovery_btn">Obnovitev</string>
 		<string name="rb_bootloader_btn">Zagonski nalagalnik</string>
 		<string name="rb_download_btn">Prejmi</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Izklapljanje …</string>
 		<string name="swipe_power_off">Povlecite za izklop</string>
 		<string name="swipe_power_off_s">Izklopi</string>
diff --git a/gui/theme/common/languages/sv.xml b/gui/theme/common/languages/sv.xml
index eadc18d..c898957 100644
--- a/gui/theme/common/languages/sv.xml
+++ b/gui/theme/common/languages/sv.xml
@@ -101,6 +101,7 @@
 		<string name="rb_system_btn">System</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Ladda ner</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Stänger av...</string>
 		<string name="settings_hdr">Inställningar</string>
 		<string name="settings_gen_s_hdr">Allmänt</string>
diff --git a/gui/theme/common/languages/tr.xml b/gui/theme/common/languages/tr.xml
index 4c10fdf..8e924cb 100644
--- a/gui/theme/common/languages/tr.xml
+++ b/gui/theme/common/languages/tr.xml
@@ -284,6 +284,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Kapatılıyor...</string>
 		<string name="swipe_power_off">Kapatmak için Kaydır</string>
 		<string name="swipe_power_off_s">Kapat</string>
diff --git a/gui/theme/common/languages/uk.xml b/gui/theme/common/languages/uk.xml
index a3ea7dd..9b267d2 100644
--- a/gui/theme/common/languages/uk.xml
+++ b/gui/theme/common/languages/uk.xml
@@ -266,6 +266,7 @@
 		<string name="rb_recovery_btn">Рекавері</string>
 		<string name="rb_bootloader_btn">Завантажувач</string>
 		<string name="rb_download_btn">Режим завантаження</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">Вимкнення...</string>
 		<string name="swipe_power_off">Вимкнути</string>
 		<string name="swipe_power_off_s">Вимкнення</string>
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index 1cf4d89..c2d32dd 100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -2862,6 +2862,25 @@
 				</actions>
 			</button>
 
+			<button style="main_button">
+				<condition var1="tw_edl_mode" var2="1"/>
+				<placement x="%center_x%" y="%row13a_y%"/>
+				<text>{@rb_edl_btn=Edl}</text>
+				<actions>
+					<action function="set">tw_back=reboot</action>
+					<action function="set">tw_action=reboot</action>
+					<action function="set">tw_action_param=edl</action>
+					<action function="set">tw_reboot_param=edl</action>
+					<action function="set">tw_has_action2=0</action>
+					<action function="set">tw_text1={@no_os1=No OS Installed! Are you}</action>
+					<action function="set">tw_text2={@no_osrb=sure you wish to reboot?}</action>
+					<action function="set">tw_action_text1={@rebooting=Rebooting...}</action>
+					<action function="set">tw_complete_text1={@rebooting=Rebooting...}</action>
+					<action function="set">tw_slider_text={@swipe_reboot=Swipe to Reboot}</action>
+					<action function="page">rebootcheck</action>
+				</actions>
+			</button>
+
 			<text style="text_m">
 				<condition var1="tw_has_boot_slots" var2="1"/>
 				<placement x="%center_x%" y="%row17_y%" placement="5"/>
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index 56bdc55..0c30a34 100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -3359,6 +3359,24 @@
 					<action function="page">rebootcheck</action>
 				</actions>
 			</button>
+			<button style="main_button">
+				<condition var1="tw_edl_mode" var2="1"/>
+				<placement x="%col1_x_right%" y="%row11_y%"/>
+				<text>{@rb_edl_btn=Edl}</text>
+				<actions>
+					<action function="set">tw_back=reboot</action>
+					<action function="set">tw_action=reboot</action>
+					<action function="set">tw_action_param=edl</action>
+					<action function="set">tw_reboot_param=edl</action>
+					<action function="set">tw_has_action2=0</action>
+					<action function="set">tw_text1={@no_os1=No OS Installed! Are you}</action>
+					<action function="set">tw_text2={@no_osrb=sure you wish to reboot?}</action>
+					<action function="set">tw_action_text1={@rebooting=Rebooting...}</action>
+					<action function="set">tw_complete_text1={@rebooting=Rebooting...}</action>
+					<action function="set">tw_slider_text={@swipe_reboot_s=   Reboot}</action>
+					<action function="page">rebootcheck</action>
+				</actions>
+			</button>
 
 			<action>
 				<touch key="home"/>
diff --git a/gui/theme/extra-languages/languages/ja.xml b/gui/theme/extra-languages/languages/ja.xml
index 37d3e7c..977b170 100644
--- a/gui/theme/extra-languages/languages/ja.xml
+++ b/gui/theme/extra-languages/languages/ja.xml
@@ -265,6 +265,7 @@
 		<string name="rb_recovery_btn">リカバリ</string>
 		<string name="rb_bootloader_btn">ブートローダー</string>
 		<string name="rb_download_btn">ダウンロード</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">電源を切っています...</string>
 		<string name="swipe_power_off">スワイプで電源を切る</string>
 		<string name="swipe_power_off_s">電源を切る</string>
diff --git a/gui/theme/extra-languages/languages/zh_CN.xml b/gui/theme/extra-languages/languages/zh_CN.xml
index 5c214a5..944be48 100644
--- a/gui/theme/extra-languages/languages/zh_CN.xml
+++ b/gui/theme/extra-languages/languages/zh_CN.xml
@@ -283,6 +283,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">正在关机…</string>
 		<string name="swipe_power_off">滑动按钮确认关机</string>
 		<string name="swipe_power_off_s">关机</string>
diff --git a/gui/theme/extra-languages/languages/zh_TW.xml b/gui/theme/extra-languages/languages/zh_TW.xml
index 75c717a..fc80862 100644
--- a/gui/theme/extra-languages/languages/zh_TW.xml
+++ b/gui/theme/extra-languages/languages/zh_TW.xml
@@ -283,6 +283,7 @@
 		<string name="rb_recovery_btn">Recovery</string>
 		<string name="rb_bootloader_btn">Bootloader</string>
 		<string name="rb_download_btn">Download</string>
+		<string name="rb_edl_btn">Edl</string>
 		<string name="turning_off">正在關機…</string>
 		<string name="swipe_power_off">滑動按鈕確認關機</string>
 		<string name="swipe_power_off_s">關機</string>
diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp
index d4d4da5..9478cd7 100755
--- a/openrecoveryscript.cpp
+++ b/openrecoveryscript.cpp
@@ -343,6 +343,8 @@
 					TWFunc::tw_reboot(rb_bootloader);
 				else if (strlen(value) && strcmp(value, "download") == 0)
 					TWFunc::tw_reboot(rb_download);
+				else if (strlen(value) && strcmp(value, "edl") == 0)
+					TWFunc::tw_reboot(rb_edl);
 				else
 					TWFunc::tw_reboot(rb_system);
 			} else if (strcmp(command, "cmd") == 0) {
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 37dd0df..ff34828 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -626,6 +626,13 @@
 #else
 			return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "download");
 #endif
+		case rb_edl:
+			check_and_run_script("/sbin/rebootedl.sh", "reboot edl");
+#ifdef ANDROID_RB_PROPERTY
+			return property_set(ANDROID_RB_PROPERTY, "reboot,edl");
+#else
+			return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "edl");
+#endif
 		default:
 			return -1;
 	}
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 7847aed..efaa460 100755
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -37,6 +37,7 @@
 	rb_poweroff,
 	rb_bootloader,     // May also be fastboot
 	rb_download,
+	rb_edl,
 } RebootCommand;
 
 enum Archive_Type {
diff --git a/twrp.cpp b/twrp.cpp
index 6b9cd75..95e376b 100755
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -345,6 +345,8 @@
 		TWFunc::tw_reboot(rb_bootloader);
 	else if (Reboot_Arg == "download")
 		TWFunc::tw_reboot(rb_download);
+	else if (Reboot_Arg == "edl")
+		TWFunc::tw_reboot(rb_edl);
 	else
 		TWFunc::tw_reboot(rb_system);
 
diff --git a/variables.h b/variables.h
index 22eb5c9..3b61432 100644
--- a/variables.h
+++ b/variables.h
@@ -129,6 +129,7 @@
 #define TW_MIN_SYSTEM_SIZE          "50" // minimum system size to allow a reboot
 #define TW_MIN_SYSTEM_VAR           "tw_min_system"
 #define TW_DOWNLOAD_MODE            "tw_download_mode"
+#define TW_EDL_MODE                 "tw_edl_mode"
 #define TW_IS_ENCRYPTED             "tw_is_encrypted"
 #define TW_IS_DECRYPTED             "tw_is_decrypted"
 #define TW_CRYPTO_PWTYPE            "tw_crypto_pwtype"