Disable stock recovery replacing TWRP during ORS
-Create a separate function to disable stock recovery flashing
-Add a call to that function to the reboot section of the ORS
action so that an OTA update will not inadvertantly replace TWRP
Change-Id: I43eae81e0e76971b6e8d34c38785dc73772242d2
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index f5bf1b0..55f795c 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -864,7 +864,7 @@
}
- 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 @@
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