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
diff --git a/install/install.cpp b/install/install.cpp
index 3d44f97..a562b5b 100644
--- a/install/install.cpp
+++ b/install/install.cpp
@@ -621,7 +621,7 @@
   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 dd5d36a..9ca70b7 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -979,6 +979,7 @@
     if (!sideload_auto_reboot) {
       ui->ShowText(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 c55044d..1ed0a4e 100644
--- a/recovery_ui/include/recovery_ui/ui.h
+++ b/recovery_ui/include/recovery_ui/ui.h
@@ -301,6 +301,14 @@
     EnqueueKey(KEY_REFRESH);
   }
 
+  bool IsSideloadAutoReboot() const {
+    return sideload_auto_reboot_;
+  }
+
+  void SetSideloadAutoReboot(bool sar) {
+    sideload_auto_reboot_ = sar;
+  }
+
  protected:
   void EnqueueKey(int key_code);
   void EnqueueTouch(const Point& pos);
@@ -318,6 +326,8 @@
 
   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 4913275..8656729 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -70,6 +70,7 @@
                                                       DEFAULT_MAX_BRIGHTNESS_FILE)),
       touch_screen_allowed_(true),
       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",