Merge "Disable the sandbox when running with `--console`." am: 39693038f5 am: d20b371d5b am: b3b3be3b73

Original change: https://android-review.googlesource.com/c/device/google/cuttlefish/+/1456145

Change-Id: Ib76aa9957a1a5d6cd96dcb162448789dd6929fb1
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index fd3fe8a..63f462d 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -400,9 +400,8 @@
   // Sepolicy rules need to be updated to support gpu mode. Temporarily disable
   // auto-enabling sandbox when gpu is enabled (b/152323505).
   if (tmp_config_obj.gpu_mode() != cuttlefish::kGpuModeGuestSwiftshader) {
-    tmp_config_obj.set_enable_sandbox(false);
-  } else {
-    tmp_config_obj.set_enable_sandbox(FLAGS_enable_sandbox);
+    SetCommandLineOptionWithMode("enable_sandbox", "false",
+                                 google::FlagSettingMode::SET_FLAGS_DEFAULT);
   }
 
   if (vmm->ConfigureGpuMode(tmp_config_obj.gpu_mode()).empty()) {
@@ -467,6 +466,11 @@
   tmp_config_obj.set_guest_force_normal_boot(FLAGS_guest_force_normal_boot);
   tmp_config_obj.set_extra_kernel_cmdline(FLAGS_extra_kernel_cmdline);
 
+  if (FLAGS_console) {
+    SetCommandLineOptionWithMode("enable_sandbox", "false",
+                                 google::FlagSettingMode::SET_FLAGS_DEFAULT);
+  }
+
   tmp_config_obj.set_console(FLAGS_console);
   tmp_config_obj.set_kgdb(FLAGS_console && FLAGS_kgdb);
 
@@ -662,6 +666,8 @@
     instance.set_modem_simulator_ports(modem_simulator_ports);
   }
 
+  tmp_config_obj.set_enable_sandbox(FLAGS_enable_sandbox);
+
   return tmp_config_obj;
 }