Add a command-line option to change the boot slot.

If no slot is specified, it is hardcoded to "_a". This will be removed
when Cuttlefish has true A/B support and can read the correct slot from
the misc partition.

Bug: 140527427
Test: launch_cvd -boot_slot
Change-Id: I6c76fbdbd46d342c35e246e44a98222488e0e901
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index c5a8c36..6de4abd 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -206,6 +206,10 @@
              "The vsock port for tombstones");
 DEFINE_bool(use_bootloader, false, "Boots the device using a bootloader");
 DEFINE_string(bootloader, "", "Bootloader binary path");
+DEFINE_string(boot_slot, "", "Force booting into the given slot. If empty, "
+             "the slot will be chosen based on the misc partition if using a "
+             "bootloader. It will default to 'a' if empty and not using a "
+             "bootloader.");
 
 namespace {
 
@@ -505,6 +509,20 @@
   tmp_config_obj.set_use_bootloader(FLAGS_use_bootloader);
   tmp_config_obj.set_bootloader(FLAGS_bootloader);
 
+  if (!FLAGS_boot_slot.empty()) {
+      tmp_config_obj.set_boot_slot(FLAGS_boot_slot);
+  }
+
+  if (!FLAGS_use_bootloader) {
+    std::string slot_suffix;
+    if (FLAGS_boot_slot.empty()) {
+      slot_suffix = "_a";
+    } else {
+      slot_suffix = "_" + FLAGS_boot_slot;
+    }
+    tmp_config_obj.add_kernel_cmdline("androidboot.slot_suffix=" + slot_suffix);
+  }
+
   tmp_config_obj.set_cuttlefish_env_path(GetCuttlefishEnvPath());
 
   auto config_file = GetConfigFilePath(tmp_config_obj);