Adds device_title to config file.

The intended use is for the vnc_server to read this and use it as its
server name. Its purpose can vary if there are additional needs.

Test: local launch_cvd
Bug: 111928072
Change-Id: I694de9cc40c0daeea87557fb1ef8ca919f757374
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index f3bc1e0..816a984 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -163,6 +163,9 @@
             "Run cuttlefish in background, the launcher exits on boot "
             "completed/failed");
 
+DEFINE_string(device_title, "", "Human readable name for the instance, "
+              "used by the vnc_server for its server title");
+
 DECLARE_string(config_file);
 
 namespace {
@@ -501,6 +504,7 @@
   config->set_refresh_rate_hz(FLAGS_refresh_rate_hz);
   config->set_gdb_flag(FLAGS_qemu_gdb);
   config->set_adb_mode(FLAGS_adb_mode);
+  config->set_device_title(FLAGS_device_title);
   if (FLAGS_kernel_path.size()) {
     config->set_kernel_image_path(FLAGS_kernel_path);
   } else {
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index be18bce..99411d9 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -31,8 +31,7 @@
 #include "common/libs/utils/environment.h"
 #include "common/libs/utils/files.h"
 
-DEFINE_string(config_file,
-              vsoc::GetGlobalConfigFileLink(),
+DEFINE_string(config_file, vsoc::GetGlobalConfigFileLink(),
               "A file from where to load the config values. This flag is "
               "ignored by the launcher");
 
@@ -69,6 +68,7 @@
 const char* kSerialNumber = "serial_number";
 const char* kInstanceDir = "instance_dir";
 const char* kVmManager = "vm_manager";
+const char* kDeviceTitle = "device_title";
 
 const char* kCpus = "cpus";
 const char* kMemoryMb = "memory_mb";
@@ -130,7 +130,7 @@
   return (*dictionary_)[kVmManager].asString();
 }
 void CuttlefishConfig::set_vm_manager(const std::string& name) {
-    (*dictionary_)[kVmManager] = name;
+  (*dictionary_)[kVmManager] = name;
 }
 
 std::string CuttlefishConfig::serial_number() const {
@@ -186,8 +186,7 @@
   return (*dictionary_)[kGdbFlag].asString();
 }
 
-void CuttlefishConfig::set_gdb_flag(
-    const std::string& device) {
+void CuttlefishConfig::set_gdb_flag(const std::string& device) {
   SetPath(kGdbFlag, device);
 }
 
@@ -425,6 +424,14 @@
   (*dictionary_)[kAdbMode] = mode;
 }
 
+std::string CuttlefishConfig::device_title() const {
+  return (*dictionary_)[kDeviceTitle].asString();
+}
+
+void CuttlefishConfig::set_device_title(const std::string& title) {
+  (*dictionary_)[kDeviceTitle] = title;
+}
+
 // Creates the (initially empty) config object and populates it with values from
 // the config file if the --config_file command line argument is present.
 // Returns nullptr if there was an error loading from file
@@ -526,7 +533,7 @@
 
 std::string DefaultGuestImagePath(const std::string& file_name) {
   return (cvd::StringFromEnv("ANDROID_PRODUCT_OUT",
-                        cvd::StringFromEnv("HOME", ".")) +
+                             cvd::StringFromEnv("HOME", ".")) +
           "/") +
          file_name;
 }
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index 180e760..c898fe7 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -179,6 +179,9 @@
   void set_adb_mode(const std::string& mode);
   std::string adb_mode() const;
 
+  void set_device_title(const std::string& title);
+  std::string device_title() const;
+
  private:
   std::unique_ptr<Json::Value> dictionary_;