From d15e3f7def317314f9110895903ae2733f60a0be Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Thu, 21 Feb 2013 14:28:29 -0600 Subject: Move removal of stock recovery to shutdown sequence --- recovery.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index 8969ebc6e..a01ca8c11 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -955,30 +955,30 @@ main(int argc, char **argv) { } } - //if (status != INSTALL_SUCCESS) ui->SetBackground(RecoveryUI::ERROR); - if (1) { - finish_recovery(NULL); - if (PartitionManager.Mount_By_Path("/system", false) && TWFunc::Path_Exists("/system/recovery-from-boot.p")) { - rename("/system/recovery-from-boot.p", "/system/recovery-from-boot.bak"); - ui_print("Renamed stock recovery file in /system to prevent\nthe stock ROM from replacing TWRP.\n"); - } - PartitionManager.UnMount_By_Path("/system", false); - if (DataManager_GetIntValue(TW_IS_ENCRYPTED) != 0) { - LOGI("Is encrypted, do decrypt page first\n"); - if (gui_startPage("decrypt") != 0) { - LOGE("Failed to start decrypt GUI page.\n"); - } - } - DataManager_ReadSettingsFile(); - if (DataManager_GetIntValue(TW_IS_ENCRYPTED) == 0 && (TWFunc::Path_Exists(SCRIPT_FILE_TMP) || TWFunc::Path_Exists(SCRIPT_FILE_CACHE))) { - OpenRecoveryScript::Run_OpenRecoveryScript(); + finish_recovery(NULL); + // Offer to decrypt if the device is encrypted + if (DataManager_GetIntValue(TW_IS_ENCRYPTED) != 0) { + LOGI("Is encrypted, do decrypt page first\n"); + if (gui_startPage("decrypt") != 0) { + LOGE("Failed to start decrypt GUI page.\n"); } - gui_start(); - //prompt_and_wait(device); - } + } + // Read the settings file + DataManager_ReadSettingsFile(); + // Run any outstanding OpenRecoveryScript + if (DataManager_GetIntValue(TW_IS_ENCRYPTED) == 0 && (TWFunc::Path_Exists(SCRIPT_FILE_TMP) || TWFunc::Path_Exists(SCRIPT_FILE_CACHE))) { + OpenRecoveryScript::Run_OpenRecoveryScript(); + } + // Launch the main GUI + gui_start(); // 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"); + ui_print("Renamed stock recovery file in /system to prevent\nthe stock ROM from replacing TWRP.\n"); + } if (TWFunc::Path_Exists("/res/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_SetIntValue("tw_busy", 1); @@ -992,6 +992,8 @@ main(int argc, char **argv) { LOGE("Failed to start decrypt GUI page.\n"); } } + sync(); + PartitionManager.UnMount_By_Path("/system", false); } // Otherwise, get ready to boot the main system... -- cgit v1.2.3