Allow entering rescue mode via recovery UI.

Only enabled on debuggable builds.

Bug: 128415917
Test: Sideload package on taimen.
Test: Choose "Enter rescue" from recovery UI.
Change-Id: I913dbdbcffd3179e6fa72ca862f74ca8f1364b02
diff --git a/recovery.cpp b/recovery.cpp
index 0e6e497..ce29cb2 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -538,12 +538,20 @@
         break;
       }
       case Device::APPLY_ADB_SIDELOAD:
-      case Device::APPLY_SDCARD: {
+      case Device::APPLY_SDCARD:
+      case Device::ENTER_RESCUE: {
         save_current_log = true;
-        bool adb = (chosen_action == Device::APPLY_ADB_SIDELOAD);
-        if (adb) {
-          status = apply_from_adb(ui);
+
+        bool adb = true;
+        if (chosen_action == Device::ENTER_RESCUE) {
+          // Switch to graphics screen.
+          ui->ShowText(false);
+          status = ApplyFromAdb(ui, true /* rescue_mode */);
+          ui->ShowText(true);
+        } else if (chosen_action == Device::APPLY_ADB_SIDELOAD) {
+          status = ApplyFromAdb(ui, false /* rescue_mode */);
         } else {
+          adb = false;
           status = ApplyFromSdcard(device, ui);
         }
 
@@ -926,7 +934,7 @@
     if (!sideload_auto_reboot) {
       ui->ShowText(true);
     }
-    status = apply_from_adb(ui);
+    status = ApplyFromAdb(ui, false /* rescue_mode */);
     ui->Print("\nInstall from ADB complete (status: %d).\n", status);
     if (sideload_auto_reboot) {
       ui->Print("Rebooting automatically.\n");