From 9002606988ab4636e3da56a6e1ecc8ee357b8cea Mon Sep 17 00:00:00 2001 From: Joseph Annareddy Date: Wed, 16 Aug 2023 12:04:56 -0400 Subject: [PATCH] recovery: Bypass reboot prompt for sideload-auto-reboot When we want to automatically reboot after a sideload, it doesn't make much sense to try and prompt the user for a reboot into recovery. Change-Id: Id0195965362b62bf940caba1f83ffe12191a73c6 --- install/install.cpp | 2 +- recovery.cpp | 1 + recovery_ui/include/recovery_ui/ui.h | 10 ++++++++++ recovery_ui/ui.cpp | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/install/install.cpp b/install/install.cpp index f4486c5d..c0151ca4 100644 --- a/install/install.cpp +++ b/install/install.cpp @@ -622,7 +622,7 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache, if (package_is_ab) { ab_package_installed = true; PerformPowerwashIfRequired(zip, device); - if (ask_to_ab_reboot(device)) { + if (!ui->IsSideloadAutoReboot() && ask_to_ab_reboot(device)) { reboot_to_recovery(); } } diff --git a/recovery.cpp b/recovery.cpp index c65375ec..e212e83e 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -858,6 +858,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vectorShowText(true); } + ui->SetSideloadAutoReboot(sideload_auto_reboot); status = ApplyFromAdb(device, false /* rescue_mode */, &next_action); ui->Print("\nInstall from ADB complete (status: %d).\n", status); if (sideload_auto_reboot) { diff --git a/recovery_ui/include/recovery_ui/ui.h b/recovery_ui/include/recovery_ui/ui.h index c3bb03f3..140461c7 100644 --- a/recovery_ui/include/recovery_ui/ui.h +++ b/recovery_ui/include/recovery_ui/ui.h @@ -198,6 +198,14 @@ class RecoveryUI { virtual bool IsUsbConnected(); + bool IsSideloadAutoReboot() const { + return sideload_auto_reboot_; + } + + void SetSideloadAutoReboot(bool sar) { + sideload_auto_reboot_ = sar; + } + protected: void EnqueueKey(int key_code); @@ -214,6 +222,8 @@ class RecoveryUI { bool fastbootd_logo_enabled_; + bool sideload_auto_reboot_; + private: enum class ScreensaverState { DISABLED, diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp index 9b0fd94c..092ba2b5 100644 --- a/recovery_ui/ui.cpp +++ b/recovery_ui/ui.cpp @@ -69,6 +69,7 @@ RecoveryUI::RecoveryUI() DEFAULT_MAX_BRIGHTNESS_FILE)), touch_screen_allowed_(false), fastbootd_logo_enabled_(false), + sideload_auto_reboot_(false), touch_low_threshold_(android::base::GetIntProperty("ro.recovery.ui.touch_low_threshold", kDefaultTouchLowThreshold)), touch_high_threshold_(android::base::GetIntProperty("ro.recovery.ui.touch_high_threshold",