From c1fb553b53ff08a7db0d4fd68a7726da75a5b4d4 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Fri, 4 Aug 2023 22:09:53 +0200 Subject: [PATCH] recovery: Clear BCB before rebooting to recovery This should clear update_in_progress flag. Change-Id: Idc5b99a77d6f1368fa37cf664a1fb5b6b19886db --- install/install.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/install/install.cpp b/install/install.cpp index c6f5c4a0..be1b4a87 100644 --- a/install/install.cpp +++ b/install/install.cpp @@ -46,6 +46,7 @@ #include #include +#include "bootloader_message/bootloader_message.h" #include "install/snapshot_utils.h" #include "install/spl_check.h" #include "install/wipe_data.h" @@ -419,10 +420,17 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache, return INSTALL_ERROR; }*/ + const auto reboot_to_recovery = [] { + if (std::string err; !clear_bootloader_message(&err)) { + LOG(ERROR) << "Failed to clear BCB message: " << err; + } + Reboot("userrequested,recovery,ui"); + }; + static bool ab_package_installed = false; if (ab_package_installed) { if (ask_to_ab_reboot(device)) { - Reboot("userrequested,recovery,ui"); + reboot_to_recovery(); } return INSTALL_ERROR; } @@ -615,7 +623,7 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache, ab_package_installed = true; PerformPowerwashIfRequired(zip, device); if (ask_to_ab_reboot(device)) { - Reboot("userrequested,recovery,ui"); + reboot_to_recovery(); } }