1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "host/libs/config/cuttlefish_config.h" 18 19 #include <android-base/logging.h> 20 #include <json/json.h> 21 22 #include "common/libs/utils/files.h" 23 24 namespace cuttlefish { 25 namespace { 26 27 const char* kInstances = "instances"; 28 IdToName(const std::string & id)29std::string IdToName(const std::string& id) { return kCvdNamePrefix + id; } 30 31 } // namespace 32 33 static constexpr char kInstanceDir[] = "instance_dir"; MutableInstanceSpecific(CuttlefishConfig * config,const std::string & id)34CuttlefishConfig::MutableInstanceSpecific::MutableInstanceSpecific( 35 CuttlefishConfig* config, const std::string& id) 36 : config_(config), id_(id) { 37 // Legacy for acloud 38 (*Dictionary())[kInstanceDir] = config_->InstancesPath(IdToName(id)); 39 } 40 Dictionary()41Json::Value* CuttlefishConfig::MutableInstanceSpecific::Dictionary() { 42 return &(*config_->dictionary_)[kInstances][id_]; 43 } 44 Dictionary() const45const Json::Value* CuttlefishConfig::InstanceSpecific::Dictionary() const { 46 return &(*config_->dictionary_)[kInstances][id_]; 47 } 48 instance_dir() const49std::string CuttlefishConfig::InstanceSpecific::instance_dir() const { 50 return config_->InstancesPath(IdToName(id_)); 51 } 52 instance_internal_dir() const53std::string CuttlefishConfig::InstanceSpecific::instance_internal_dir() const { 54 return PerInstancePath(kInternalDirName); 55 } 56 57 static constexpr char kSerialNumber[] = "serial_number"; serial_number() const58std::string CuttlefishConfig::InstanceSpecific::serial_number() const { 59 return (*Dictionary())[kSerialNumber].asString(); 60 } set_serial_number(const std::string & serial_number)61void CuttlefishConfig::MutableInstanceSpecific::set_serial_number( 62 const std::string& serial_number) { 63 (*Dictionary())[kSerialNumber] = serial_number; 64 } 65 66 static constexpr char kVirtualDiskPaths[] = "virtual_disk_paths"; virtual_disk_paths() const67std::vector<std::string> CuttlefishConfig::InstanceSpecific::virtual_disk_paths() const { 68 std::vector<std::string> virtual_disks; 69 auto virtual_disks_json_obj = (*Dictionary())[kVirtualDiskPaths]; 70 for (const auto& disk : virtual_disks_json_obj) { 71 virtual_disks.push_back(disk.asString()); 72 } 73 return virtual_disks; 74 } set_virtual_disk_paths(const std::vector<std::string> & virtual_disk_paths)75void CuttlefishConfig::MutableInstanceSpecific::set_virtual_disk_paths( 76 const std::vector<std::string>& virtual_disk_paths) { 77 Json::Value virtual_disks_json_obj(Json::arrayValue); 78 for (const auto& arg : virtual_disk_paths) { 79 virtual_disks_json_obj.append(arg); 80 } 81 (*Dictionary())[kVirtualDiskPaths] = virtual_disks_json_obj; 82 } 83 kernel_log_pipe_name() const84std::string CuttlefishConfig::InstanceSpecific::kernel_log_pipe_name() const { 85 return AbsolutePath(PerInstanceInternalPath("kernel-log-pipe")); 86 } 87 console_pipe_prefix() const88std::string CuttlefishConfig::InstanceSpecific::console_pipe_prefix() const { 89 return AbsolutePath(PerInstanceInternalPath("console")); 90 } 91 console_in_pipe_name() const92std::string CuttlefishConfig::InstanceSpecific::console_in_pipe_name() const { 93 return console_pipe_prefix() + ".in"; 94 } 95 console_out_pipe_name() const96std::string CuttlefishConfig::InstanceSpecific::console_out_pipe_name() const { 97 return console_pipe_prefix() + ".out"; 98 } 99 gnss_pipe_prefix() const100std::string CuttlefishConfig::InstanceSpecific::gnss_pipe_prefix() const { 101 return AbsolutePath(PerInstanceInternalPath("gnss")); 102 } 103 gnss_in_pipe_name() const104std::string CuttlefishConfig::InstanceSpecific::gnss_in_pipe_name() const { 105 return gnss_pipe_prefix() + ".in"; 106 } 107 gnss_out_pipe_name() const108std::string CuttlefishConfig::InstanceSpecific::gnss_out_pipe_name() const { 109 return gnss_pipe_prefix() + ".out"; 110 } 111 112 static constexpr char kGnssGrpcProxyServerPort[] = 113 "gnss_grpc_proxy_server_port"; gnss_grpc_proxy_server_port() const114int CuttlefishConfig::InstanceSpecific::gnss_grpc_proxy_server_port() const { 115 return (*Dictionary())[kGnssGrpcProxyServerPort].asInt(); 116 } set_gnss_grpc_proxy_server_port(int gnss_grpc_proxy_server_port)117void CuttlefishConfig::MutableInstanceSpecific::set_gnss_grpc_proxy_server_port( 118 int gnss_grpc_proxy_server_port) { 119 (*Dictionary())[kGnssGrpcProxyServerPort] = gnss_grpc_proxy_server_port; 120 } 121 122 static constexpr char kGnssFilePath[] = "gnss_file_path"; gnss_file_path() const123std::string CuttlefishConfig::InstanceSpecific::gnss_file_path() const { 124 return (*Dictionary())[kGnssFilePath].asString(); 125 } set_gnss_file_path(const std::string & gnss_file_path)126void CuttlefishConfig::MutableInstanceSpecific::set_gnss_file_path( 127 const std::string& gnss_file_path) { 128 (*Dictionary())[kGnssFilePath] = gnss_file_path; 129 } 130 logcat_pipe_name() const131std::string CuttlefishConfig::InstanceSpecific::logcat_pipe_name() const { 132 return AbsolutePath(PerInstanceInternalPath("logcat-pipe")); 133 } 134 access_kregistry_path() const135std::string CuttlefishConfig::InstanceSpecific::access_kregistry_path() const { 136 return AbsolutePath(PerInstancePath("access-kregistry")); 137 } 138 hwcomposer_pmem_path() const139std::string CuttlefishConfig::InstanceSpecific::hwcomposer_pmem_path() const { 140 return AbsolutePath(PerInstancePath("hwcomposer-pmem")); 141 } 142 pstore_path() const143std::string CuttlefishConfig::InstanceSpecific::pstore_path() const { 144 return AbsolutePath(PerInstancePath("pstore")); 145 } 146 console_path() const147std::string CuttlefishConfig::InstanceSpecific::console_path() const { 148 return AbsolutePath(PerInstancePath("console")); 149 } 150 logcat_path() const151std::string CuttlefishConfig::InstanceSpecific::logcat_path() const { 152 return AbsolutePath(PerInstanceLogPath("logcat")); 153 } 154 launcher_monitor_socket_path() const155std::string CuttlefishConfig::InstanceSpecific::launcher_monitor_socket_path() 156 const { 157 return AbsolutePath(PerInstancePath("launcher_monitor.sock")); 158 } 159 160 static constexpr char kModemSimulatorPorts[] = "modem_simulator_ports"; modem_simulator_ports() const161std::string CuttlefishConfig::InstanceSpecific::modem_simulator_ports() const { 162 return (*Dictionary())[kModemSimulatorPorts].asString(); 163 } set_modem_simulator_ports(const std::string & modem_simulator_ports)164void CuttlefishConfig::MutableInstanceSpecific::set_modem_simulator_ports( 165 const std::string& modem_simulator_ports) { 166 (*Dictionary())[kModemSimulatorPorts] = modem_simulator_ports; 167 } 168 launcher_log_path() const169std::string CuttlefishConfig::InstanceSpecific::launcher_log_path() const { 170 return AbsolutePath(PerInstanceLogPath("launcher.log")); 171 } 172 sdcard_path() const173std::string CuttlefishConfig::InstanceSpecific::sdcard_path() const { 174 return AbsolutePath(PerInstancePath("sdcard.img")); 175 } 176 persistent_composite_disk_path() const177std::string CuttlefishConfig::InstanceSpecific::persistent_composite_disk_path() 178 const { 179 return AbsolutePath(PerInstancePath("persistent_composite.img")); 180 } 181 vbmeta_path() const182std::string CuttlefishConfig::InstanceSpecific::vbmeta_path() const { 183 return AbsolutePath(PerInstancePath("vbmeta.img")); 184 } 185 uboot_env_image_path() const186std::string CuttlefishConfig::InstanceSpecific::uboot_env_image_path() const { 187 return AbsolutePath(PerInstancePath("uboot_env.img")); 188 } 189 190 static constexpr char kMobileBridgeName[] = "mobile_bridge_name"; 191 audio_server_path() const192std::string CuttlefishConfig::InstanceSpecific::audio_server_path() const { 193 return AbsolutePath(PerInstanceInternalPath("audio_server.sock")); 194 } 195 mobile_bridge_name() const196std::string CuttlefishConfig::InstanceSpecific::mobile_bridge_name() const { 197 return (*Dictionary())[kMobileBridgeName].asString(); 198 } set_mobile_bridge_name(const std::string & mobile_bridge_name)199void CuttlefishConfig::MutableInstanceSpecific::set_mobile_bridge_name( 200 const std::string& mobile_bridge_name) { 201 (*Dictionary())[kMobileBridgeName] = mobile_bridge_name; 202 } 203 204 static constexpr char kMobileTapName[] = "mobile_tap_name"; mobile_tap_name() const205std::string CuttlefishConfig::InstanceSpecific::mobile_tap_name() const { 206 return (*Dictionary())[kMobileTapName].asString(); 207 } set_mobile_tap_name(const std::string & mobile_tap_name)208void CuttlefishConfig::MutableInstanceSpecific::set_mobile_tap_name( 209 const std::string& mobile_tap_name) { 210 (*Dictionary())[kMobileTapName] = mobile_tap_name; 211 } 212 213 static constexpr char kConfUiHostPort[] = "confirmation_ui_host_port"; confui_host_vsock_port() const214int CuttlefishConfig::InstanceSpecific::confui_host_vsock_port() const { 215 return (*Dictionary())[kConfUiHostPort].asInt(); 216 } 217 set_confui_host_vsock_port(int port)218void CuttlefishConfig::MutableInstanceSpecific::set_confui_host_vsock_port( 219 int port) { 220 (*Dictionary())[kConfUiHostPort] = port; 221 } 222 223 static constexpr char kWifiTapName[] = "wifi_tap_name"; wifi_tap_name() const224std::string CuttlefishConfig::InstanceSpecific::wifi_tap_name() const { 225 return (*Dictionary())[kWifiTapName].asString(); 226 } set_wifi_tap_name(const std::string & wifi_tap_name)227void CuttlefishConfig::MutableInstanceSpecific::set_wifi_tap_name( 228 const std::string& wifi_tap_name) { 229 (*Dictionary())[kWifiTapName] = wifi_tap_name; 230 } 231 232 static constexpr char kEthernetTapName[] = "ethernet_tap_name"; ethernet_tap_name() const233std::string CuttlefishConfig::InstanceSpecific::ethernet_tap_name() const { 234 return (*Dictionary())[kEthernetTapName].asString(); 235 } set_ethernet_tap_name(const std::string & ethernet_tap_name)236void CuttlefishConfig::MutableInstanceSpecific::set_ethernet_tap_name( 237 const std::string& ethernet_tap_name) { 238 (*Dictionary())[kEthernetTapName] = ethernet_tap_name; 239 } 240 241 static constexpr char kUseAllocd[] = "use_allocd"; use_allocd() const242bool CuttlefishConfig::InstanceSpecific::use_allocd() const { 243 return (*Dictionary())[kUseAllocd].asBool(); 244 } set_use_allocd(bool use_allocd)245void CuttlefishConfig::MutableInstanceSpecific::set_use_allocd( 246 bool use_allocd) { 247 (*Dictionary())[kUseAllocd] = use_allocd; 248 } 249 250 static constexpr char kSessionId[] = "session_id"; session_id() const251uint32_t CuttlefishConfig::InstanceSpecific::session_id() const { 252 return (*Dictionary())[kSessionId].asUInt(); 253 } set_session_id(uint32_t session_id)254void CuttlefishConfig::MutableInstanceSpecific::set_session_id( 255 uint32_t session_id) { 256 (*Dictionary())[kSessionId] = session_id; 257 } 258 259 static constexpr char kVsockGuestCid[] = "vsock_guest_cid"; vsock_guest_cid() const260int CuttlefishConfig::InstanceSpecific::vsock_guest_cid() const { 261 return (*Dictionary())[kVsockGuestCid].asInt(); 262 } set_vsock_guest_cid(int vsock_guest_cid)263void CuttlefishConfig::MutableInstanceSpecific::set_vsock_guest_cid( 264 int vsock_guest_cid) { 265 (*Dictionary())[kVsockGuestCid] = vsock_guest_cid; 266 } 267 268 static constexpr char kUuid[] = "uuid"; uuid() const269std::string CuttlefishConfig::InstanceSpecific::uuid() const { 270 return (*Dictionary())[kUuid].asString(); 271 } set_uuid(const std::string & uuid)272void CuttlefishConfig::MutableInstanceSpecific::set_uuid(const std::string& uuid) { 273 (*Dictionary())[kUuid] = uuid; 274 } 275 276 static constexpr char kHostPort[] = "adb_host_port"; adb_host_port() const277int CuttlefishConfig::InstanceSpecific::adb_host_port() const { 278 return (*Dictionary())[kHostPort].asInt(); 279 } set_adb_host_port(int port)280void CuttlefishConfig::MutableInstanceSpecific::set_adb_host_port(int port) { 281 (*Dictionary())[kHostPort] = port; 282 } 283 284 static constexpr char kModemSimulatorId[] = "modem_simulator_host_id"; modem_simulator_host_id() const285int CuttlefishConfig::InstanceSpecific::modem_simulator_host_id() const { 286 return (*Dictionary())[kModemSimulatorId].asInt(); 287 } set_modem_simulator_host_id(int id)288void CuttlefishConfig::MutableInstanceSpecific::set_modem_simulator_host_id( 289 int id) { 290 (*Dictionary())[kModemSimulatorId] = id; 291 } 292 293 static constexpr char kAdbIPAndPort[] = "adb_ip_and_port"; adb_ip_and_port() const294std::string CuttlefishConfig::InstanceSpecific::adb_ip_and_port() const { 295 return (*Dictionary())[kAdbIPAndPort].asString(); 296 } set_adb_ip_and_port(const std::string & ip_port)297void CuttlefishConfig::MutableInstanceSpecific::set_adb_ip_and_port( 298 const std::string& ip_port) { 299 (*Dictionary())[kAdbIPAndPort] = ip_port; 300 } 301 adb_device_name() const302std::string CuttlefishConfig::InstanceSpecific::adb_device_name() const { 303 if (adb_ip_and_port() != "") { 304 return adb_ip_and_port(); 305 } 306 LOG(ERROR) << "no adb_mode found, returning bad device name"; 307 return "NO_ADB_MODE_SET_NO_VALID_DEVICE_NAME"; 308 } 309 310 static constexpr char kQemuVncServerPort[] = "qemu_vnc_server_port"; qemu_vnc_server_port() const311int CuttlefishConfig::InstanceSpecific::qemu_vnc_server_port() const { 312 return (*Dictionary())[kQemuVncServerPort].asInt(); 313 } set_qemu_vnc_server_port(int qemu_vnc_server_port)314void CuttlefishConfig::MutableInstanceSpecific::set_qemu_vnc_server_port( 315 int qemu_vnc_server_port) { 316 (*Dictionary())[kQemuVncServerPort] = qemu_vnc_server_port; 317 } 318 319 static constexpr char kTouchServerPort[] = "touch_server_port"; touch_server_port() const320int CuttlefishConfig::InstanceSpecific::touch_server_port() const { 321 return (*Dictionary())[kTouchServerPort].asInt(); 322 } 323 set_touch_server_port(int touch_server_port)324void CuttlefishConfig::MutableInstanceSpecific::set_touch_server_port(int touch_server_port) { 325 (*Dictionary())[kTouchServerPort] = touch_server_port; 326 } 327 328 static constexpr char kKeyboardServerPort[] = "keyboard_server_port"; keyboard_server_port() const329int CuttlefishConfig::InstanceSpecific::keyboard_server_port() const { 330 return (*Dictionary())[kKeyboardServerPort].asInt(); 331 } set_keyboard_server_port(int keyboard_server_port)332void CuttlefishConfig::MutableInstanceSpecific::set_keyboard_server_port(int keyboard_server_port) { 333 (*Dictionary())[kKeyboardServerPort] = keyboard_server_port; 334 } 335 336 static constexpr char kTombstoneReceiverPort[] = "tombstone_receiver_port"; tombstone_receiver_port() const337int CuttlefishConfig::InstanceSpecific::tombstone_receiver_port() const { 338 return (*Dictionary())[kTombstoneReceiverPort].asInt(); 339 } set_tombstone_receiver_port(int tombstone_receiver_port)340void CuttlefishConfig::MutableInstanceSpecific::set_tombstone_receiver_port(int tombstone_receiver_port) { 341 (*Dictionary())[kTombstoneReceiverPort] = tombstone_receiver_port; 342 } 343 344 static constexpr char kVehicleHalServerPort[] = "vehicle_hal_server_port"; vehicle_hal_server_port() const345int CuttlefishConfig::InstanceSpecific::vehicle_hal_server_port() const { 346 return (*Dictionary())[kVehicleHalServerPort].asInt(); 347 } set_vehicle_hal_server_port(int vehicle_hal_server_port)348void CuttlefishConfig::MutableInstanceSpecific::set_vehicle_hal_server_port(int vehicle_hal_server_port) { 349 (*Dictionary())[kVehicleHalServerPort] = vehicle_hal_server_port; 350 } 351 352 static constexpr char kAudioControlServerPort[] = "audiocontrol_server_port"; audiocontrol_server_port() const353int CuttlefishConfig::InstanceSpecific::audiocontrol_server_port() const { 354 return (*Dictionary())[kAudioControlServerPort].asInt(); 355 } set_audiocontrol_server_port(int audiocontrol_server_port)356void CuttlefishConfig::MutableInstanceSpecific::set_audiocontrol_server_port(int audiocontrol_server_port) { 357 (*Dictionary())[kAudioControlServerPort] = audiocontrol_server_port; 358 } 359 360 static constexpr char kConfigServerPort[] = "config_server_port"; config_server_port() const361int CuttlefishConfig::InstanceSpecific::config_server_port() const { 362 return (*Dictionary())[kConfigServerPort].asInt(); 363 } set_config_server_port(int config_server_port)364void CuttlefishConfig::MutableInstanceSpecific::set_config_server_port(int config_server_port) { 365 (*Dictionary())[kConfigServerPort] = config_server_port; 366 } 367 368 static constexpr char kCameraServerPort[] = "camera_server_port"; camera_server_port() const369int CuttlefishConfig::InstanceSpecific::camera_server_port() const { 370 return (*Dictionary())[kCameraServerPort].asInt(); 371 } set_camera_server_port(int camera_server_port)372void CuttlefishConfig::MutableInstanceSpecific::set_camera_server_port( 373 int camera_server_port) { 374 (*Dictionary())[kCameraServerPort] = camera_server_port; 375 } 376 377 static constexpr char kWebrtcDeviceId[] = "webrtc_device_id"; set_webrtc_device_id(const std::string & id)378void CuttlefishConfig::MutableInstanceSpecific::set_webrtc_device_id( 379 const std::string& id) { 380 (*Dictionary())[kWebrtcDeviceId] = id; 381 } webrtc_device_id() const382std::string CuttlefishConfig::InstanceSpecific::webrtc_device_id() const { 383 return (*Dictionary())[kWebrtcDeviceId].asString(); 384 } 385 386 static constexpr char kStartSigServer[] = "webrtc_start_sig_server"; set_start_webrtc_signaling_server(bool start)387void CuttlefishConfig::MutableInstanceSpecific::set_start_webrtc_signaling_server(bool start) { 388 (*Dictionary())[kStartSigServer] = start; 389 } start_webrtc_sig_server() const390bool CuttlefishConfig::InstanceSpecific::start_webrtc_sig_server() const { 391 return (*Dictionary())[kStartSigServer].asBool(); 392 } 393 394 static constexpr char kStartSigServerProxy[] = "webrtc_start_sig_server_proxy"; 395 void CuttlefishConfig::MutableInstanceSpecific:: set_start_webrtc_sig_server_proxy(bool start)396 set_start_webrtc_sig_server_proxy(bool start) { 397 (*Dictionary())[kStartSigServerProxy] = start; 398 } start_webrtc_sig_server_proxy() const399bool CuttlefishConfig::InstanceSpecific::start_webrtc_sig_server_proxy() const { 400 return (*Dictionary())[kStartSigServerProxy].asBool(); 401 } 402 403 static constexpr char kStartWmediumd[] = "start_wmediumd"; set_start_wmediumd(bool start)404void CuttlefishConfig::MutableInstanceSpecific::set_start_wmediumd(bool start) { 405 (*Dictionary())[kStartWmediumd] = start; 406 } start_wmediumd() const407bool CuttlefishConfig::InstanceSpecific::start_wmediumd() const { 408 return (*Dictionary())[kStartWmediumd].asBool(); 409 } 410 411 static constexpr char kStartRootcanal[] = "start_rootcanal"; set_start_rootcanal(bool start)412void CuttlefishConfig::MutableInstanceSpecific::set_start_rootcanal( 413 bool start) { 414 (*Dictionary())[kStartRootcanal] = start; 415 } start_rootcanal() const416bool CuttlefishConfig::InstanceSpecific::start_rootcanal() const { 417 return (*Dictionary())[kStartRootcanal].asBool(); 418 } 419 420 static constexpr char kStartAp[] = "start_ap"; set_start_ap(bool start)421void CuttlefishConfig::MutableInstanceSpecific::set_start_ap(bool start) { 422 (*Dictionary())[kStartAp] = start; 423 } start_ap() const424bool CuttlefishConfig::InstanceSpecific::start_ap() const { 425 return (*Dictionary())[kStartAp].asBool(); 426 } 427 touch_socket_path(int screen_idx) const428std::string CuttlefishConfig::InstanceSpecific::touch_socket_path( 429 int screen_idx) const { 430 return PerInstanceInternalPath( 431 ("touch_" + std::to_string(screen_idx) + ".sock").c_str()); 432 } 433 keyboard_socket_path() const434std::string CuttlefishConfig::InstanceSpecific::keyboard_socket_path() const { 435 return PerInstanceInternalPath("keyboard.sock"); 436 } 437 switches_socket_path() const438std::string CuttlefishConfig::InstanceSpecific::switches_socket_path() const { 439 return PerInstanceInternalPath("switches.sock"); 440 } 441 frames_socket_path() const442std::string CuttlefishConfig::InstanceSpecific::frames_socket_path() const { 443 return PerInstanceInternalPath("frames.sock"); 444 } 445 446 static constexpr char kWifiMacPrefix[] = "wifi_mac_prefix"; wifi_mac_prefix() const447int CuttlefishConfig::InstanceSpecific::wifi_mac_prefix() const { 448 return (*Dictionary())[kWifiMacPrefix].asInt(); 449 } set_wifi_mac_prefix(int wifi_mac_prefix)450void CuttlefishConfig::MutableInstanceSpecific::set_wifi_mac_prefix( 451 int wifi_mac_prefix) { 452 (*Dictionary())[kWifiMacPrefix] = wifi_mac_prefix; 453 } 454 factory_reset_protected_path() const455std::string CuttlefishConfig::InstanceSpecific::factory_reset_protected_path() const { 456 return PerInstanceInternalPath("factory_reset_protected.img"); 457 } 458 persistent_bootconfig_path() const459std::string CuttlefishConfig::InstanceSpecific::persistent_bootconfig_path() 460 const { 461 return PerInstanceInternalPath("bootconfig"); 462 } 463 PerInstancePath(const char * file_name) const464std::string CuttlefishConfig::InstanceSpecific::PerInstancePath( 465 const char* file_name) const { 466 return (instance_dir() + "/") + file_name; 467 } 468 PerInstanceInternalPath(const char * file_name) const469std::string CuttlefishConfig::InstanceSpecific::PerInstanceInternalPath( 470 const char* file_name) const { 471 if (file_name[0] == '\0') { 472 // Don't append a / if file_name is empty. 473 return PerInstancePath(kInternalDirName); 474 } 475 auto relative_path = (std::string(kInternalDirName) + "/") + file_name; 476 return PerInstancePath(relative_path.c_str()); 477 } 478 PerInstanceLogPath(const std::string & file_name) const479std::string CuttlefishConfig::InstanceSpecific::PerInstanceLogPath( 480 const std::string& file_name) const { 481 if (file_name.size() == 0) { 482 // Don't append a / if file_name is empty. 483 return PerInstancePath(kLogDirName); 484 } 485 auto relative_path = (std::string(kLogDirName) + "/") + file_name; 486 return PerInstancePath(relative_path.c_str()); 487 } 488 instance_name() const489std::string CuttlefishConfig::InstanceSpecific::instance_name() const { 490 return IdToName(id_); 491 } 492 id() const493std::string CuttlefishConfig::InstanceSpecific::id() const { return id_; } 494 495 } // namespace cuttlefish 496