summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--gui/action.cpp2
-rw-r--r--twrp-functions.cpp14
-rw-r--r--twrp-functions.hpp2
-rw-r--r--twrp.cpp7
4 files changed, 18 insertions, 7 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index 2aa03a637..aa81dff16 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -1555,6 +1555,8 @@ int GUIAction::openrecoveryscript(std::string arg)
}
}
if (reboot) {
+ // Disable stock recovery reflashing
+ TWFunc::Disable_Stock_Recovery_Replace();
usleep(2000000); // Sleep for 2 seconds before rebooting
TWFunc::tw_reboot(rb_system);
} else {
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index f5bf1b0f0..55f795c6f 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -864,7 +864,7 @@ void TWFunc::Fixup_Time_On_Boot()
}
- LOGINFO("TWFunc::Fixup_Time: will attempt to use the ats files now.\n", sepoch.c_str());
+ LOGINFO("TWFunc::Fixup_Time: will attempt to use the ats files now.\n");
// Devices with Qualcomm Snapdragon 800 do some shenanigans with RTC.
// They never set it, it just ticks forward from 1970-01-01 00:00,
@@ -1038,4 +1038,16 @@ std::string TWFunc::to_string(unsigned long value) {
return os.str();
}
+void TWFunc::Disable_Stock_Recovery_Replace(void) {
+ if (PartitionManager.Mount_By_Path("/system", false)) {
+ // Disable flashing of stock recovery
+ if (TWFunc::Path_Exists("/system/recovery-from-boot.p")) {
+ rename("/system/recovery-from-boot.p", "/system/recovery-from-boot.bak");
+ gui_print("Renamed stock recovery file in /system to prevent\nthe stock ROM from replacing TWRP.\n");
+ sync();
+ }
+ PartitionManager.UnMount_By_Path("/system", false);
+ }
+}
+
#endif // ndef BUILD_TWRPTAR_MAIN
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index c10a184e6..d49cd8499 100644
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -83,8 +83,8 @@ public:
static int Set_Brightness(std::string brightness_value); // Well, you can read, it does what it says, passing return int from TWFunc::Write_File ;)
static bool Toggle_MTP(bool enable); // Disables MTP if enable is false and re-enables MTP if enable is true and it was enabled the last time it was toggled off
static std::string to_string(unsigned long value); //convert ul to string
-
static void SetPerformanceMode(bool mode); // support recovery.perf.mode
+ static void Disable_Stock_Recovery_Replace(); // Disable stock ROMs from replacing TWRP with stock recovery
private:
static void Copy_Log(string Source, string Destination);
diff --git a/twrp.cpp b/twrp.cpp
index 4a8b1fbf1..ef694bf24 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -337,13 +337,10 @@ int main(int argc, char **argv) {
// Launch the main GUI
gui_start();
+ // Disable flashing of stock recovery
+ TWFunc::Disable_Stock_Recovery_Replace();
// Check for su to see if the device is rooted or not
if (PartitionManager.Mount_By_Path("/system", false)) {
- // Disable flashing of stock recovery
- if (TWFunc::Path_Exists("/system/recovery-from-boot.p")) {
- rename("/system/recovery-from-boot.p", "/system/recovery-from-boot.bak");
- gui_print("Renamed stock recovery file in /system to prevent\nthe stock ROM from replacing TWRP.\n");
- }
if (TWFunc::Path_Exists("/supersu/su") && !TWFunc::Path_Exists("/system/bin/su") && !TWFunc::Path_Exists("/system/xbin/su") && !TWFunc::Path_Exists("/system/bin/.ext/.su")) {
// Device doesn't have su installed
DataManager::SetValue("tw_busy", 1);