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 "cuttlefish_config.h"
18 #include "host/libs/config/cuttlefish_config.h"
19
20 #include <string_view>
21
22 #include <android-base/logging.h>
23 #include <android-base/strings.h>
24 #include <json/json.h>
25
26 #include "common/libs/utils/files.h"
27 #include "common/libs/utils/flags_validator.h"
28 #include "host/libs/vm_manager/crosvm_manager.h"
29 #include "host/libs/vm_manager/gem5_manager.h"
30
31 namespace cuttlefish {
32 namespace {
33
34 using APBootFlow = CuttlefishConfig::InstanceSpecific::APBootFlow;
35
36 const char* kInstances = "instances";
37
IdToName(const std::string & id)38 std::string IdToName(const std::string& id) { return kCvdNamePrefix + id; }
39
40 } // namespace
41
operator <<(std::ostream & out,ExternalNetworkMode net)42 std::ostream& operator<<(std::ostream& out, ExternalNetworkMode net) {
43 switch (net) {
44 case ExternalNetworkMode::kUnknown:
45 return out << "unknown";
46 case ExternalNetworkMode::kTap:
47 return out << "tap";
48 case ExternalNetworkMode::kSlirp:
49 return out << "slirp";
50 }
51 }
ParseExternalNetworkMode(std::string_view str)52 Result<ExternalNetworkMode> ParseExternalNetworkMode(std::string_view str) {
53 if (android::base::EqualsIgnoreCase(str, "tap")) {
54 return ExternalNetworkMode::kTap;
55 } else if (android::base::EqualsIgnoreCase(str, "slirp")) {
56 return ExternalNetworkMode::kSlirp;
57 } else {
58 return CF_ERRF(
59 "\"{}\" is not a valid ExternalNetworkMode. Valid values are \"tap\" "
60 "and \"slirp\"",
61 str);
62 }
63 }
64
ToString(VmmMode mode)65 std::string ToString(VmmMode mode) {
66 std::stringstream ss;
67 ss << mode;
68 return ss.str();
69 }
70
operator <<(std::ostream & out,VmmMode vmm)71 std::ostream& operator<<(std::ostream& out, VmmMode vmm) {
72 switch (vmm) {
73 case VmmMode::kUnknown:
74 return out << "unknown";
75 case VmmMode::kCrosvm:
76 return out << "crosvm";
77 case VmmMode::kGem5:
78 return out << "gem5";
79 case VmmMode::kQemu:
80 return out << "qemu_cli";
81 }
82 }
83
ParseVmm(std::string_view str)84 Result<VmmMode> ParseVmm(std::string_view str) {
85 if (android::base::EqualsIgnoreCase(str, "crosvm")) {
86 return VmmMode::kCrosvm;
87 } else if (android::base::EqualsIgnoreCase(str, "gem5")) {
88 return VmmMode::kGem5;
89 } else if (android::base::EqualsIgnoreCase(str, "qemu_cli")) {
90 return VmmMode::kQemu;
91 } else {
92 return CF_ERRF("\"{}\" is not a valid Vmm.", str);
93 }
94 }
95
96 static constexpr char kInstanceDir[] = "instance_dir";
MutableInstanceSpecific(CuttlefishConfig * config,const std::string & id)97 CuttlefishConfig::MutableInstanceSpecific::MutableInstanceSpecific(
98 CuttlefishConfig* config, const std::string& id)
99 : config_(config), id_(id) {
100 // Legacy for acloud
101 (*Dictionary())[kInstanceDir] = config_->InstancesPath(IdToName(id));
102 }
103
Dictionary()104 Json::Value* CuttlefishConfig::MutableInstanceSpecific::Dictionary() {
105 return &(*config_->dictionary_)[kInstances][id_];
106 }
107
Dictionary() const108 const Json::Value* CuttlefishConfig::InstanceSpecific::Dictionary() const {
109 return &(*config_->dictionary_)[kInstances][id_];
110 }
111
instance_dir() const112 std::string CuttlefishConfig::InstanceSpecific::instance_dir() const {
113 return config_->InstancesPath(IdToName(id_));
114 }
115
instance_internal_dir() const116 std::string CuttlefishConfig::InstanceSpecific::instance_internal_dir() const {
117 return PerInstancePath(kInternalDirName);
118 }
119
instance_uds_dir() const120 std::string CuttlefishConfig::InstanceSpecific::instance_uds_dir() const {
121 return config_->InstancesUdsPath(IdToName(id_));
122 }
123
instance_internal_uds_dir() const124 std::string CuttlefishConfig::InstanceSpecific::instance_internal_uds_dir()
125 const {
126 return PerInstanceUdsPath(kInternalDirName);
127 }
128
129 // TODO (b/163575714) add virtio console support to the bootloader so the
130 // virtio console path for the console device can be taken again. When that
131 // happens, this function can be deleted along with all the code paths it
132 // forces.
use_bootloader() const133 bool CuttlefishConfig::InstanceSpecific::use_bootloader() const {
134 return true;
135 };
136
137 // vectorized and moved system image files into instance specific
138 static constexpr char kBootImage[] = "boot_image";
boot_image() const139 std::string CuttlefishConfig::InstanceSpecific::boot_image() const {
140 return (*Dictionary())[kBootImage].asString();
141 }
set_boot_image(const std::string & boot_image)142 void CuttlefishConfig::MutableInstanceSpecific::set_boot_image(
143 const std::string& boot_image) {
144 (*Dictionary())[kBootImage] = boot_image;
145 }
146 static constexpr char kNewBootImage[] = "new_boot_image";
new_boot_image() const147 std::string CuttlefishConfig::InstanceSpecific::new_boot_image() const {
148 return (*Dictionary())[kNewBootImage].asString();
149 }
set_new_boot_image(const std::string & new_boot_image)150 void CuttlefishConfig::MutableInstanceSpecific::set_new_boot_image(
151 const std::string& new_boot_image) {
152 (*Dictionary())[kNewBootImage] = new_boot_image;
153 }
154 static constexpr char kInitBootImage[] = "init_boot_image";
init_boot_image() const155 std::string CuttlefishConfig::InstanceSpecific::init_boot_image() const {
156 return (*Dictionary())[kInitBootImage].asString();
157 }
set_init_boot_image(const std::string & init_boot_image)158 void CuttlefishConfig::MutableInstanceSpecific::set_init_boot_image(
159 const std::string& init_boot_image) {
160 (*Dictionary())[kInitBootImage] = init_boot_image;
161 }
162 static constexpr char kDataImage[] = "data_image";
data_image() const163 std::string CuttlefishConfig::InstanceSpecific::data_image() const {
164 return (*Dictionary())[kDataImage].asString();
165 }
set_data_image(const std::string & data_image)166 void CuttlefishConfig::MutableInstanceSpecific::set_data_image(
167 const std::string& data_image) {
168 (*Dictionary())[kDataImage] = data_image;
169 }
170 static constexpr char kNewDataImage[] = "new_data_image";
new_data_image() const171 std::string CuttlefishConfig::InstanceSpecific::new_data_image() const {
172 return (*Dictionary())[kNewDataImage].asString();
173 }
set_new_data_image(const std::string & new_data_image)174 void CuttlefishConfig::MutableInstanceSpecific::set_new_data_image(
175 const std::string& new_data_image) {
176 (*Dictionary())[kNewDataImage] = new_data_image;
177 }
178 static constexpr char kSuperImage[] = "super_image";
super_image() const179 std::string CuttlefishConfig::InstanceSpecific::super_image() const {
180 return (*Dictionary())[kSuperImage].asString();
181 }
set_super_image(const std::string & super_image)182 void CuttlefishConfig::MutableInstanceSpecific::set_super_image(
183 const std::string& super_image) {
184 (*Dictionary())[kSuperImage] = super_image;
185 }
186 static constexpr char kNewSuperImage[] = "new_super_image";
new_super_image() const187 std::string CuttlefishConfig::InstanceSpecific::new_super_image() const {
188 return (*Dictionary())[kNewSuperImage].asString();
189 }
set_new_super_image(const std::string & super_image)190 void CuttlefishConfig::MutableInstanceSpecific::set_new_super_image(
191 const std::string& super_image) {
192 (*Dictionary())[kNewSuperImage] = super_image;
193 }
194 static constexpr char kMiscInfoTxt[] = "misc_info_txt";
misc_info_txt() const195 std::string CuttlefishConfig::InstanceSpecific::misc_info_txt() const {
196 return (*Dictionary())[kMiscInfoTxt].asString();
197 }
set_misc_info_txt(const std::string & misc_info)198 void CuttlefishConfig::MutableInstanceSpecific::set_misc_info_txt(
199 const std::string& misc_info) {
200 (*Dictionary())[kMiscInfoTxt] = misc_info;
201 }
202 static constexpr char kVendorBootImage[] = "vendor_boot_image";
vendor_boot_image() const203 std::string CuttlefishConfig::InstanceSpecific::vendor_boot_image() const {
204 return (*Dictionary())[kVendorBootImage].asString();
205 }
set_vendor_boot_image(const std::string & vendor_boot_image)206 void CuttlefishConfig::MutableInstanceSpecific::set_vendor_boot_image(
207 const std::string& vendor_boot_image) {
208 (*Dictionary())[kVendorBootImage] = vendor_boot_image;
209 }
210 static constexpr char kNewVendorBootImage[] = "new_vendor_boot_image";
new_vendor_boot_image() const211 std::string CuttlefishConfig::InstanceSpecific::new_vendor_boot_image() const {
212 return (*Dictionary())[kNewVendorBootImage].asString();
213 }
set_new_vendor_boot_image(const std::string & new_vendor_boot_image)214 void CuttlefishConfig::MutableInstanceSpecific::set_new_vendor_boot_image(
215 const std::string& new_vendor_boot_image) {
216 (*Dictionary())[kNewVendorBootImage] = new_vendor_boot_image;
217 }
218 static constexpr char kVbmetaImage[] = "vbmeta_image";
vbmeta_image() const219 std::string CuttlefishConfig::InstanceSpecific::vbmeta_image() const {
220 return (*Dictionary())[kVbmetaImage].asString();
221 }
set_vbmeta_image(const std::string & vbmeta_image)222 void CuttlefishConfig::MutableInstanceSpecific::set_vbmeta_image(
223 const std::string& vbmeta_image) {
224 (*Dictionary())[kVbmetaImage] = vbmeta_image;
225 }
226 static constexpr char kNewVbmetaImage[] = "new_vbmeta_image";
new_vbmeta_image() const227 std::string CuttlefishConfig::InstanceSpecific::new_vbmeta_image() const {
228 return (*Dictionary())[kNewVbmetaImage].asString();
229 }
set_new_vbmeta_image(const std::string & new_vbmeta_image)230 void CuttlefishConfig::MutableInstanceSpecific::set_new_vbmeta_image(
231 const std::string& new_vbmeta_image) {
232 (*Dictionary())[kNewVbmetaImage] = new_vbmeta_image;
233 }
234 static constexpr char kVbmetaSystemImage[] = "vbmeta_system_image";
vbmeta_system_image() const235 std::string CuttlefishConfig::InstanceSpecific::vbmeta_system_image() const {
236 return (*Dictionary())[kVbmetaSystemImage].asString();
237 }
set_vbmeta_system_image(const std::string & vbmeta_system_image)238 void CuttlefishConfig::MutableInstanceSpecific::set_vbmeta_system_image(
239 const std::string& vbmeta_system_image) {
240 (*Dictionary())[kVbmetaSystemImage] = vbmeta_system_image;
241 }
242 static constexpr char kVbmetaVendorDlkmImage[] = "vbmeta_vendor_dlkm_image";
vbmeta_vendor_dlkm_image() const243 std::string CuttlefishConfig::InstanceSpecific::vbmeta_vendor_dlkm_image()
244 const {
245 return (*Dictionary())[kVbmetaVendorDlkmImage].asString();
246 }
set_vbmeta_vendor_dlkm_image(const std::string & image)247 void CuttlefishConfig::MutableInstanceSpecific::set_vbmeta_vendor_dlkm_image(
248 const std::string& image) {
249 (*Dictionary())[kVbmetaVendorDlkmImage] = image;
250 }
251 static constexpr char kNewVbmetaVendorDlkmImage[] =
252 "new_vbmeta_vendor_dlkm_image";
new_vbmeta_vendor_dlkm_image() const253 std::string CuttlefishConfig::InstanceSpecific::new_vbmeta_vendor_dlkm_image()
254 const {
255 return (*Dictionary())[kNewVbmetaVendorDlkmImage].asString();
256 }
257 void CuttlefishConfig::MutableInstanceSpecific::
set_new_vbmeta_vendor_dlkm_image(const std::string & image)258 set_new_vbmeta_vendor_dlkm_image(const std::string& image) {
259 (*Dictionary())[kNewVbmetaVendorDlkmImage] = image;
260 }
261 static constexpr char kVbmetaSystemDlkmImage[] = "vbmeta_system_dlkm_image";
vbmeta_system_dlkm_image() const262 std::string CuttlefishConfig::InstanceSpecific::vbmeta_system_dlkm_image()
263 const {
264 return (*Dictionary())[kVbmetaSystemDlkmImage].asString();
265 }
set_vbmeta_system_dlkm_image(const std::string & image)266 void CuttlefishConfig::MutableInstanceSpecific::set_vbmeta_system_dlkm_image(
267 const std::string& image) {
268 (*Dictionary())[kVbmetaSystemDlkmImage] = image;
269 }
270 static constexpr char kNewVbmetaSystemDlkmImage[] =
271 "new_vbmeta_system_dlkm_image";
new_vbmeta_system_dlkm_image() const272 std::string CuttlefishConfig::InstanceSpecific::new_vbmeta_system_dlkm_image()
273 const {
274 return (*Dictionary())[kNewVbmetaSystemDlkmImage].asString();
275 }
276 void CuttlefishConfig::MutableInstanceSpecific::
set_new_vbmeta_system_dlkm_image(const std::string & image)277 set_new_vbmeta_system_dlkm_image(const std::string& image) {
278 (*Dictionary())[kNewVbmetaSystemDlkmImage] = image;
279 }
280 static constexpr char kOtherosEspImage[] = "otheros_esp_image";
otheros_esp_image() const281 std::string CuttlefishConfig::InstanceSpecific::otheros_esp_image() const {
282 return (*Dictionary())[kOtherosEspImage].asString();
283 }
set_otheros_esp_image(const std::string & otheros_esp_image)284 void CuttlefishConfig::MutableInstanceSpecific::set_otheros_esp_image(
285 const std::string& otheros_esp_image) {
286 (*Dictionary())[kOtherosEspImage] = otheros_esp_image;
287 }
288 static constexpr char kAndroidEfiLoader[] = "android_efi_loader";
android_efi_loader() const289 std::string CuttlefishConfig::InstanceSpecific::android_efi_loader() const {
290 return (*Dictionary())[kAndroidEfiLoader].asString();
291 }
set_android_efi_loader(const std::string & android_efi_loader)292 void CuttlefishConfig::MutableInstanceSpecific::set_android_efi_loader(
293 const std::string& android_efi_loader) {
294 (*Dictionary())[kAndroidEfiLoader] = android_efi_loader;
295 }
296 static constexpr char kChromeOsDisk[] = "chromeos_disk";
chromeos_disk() const297 std::string CuttlefishConfig::InstanceSpecific::chromeos_disk() const {
298 return (*Dictionary())[kChromeOsDisk].asString();
299 }
set_chromeos_disk(const std::string & chromeos_disk)300 void CuttlefishConfig::MutableInstanceSpecific::set_chromeos_disk(
301 const std::string& chromeos_disk) {
302 (*Dictionary())[kChromeOsDisk] = chromeos_disk;
303 }
304 static constexpr char kChromeOsKernelPath[] = "chromeos_kernel_path";
chromeos_kernel_path() const305 std::string CuttlefishConfig::InstanceSpecific::chromeos_kernel_path() const {
306 return (*Dictionary())[kChromeOsKernelPath].asString();
307 }
set_chromeos_kernel_path(const std::string & chromeos_kernel_path)308 void CuttlefishConfig::MutableInstanceSpecific::set_chromeos_kernel_path(
309 const std::string& chromeos_kernel_path) {
310 (*Dictionary())[kChromeOsKernelPath] = chromeos_kernel_path;
311 }
312 static constexpr char kChromeOsRootImage[] = "chromeos_root_image";
chromeos_root_image() const313 std::string CuttlefishConfig::InstanceSpecific::chromeos_root_image() const {
314 return (*Dictionary())[kChromeOsRootImage].asString();
315 }
set_chromeos_root_image(const std::string & chromeos_root_image)316 void CuttlefishConfig::MutableInstanceSpecific::set_chromeos_root_image(
317 const std::string& chromeos_root_image) {
318 (*Dictionary())[kChromeOsRootImage] = chromeos_root_image;
319 }
320 static constexpr char kLinuxKernelPath[] = "linux_kernel_path";
linux_kernel_path() const321 std::string CuttlefishConfig::InstanceSpecific::linux_kernel_path() const {
322 return (*Dictionary())[kLinuxKernelPath].asString();
323 }
set_linux_kernel_path(const std::string & linux_kernel_path)324 void CuttlefishConfig::MutableInstanceSpecific::set_linux_kernel_path(
325 const std::string& linux_kernel_path) {
326 (*Dictionary())[kLinuxKernelPath] = linux_kernel_path;
327 }
328 static constexpr char kLinuxInitramfsPath[] = "linux_initramfs_path";
linux_initramfs_path() const329 std::string CuttlefishConfig::InstanceSpecific::linux_initramfs_path() const {
330 return (*Dictionary())[kLinuxInitramfsPath].asString();
331 }
set_linux_initramfs_path(const std::string & linux_initramfs_path)332 void CuttlefishConfig::MutableInstanceSpecific::set_linux_initramfs_path(
333 const std::string& linux_initramfs_path) {
334 (*Dictionary())[kLinuxInitramfsPath] = linux_initramfs_path;
335 }
336 static constexpr char kLinuxRootImage[] = "linux_root_image";
linux_root_image() const337 std::string CuttlefishConfig::InstanceSpecific::linux_root_image() const {
338 return (*Dictionary())[kLinuxRootImage].asString();
339 }
set_linux_root_image(const std::string & linux_root_image)340 void CuttlefishConfig::MutableInstanceSpecific::set_linux_root_image(
341 const std::string& linux_root_image) {
342 (*Dictionary())[kLinuxRootImage] = linux_root_image;
343 }
344 static constexpr char kFuchsiaZedbootPath[] = "fuchsia_zedboot_path";
set_fuchsia_zedboot_path(const std::string & fuchsia_zedboot_path)345 void CuttlefishConfig::MutableInstanceSpecific::set_fuchsia_zedboot_path(
346 const std::string& fuchsia_zedboot_path) {
347 (*Dictionary())[kFuchsiaZedbootPath] = fuchsia_zedboot_path;
348 }
fuchsia_zedboot_path() const349 std::string CuttlefishConfig::InstanceSpecific::fuchsia_zedboot_path() const {
350 return (*Dictionary())[kFuchsiaZedbootPath].asString();
351 }
352 static constexpr char kFuchsiaMultibootBinPath[] = "multiboot_bin_path";
set_fuchsia_multiboot_bin_path(const std::string & fuchsia_multiboot_bin_path)353 void CuttlefishConfig::MutableInstanceSpecific::set_fuchsia_multiboot_bin_path(
354 const std::string& fuchsia_multiboot_bin_path) {
355 (*Dictionary())[kFuchsiaMultibootBinPath] = fuchsia_multiboot_bin_path;
356 }
fuchsia_multiboot_bin_path() const357 std::string CuttlefishConfig::InstanceSpecific::fuchsia_multiboot_bin_path() const {
358 return (*Dictionary())[kFuchsiaMultibootBinPath].asString();
359 }
360 static constexpr char kFuchsiaRootImage[] = "fuchsia_root_image";
set_fuchsia_root_image(const std::string & fuchsia_root_image)361 void CuttlefishConfig::MutableInstanceSpecific::set_fuchsia_root_image(
362 const std::string& fuchsia_root_image) {
363 (*Dictionary())[kFuchsiaRootImage] = fuchsia_root_image;
364 }
fuchsia_root_image() const365 std::string CuttlefishConfig::InstanceSpecific::fuchsia_root_image() const {
366 return (*Dictionary())[kFuchsiaRootImage].asString();
367 }
368 static constexpr char kCustomPartitionPath[] = "custom_partition_path";
set_custom_partition_path(const std::string & custom_partition_path)369 void CuttlefishConfig::MutableInstanceSpecific::set_custom_partition_path(
370 const std::string& custom_partition_path) {
371 (*Dictionary())[kCustomPartitionPath] = custom_partition_path;
372 }
custom_partition_path() const373 std::string CuttlefishConfig::InstanceSpecific::custom_partition_path() const {
374 return (*Dictionary())[kCustomPartitionPath].asString();
375 }
376 static constexpr char kBlankMetadataImageMb[] = "blank_metadata_image_mb";
blank_metadata_image_mb() const377 int CuttlefishConfig::InstanceSpecific::blank_metadata_image_mb() const {
378 return (*Dictionary())[kBlankMetadataImageMb].asInt();
379 }
set_blank_metadata_image_mb(int blank_metadata_image_mb)380 void CuttlefishConfig::MutableInstanceSpecific::set_blank_metadata_image_mb(
381 int blank_metadata_image_mb) {
382 (*Dictionary())[kBlankMetadataImageMb] = blank_metadata_image_mb;
383 }
384 static constexpr char kBlankSdcardImageMb[] = "blank_sdcard_image_mb";
blank_sdcard_image_mb() const385 int CuttlefishConfig::InstanceSpecific::blank_sdcard_image_mb() const {
386 return (*Dictionary())[kBlankSdcardImageMb].asInt();
387 }
set_blank_sdcard_image_mb(int blank_sdcard_image_mb)388 void CuttlefishConfig::MutableInstanceSpecific::set_blank_sdcard_image_mb(
389 int blank_sdcard_image_mb) {
390 (*Dictionary())[kBlankSdcardImageMb] = blank_sdcard_image_mb;
391 }
392 static constexpr char kBootloader[] = "bootloader";
bootloader() const393 std::string CuttlefishConfig::InstanceSpecific::bootloader() const {
394 return (*Dictionary())[kBootloader].asString();
395 }
set_bootloader(const std::string & bootloader)396 void CuttlefishConfig::MutableInstanceSpecific::set_bootloader(
397 const std::string& bootloader) {
398 (*Dictionary())[kBootloader] = bootloader;
399 }
400 static constexpr char kInitramfsPath[] = "initramfs_path";
initramfs_path() const401 std::string CuttlefishConfig::InstanceSpecific::initramfs_path() const {
402 return (*Dictionary())[kInitramfsPath].asString();
403 }
set_initramfs_path(const std::string & initramfs_path)404 void CuttlefishConfig::MutableInstanceSpecific::set_initramfs_path(
405 const std::string& initramfs_path) {
406 (*Dictionary())[kInitramfsPath] = initramfs_path;
407 }
408 static constexpr char kKernelPath[] = "kernel_path";
kernel_path() const409 std::string CuttlefishConfig::InstanceSpecific::kernel_path() const {
410 return (*Dictionary())[kKernelPath].asString();
411 }
set_kernel_path(const std::string & kernel_path)412 void CuttlefishConfig::MutableInstanceSpecific::set_kernel_path(
413 const std::string& kernel_path) {
414 (*Dictionary())[kKernelPath] = kernel_path;
415 }
416 // end of system image files
417
418 static constexpr char kDefaultTargetZip[] = "default_target_zip";
default_target_zip() const419 std::string CuttlefishConfig::InstanceSpecific::default_target_zip() const {
420 return (*Dictionary())[kDefaultTargetZip].asString();
421 }
set_default_target_zip(const std::string & default_target_zip)422 void CuttlefishConfig::MutableInstanceSpecific::set_default_target_zip(
423 const std::string& default_target_zip) {
424 (*Dictionary())[kDefaultTargetZip] = default_target_zip;
425 }
426 static constexpr char kSystemTargetZip[] = "system_target_zip";
system_target_zip() const427 std::string CuttlefishConfig::InstanceSpecific::system_target_zip() const {
428 return (*Dictionary())[kSystemTargetZip].asString();
429 }
set_system_target_zip(const std::string & system_target_zip)430 void CuttlefishConfig::MutableInstanceSpecific::set_system_target_zip(
431 const std::string& system_target_zip) {
432 (*Dictionary())[kSystemTargetZip] = system_target_zip;
433 }
434
435 static constexpr char kSerialNumber[] = "serial_number";
serial_number() const436 std::string CuttlefishConfig::InstanceSpecific::serial_number() const {
437 return (*Dictionary())[kSerialNumber].asString();
438 }
set_serial_number(const std::string & serial_number)439 void CuttlefishConfig::MutableInstanceSpecific::set_serial_number(
440 const std::string& serial_number) {
441 (*Dictionary())[kSerialNumber] = serial_number;
442 }
443
444 static constexpr char kVirtualDiskPaths[] = "virtual_disk_paths";
virtual_disk_paths() const445 std::vector<std::string> CuttlefishConfig::InstanceSpecific::virtual_disk_paths() const {
446 std::vector<std::string> virtual_disks;
447 auto virtual_disks_json_obj = (*Dictionary())[kVirtualDiskPaths];
448 for (const auto& disk : virtual_disks_json_obj) {
449 virtual_disks.push_back(disk.asString());
450 }
451 return virtual_disks;
452 }
set_virtual_disk_paths(const std::vector<std::string> & virtual_disk_paths)453 void CuttlefishConfig::MutableInstanceSpecific::set_virtual_disk_paths(
454 const std::vector<std::string>& virtual_disk_paths) {
455 Json::Value virtual_disks_json_obj(Json::arrayValue);
456 for (const auto& arg : virtual_disk_paths) {
457 virtual_disks_json_obj.append(arg);
458 }
459 (*Dictionary())[kVirtualDiskPaths] = virtual_disks_json_obj;
460 }
461
462 static constexpr char kGuestAndroidVersion[] = "guest_android_version";
guest_android_version() const463 std::string CuttlefishConfig::InstanceSpecific::guest_android_version() const {
464 return (*Dictionary())[kGuestAndroidVersion].asString();
465 }
set_guest_android_version(const std::string & guest_android_version)466 void CuttlefishConfig::MutableInstanceSpecific::set_guest_android_version(
467 const std::string& guest_android_version) {
468 (*Dictionary())[kGuestAndroidVersion] = guest_android_version;
469 }
470
471 static constexpr char kBootconfigSupported[] = "bootconfig_supported";
bootconfig_supported() const472 bool CuttlefishConfig::InstanceSpecific::bootconfig_supported() const {
473 return (*Dictionary())[kBootconfigSupported].asBool();
474 }
set_bootconfig_supported(bool bootconfig_supported)475 void CuttlefishConfig::MutableInstanceSpecific::set_bootconfig_supported(
476 bool bootconfig_supported) {
477 (*Dictionary())[kBootconfigSupported] = bootconfig_supported;
478 }
479
480 static constexpr char kFilenameEncryptionMode[] = "filename_encryption_mode";
filename_encryption_mode() const481 std::string CuttlefishConfig::InstanceSpecific::filename_encryption_mode() const {
482 return (*Dictionary())[kFilenameEncryptionMode].asString();
483 }
set_filename_encryption_mode(const std::string & filename_encryption_mode)484 void CuttlefishConfig::MutableInstanceSpecific::set_filename_encryption_mode(
485 const std::string& filename_encryption_mode) {
486 auto fmt = filename_encryption_mode;
487 std::transform(fmt.begin(), fmt.end(), fmt.begin(), ::tolower);
488 (*Dictionary())[kFilenameEncryptionMode] = fmt;
489 }
490
491 static constexpr char kExternalNetworkMode[] = "external_network_mode";
external_network_mode() const492 ExternalNetworkMode CuttlefishConfig::InstanceSpecific::external_network_mode()
493 const {
494 auto str = (*Dictionary())[kExternalNetworkMode].asString();
495 return ParseExternalNetworkMode(str).value_or(ExternalNetworkMode::kUnknown);
496 }
set_external_network_mode(ExternalNetworkMode mode)497 void CuttlefishConfig::MutableInstanceSpecific::set_external_network_mode(
498 ExternalNetworkMode mode) {
499 (*Dictionary())[kExternalNetworkMode] = fmt::format("{}", mode);
500 }
501
kernel_log_pipe_name() const502 std::string CuttlefishConfig::InstanceSpecific::kernel_log_pipe_name() const {
503 return AbsolutePath(PerInstanceInternalPath("kernel-log-pipe"));
504 }
505
console_pipe_prefix() const506 std::string CuttlefishConfig::InstanceSpecific::console_pipe_prefix() const {
507 return AbsolutePath(PerInstanceInternalPath("console"));
508 }
509
console_in_pipe_name() const510 std::string CuttlefishConfig::InstanceSpecific::console_in_pipe_name() const {
511 return console_pipe_prefix() + ".in";
512 }
513
console_out_pipe_name() const514 std::string CuttlefishConfig::InstanceSpecific::console_out_pipe_name() const {
515 return console_pipe_prefix() + ".out";
516 }
517
gnss_pipe_prefix() const518 std::string CuttlefishConfig::InstanceSpecific::gnss_pipe_prefix() const {
519 return AbsolutePath(PerInstanceInternalPath("gnss"));
520 }
521
gnss_in_pipe_name() const522 std::string CuttlefishConfig::InstanceSpecific::gnss_in_pipe_name() const {
523 return gnss_pipe_prefix() + ".in";
524 }
525
gnss_out_pipe_name() const526 std::string CuttlefishConfig::InstanceSpecific::gnss_out_pipe_name() const {
527 return gnss_pipe_prefix() + ".out";
528 }
529
530 static constexpr char kGnssGrpcProxyServerPort[] =
531 "gnss_grpc_proxy_server_port";
gnss_grpc_proxy_server_port() const532 int CuttlefishConfig::InstanceSpecific::gnss_grpc_proxy_server_port() const {
533 return (*Dictionary())[kGnssGrpcProxyServerPort].asInt();
534 }
set_gnss_grpc_proxy_server_port(int gnss_grpc_proxy_server_port)535 void CuttlefishConfig::MutableInstanceSpecific::set_gnss_grpc_proxy_server_port(
536 int gnss_grpc_proxy_server_port) {
537 (*Dictionary())[kGnssGrpcProxyServerPort] = gnss_grpc_proxy_server_port;
538 }
539
540 static constexpr char kGnssFilePath[] = "gnss_file_path";
gnss_file_path() const541 std::string CuttlefishConfig::InstanceSpecific::gnss_file_path() const {
542 return (*Dictionary())[kGnssFilePath].asString();
543 }
set_gnss_file_path(const std::string & gnss_file_path)544 void CuttlefishConfig::MutableInstanceSpecific::set_gnss_file_path(
545 const std::string& gnss_file_path) {
546 (*Dictionary())[kGnssFilePath] = gnss_file_path;
547 }
548
549 static constexpr char kFixedLocationFilePath[] = "fixed_location_file_path";
fixed_location_file_path() const550 std::string CuttlefishConfig::InstanceSpecific::fixed_location_file_path()
551 const {
552 return (*Dictionary())[kFixedLocationFilePath].asString();
553 }
set_fixed_location_file_path(const std::string & fixed_location_file_path)554 void CuttlefishConfig::MutableInstanceSpecific::set_fixed_location_file_path(
555 const std::string& fixed_location_file_path) {
556 (*Dictionary())[kFixedLocationFilePath] = fixed_location_file_path;
557 }
558
559 static constexpr char kGem5BinaryDir[] = "gem5_binary_dir";
gem5_binary_dir() const560 std::string CuttlefishConfig::InstanceSpecific::gem5_binary_dir() const {
561 return (*Dictionary())[kGem5BinaryDir].asString();
562 }
set_gem5_binary_dir(const std::string & gem5_binary_dir)563 void CuttlefishConfig::MutableInstanceSpecific::set_gem5_binary_dir(
564 const std::string& gem5_binary_dir) {
565 (*Dictionary())[kGem5BinaryDir] = gem5_binary_dir;
566 }
567
568 static constexpr char kGem5CheckpointDir[] = "gem5_checkpoint_dir";
gem5_checkpoint_dir() const569 std::string CuttlefishConfig::InstanceSpecific::gem5_checkpoint_dir() const {
570 return (*Dictionary())[kGem5CheckpointDir].asString();
571 }
set_gem5_checkpoint_dir(const std::string & gem5_checkpoint_dir)572 void CuttlefishConfig::MutableInstanceSpecific::set_gem5_checkpoint_dir(
573 const std::string& gem5_checkpoint_dir) {
574 (*Dictionary())[kGem5CheckpointDir] = gem5_checkpoint_dir;
575 }
576
577 static constexpr char kKgdb[] = "kgdb";
set_kgdb(bool kgdb)578 void CuttlefishConfig::MutableInstanceSpecific::set_kgdb(bool kgdb) {
579 (*Dictionary())[kKgdb] = kgdb;
580 }
kgdb() const581 bool CuttlefishConfig::InstanceSpecific::kgdb() const {
582 return (*Dictionary())[kKgdb].asBool();
583 }
584
585 static constexpr char kCpus[] = "cpus";
set_cpus(int cpus)586 void CuttlefishConfig::MutableInstanceSpecific::set_cpus(int cpus) { (*Dictionary())[kCpus] = cpus; }
cpus() const587 int CuttlefishConfig::InstanceSpecific::cpus() const { return (*Dictionary())[kCpus].asInt(); }
588
589 static constexpr char kDataPolicy[] = "data_policy";
set_data_policy(const std::string & data_policy)590 void CuttlefishConfig::MutableInstanceSpecific::set_data_policy(
591 const std::string& data_policy) {
592 (*Dictionary())[kDataPolicy] = data_policy;
593 }
data_policy() const594 std::string CuttlefishConfig::InstanceSpecific::data_policy() const {
595 return (*Dictionary())[kDataPolicy].asString();
596 }
597
598 static constexpr char kBlankDataImageMb[] = "blank_data_image_mb";
set_blank_data_image_mb(int blank_data_image_mb)599 void CuttlefishConfig::MutableInstanceSpecific::set_blank_data_image_mb(
600 int blank_data_image_mb) {
601 (*Dictionary())[kBlankDataImageMb] = blank_data_image_mb;
602 }
blank_data_image_mb() const603 int CuttlefishConfig::InstanceSpecific::blank_data_image_mb() const {
604 return (*Dictionary())[kBlankDataImageMb].asInt();
605 }
606
607 static constexpr char kGdbPort[] = "gdb_port";
set_gdb_port(int port)608 void CuttlefishConfig::MutableInstanceSpecific::set_gdb_port(int port) {
609 (*Dictionary())[kGdbPort] = port;
610 }
gdb_port() const611 int CuttlefishConfig::InstanceSpecific::gdb_port() const {
612 return (*Dictionary())[kGdbPort].asInt();
613 }
614
615 static constexpr char kMemoryMb[] = "memory_mb";
memory_mb() const616 int CuttlefishConfig::InstanceSpecific::memory_mb() const {
617 return (*Dictionary())[kMemoryMb].asInt();
618 }
set_memory_mb(int memory_mb)619 void CuttlefishConfig::MutableInstanceSpecific::set_memory_mb(int memory_mb) {
620 (*Dictionary())[kMemoryMb] = memory_mb;
621 }
622
623 static constexpr char kDdrMemMb[] = "ddr_mem_mb";
ddr_mem_mb() const624 int CuttlefishConfig::InstanceSpecific::ddr_mem_mb() const {
625 return (*Dictionary())[kDdrMemMb].asInt();
626 }
set_ddr_mem_mb(int ddr_mem_mb)627 void CuttlefishConfig::MutableInstanceSpecific::set_ddr_mem_mb(int ddr_mem_mb) {
628 (*Dictionary())[kDdrMemMb] = ddr_mem_mb;
629 }
630
631 static constexpr char kSetupWizardMode[] = "setupwizard_mode";
setupwizard_mode() const632 std::string CuttlefishConfig::InstanceSpecific::setupwizard_mode() const {
633 return (*Dictionary())[kSetupWizardMode].asString();
634 }
set_setupwizard_mode(const std::string & mode)635 Result<void> CuttlefishConfig::MutableInstanceSpecific::set_setupwizard_mode(
636 const std::string& mode) {
637 CF_EXPECT(ValidateSetupWizardMode(mode),
638 "setupwizard_mode flag has invalid value: " << mode);
639 (*Dictionary())[kSetupWizardMode] = mode;
640 return {};
641 }
642
643 static constexpr char kUserdataFormat[] = "userdata_format";
userdata_format() const644 std::string CuttlefishConfig::InstanceSpecific::userdata_format() const {
645 return (*Dictionary())[kUserdataFormat].asString();
646 }
set_userdata_format(const std::string & userdata_format)647 void CuttlefishConfig::MutableInstanceSpecific::set_userdata_format(const std::string& userdata_format) {
648 auto fmt = userdata_format;
649 std::transform(fmt.begin(), fmt.end(), fmt.begin(), ::tolower);
650 (*Dictionary())[kUserdataFormat] = fmt;
651 }
652
653 static constexpr char kGuestEnforceSecurity[] = "guest_enforce_security";
set_guest_enforce_security(bool guest_enforce_security)654 void CuttlefishConfig::MutableInstanceSpecific::set_guest_enforce_security(bool guest_enforce_security) {
655 (*Dictionary())[kGuestEnforceSecurity] = guest_enforce_security;
656 }
guest_enforce_security() const657 bool CuttlefishConfig::InstanceSpecific::guest_enforce_security() const {
658 return (*Dictionary())[kGuestEnforceSecurity].asBool();
659 }
660
661 static constexpr char kUseSdcard[] = "use_sdcard";
set_use_sdcard(bool use_sdcard)662 void CuttlefishConfig::MutableInstanceSpecific::set_use_sdcard(bool use_sdcard) {
663 (*Dictionary())[kUseSdcard] = use_sdcard;
664 }
use_sdcard() const665 bool CuttlefishConfig::InstanceSpecific::use_sdcard() const {
666 return (*Dictionary())[kUseSdcard].asBool();
667 }
668
669 static constexpr char kPauseInBootloader[] = "pause_in_bootloader";
set_pause_in_bootloader(bool pause_in_bootloader)670 void CuttlefishConfig::MutableInstanceSpecific::set_pause_in_bootloader(bool pause_in_bootloader) {
671 (*Dictionary())[kPauseInBootloader] = pause_in_bootloader;
672 }
pause_in_bootloader() const673 bool CuttlefishConfig::InstanceSpecific::pause_in_bootloader() const {
674 return (*Dictionary())[kPauseInBootloader].asBool();
675 }
676
677 static constexpr char kRunAsDaemon[] = "run_as_daemon";
run_as_daemon() const678 bool CuttlefishConfig::InstanceSpecific::run_as_daemon() const {
679 return (*Dictionary())[kRunAsDaemon].asBool();
680 }
set_run_as_daemon(bool run_as_daemon)681 void CuttlefishConfig::MutableInstanceSpecific::set_run_as_daemon(bool run_as_daemon) {
682 (*Dictionary())[kRunAsDaemon] = run_as_daemon;
683 }
684
685 static constexpr char kEnableMinimalMode[] = "enable_minimal_mode";
enable_minimal_mode() const686 bool CuttlefishConfig::InstanceSpecific::enable_minimal_mode() const {
687 return (*Dictionary())[kEnableMinimalMode].asBool();
688 }
set_enable_minimal_mode(bool enable_minimal_mode)689 void CuttlefishConfig::MutableInstanceSpecific::set_enable_minimal_mode(
690 bool enable_minimal_mode) {
691 (*Dictionary())[kEnableMinimalMode] = enable_minimal_mode;
692 }
693
694 static constexpr char kRunModemSimulator[] = "enable_modem_simulator";
enable_modem_simulator() const695 bool CuttlefishConfig::InstanceSpecific::enable_modem_simulator() const {
696 return (*Dictionary())[kRunModemSimulator].asBool();
697 }
set_enable_modem_simulator(bool enable_modem_simulator)698 void CuttlefishConfig::MutableInstanceSpecific::set_enable_modem_simulator(
699 bool enable_modem_simulator) {
700 (*Dictionary())[kRunModemSimulator] = enable_modem_simulator;
701 }
702
703 static constexpr char kModemSimulatorInstanceNumber[] =
704 "modem_simulator_instance_number";
705 void CuttlefishConfig::MutableInstanceSpecific::
set_modem_simulator_instance_number(int instance_number)706 set_modem_simulator_instance_number(int instance_number) {
707 (*Dictionary())[kModemSimulatorInstanceNumber] = instance_number;
708 }
modem_simulator_instance_number() const709 int CuttlefishConfig::InstanceSpecific::modem_simulator_instance_number()
710 const {
711 return (*Dictionary())[kModemSimulatorInstanceNumber].asInt();
712 }
713
714 static constexpr char kModemSimulatorSimType[] = "modem_simulator_sim_type";
set_modem_simulator_sim_type(int sim_type)715 void CuttlefishConfig::MutableInstanceSpecific::set_modem_simulator_sim_type(
716 int sim_type) {
717 (*Dictionary())[kModemSimulatorSimType] = sim_type;
718 }
modem_simulator_sim_type() const719 int CuttlefishConfig::InstanceSpecific::modem_simulator_sim_type() const {
720 return (*Dictionary())[kModemSimulatorSimType].asInt();
721 }
722
723 static constexpr char kGpuMode[] = "gpu_mode";
gpu_mode() const724 std::string CuttlefishConfig::InstanceSpecific::gpu_mode() const {
725 return (*Dictionary())[kGpuMode].asString();
726 }
set_gpu_mode(const std::string & name)727 void CuttlefishConfig::MutableInstanceSpecific::set_gpu_mode(const std::string& name) {
728 (*Dictionary())[kGpuMode] = name;
729 }
730
731 static constexpr char kGpuAngleFeatureOverridesEnabled[] =
732 "gpu_angle_feature_overrides_enabled";
733 std::string
gpu_angle_feature_overrides_enabled() const734 CuttlefishConfig::InstanceSpecific::gpu_angle_feature_overrides_enabled()
735 const {
736 return (*Dictionary())[kGpuAngleFeatureOverridesEnabled].asString();
737 }
738 void CuttlefishConfig::MutableInstanceSpecific::
set_gpu_angle_feature_overrides_enabled(const std::string & overrides)739 set_gpu_angle_feature_overrides_enabled(const std::string& overrides) {
740 (*Dictionary())[kGpuAngleFeatureOverridesEnabled] = overrides;
741 }
742
743 static constexpr char kGpuAngleFeatureOverridesDisabled[] =
744 "gpu_angle_feature_overrides_disabled";
745 std::string
gpu_angle_feature_overrides_disabled() const746 CuttlefishConfig::InstanceSpecific::gpu_angle_feature_overrides_disabled()
747 const {
748 return (*Dictionary())[kGpuAngleFeatureOverridesDisabled].asString();
749 }
750 void CuttlefishConfig::MutableInstanceSpecific::
set_gpu_angle_feature_overrides_disabled(const std::string & overrides)751 set_gpu_angle_feature_overrides_disabled(const std::string& overrides) {
752 (*Dictionary())[kGpuAngleFeatureOverridesDisabled] = overrides;
753 }
754
755 static constexpr char kGpuCaptureBinary[] = "gpu_capture_binary";
gpu_capture_binary() const756 std::string CuttlefishConfig::InstanceSpecific::gpu_capture_binary() const {
757 return (*Dictionary())[kGpuCaptureBinary].asString();
758 }
set_gpu_capture_binary(const std::string & name)759 void CuttlefishConfig::MutableInstanceSpecific::set_gpu_capture_binary(const std::string& name) {
760 (*Dictionary())[kGpuCaptureBinary] = name;
761 }
762
763 static constexpr char kGpuGfxstreamTransport[] = "gpu_gfxstream_transport";
gpu_gfxstream_transport() const764 std::string CuttlefishConfig::InstanceSpecific::gpu_gfxstream_transport()
765 const {
766 return (*Dictionary())[kGpuGfxstreamTransport].asString();
767 }
set_gpu_gfxstream_transport(const std::string & transport)768 void CuttlefishConfig::MutableInstanceSpecific::set_gpu_gfxstream_transport(
769 const std::string& transport) {
770 (*Dictionary())[kGpuGfxstreamTransport] = transport;
771 }
772
773 static constexpr char kGpuRendererFeatures[] = "gpu_renderer_features";
gpu_renderer_features() const774 std::string CuttlefishConfig::InstanceSpecific::gpu_renderer_features() const {
775 return (*Dictionary())[kGpuRendererFeatures].asString();
776 }
set_gpu_renderer_features(const std::string & transport)777 void CuttlefishConfig::MutableInstanceSpecific::set_gpu_renderer_features(
778 const std::string& transport) {
779 (*Dictionary())[kGpuRendererFeatures] = transport;
780 }
781
782 static constexpr char kGpuContextTypes[] = "gpu_context_types";
gpu_context_types() const783 std::string CuttlefishConfig::InstanceSpecific::gpu_context_types() const {
784 return (*Dictionary())[kGpuContextTypes].asString();
785 }
set_gpu_context_types(const std::string & context_types)786 void CuttlefishConfig::MutableInstanceSpecific::set_gpu_context_types(
787 const std::string& context_types) {
788 (*Dictionary())[kGpuContextTypes] = context_types;
789 }
790
791 static constexpr char kVulkanDriver[] = "guest_vulkan_driver";
guest_vulkan_driver() const792 std::string CuttlefishConfig::InstanceSpecific::guest_vulkan_driver() const {
793 return (*Dictionary())[kVulkanDriver].asString();
794 }
set_guest_vulkan_driver(const std::string & driver)795 void CuttlefishConfig::MutableInstanceSpecific::set_guest_vulkan_driver(
796 const std::string& driver) {
797 (*Dictionary())[kVulkanDriver] = driver;
798 }
799
800 static constexpr char kGuestUsesBgraFramebuffers[] =
801 "guest_uses_bgra_framebuffers";
guest_uses_bgra_framebuffers() const802 bool CuttlefishConfig::InstanceSpecific::guest_uses_bgra_framebuffers() const {
803 return (*Dictionary())[kGuestUsesBgraFramebuffers].asBool();
804 }
805 void CuttlefishConfig::MutableInstanceSpecific::
set_guest_uses_bgra_framebuffers(bool uses_bgra)806 set_guest_uses_bgra_framebuffers(bool uses_bgra) {
807 (*Dictionary())[kGuestUsesBgraFramebuffers] = uses_bgra;
808 }
809
810 static constexpr char kRestartSubprocesses[] = "restart_subprocesses";
restart_subprocesses() const811 bool CuttlefishConfig::InstanceSpecific::restart_subprocesses() const {
812 return (*Dictionary())[kRestartSubprocesses].asBool();
813 }
set_restart_subprocesses(bool restart_subprocesses)814 void CuttlefishConfig::MutableInstanceSpecific::set_restart_subprocesses(bool restart_subprocesses) {
815 (*Dictionary())[kRestartSubprocesses] = restart_subprocesses;
816 }
817
818 static constexpr char kHWComposer[] = "hwcomposer";
hwcomposer() const819 std::string CuttlefishConfig::InstanceSpecific::hwcomposer() const {
820 return (*Dictionary())[kHWComposer].asString();
821 }
set_hwcomposer(const std::string & name)822 void CuttlefishConfig::MutableInstanceSpecific::set_hwcomposer(const std::string& name) {
823 (*Dictionary())[kHWComposer] = name;
824 }
825
826 static constexpr char kEnableGpuUdmabuf[] = "enable_gpu_udmabuf";
set_enable_gpu_udmabuf(const bool enable_gpu_udmabuf)827 void CuttlefishConfig::MutableInstanceSpecific::set_enable_gpu_udmabuf(const bool enable_gpu_udmabuf) {
828 (*Dictionary())[kEnableGpuUdmabuf] = enable_gpu_udmabuf;
829 }
enable_gpu_udmabuf() const830 bool CuttlefishConfig::InstanceSpecific::enable_gpu_udmabuf() const {
831 return (*Dictionary())[kEnableGpuUdmabuf].asBool();
832 }
833
834 static constexpr char kEnableGpuVhostUser[] = "enable_gpu_vhost_user";
set_enable_gpu_vhost_user(const bool enable_gpu_vhost_user)835 void CuttlefishConfig::MutableInstanceSpecific::set_enable_gpu_vhost_user(
836 const bool enable_gpu_vhost_user) {
837 (*Dictionary())[kEnableGpuVhostUser] = enable_gpu_vhost_user;
838 }
enable_gpu_vhost_user() const839 bool CuttlefishConfig::InstanceSpecific::enable_gpu_vhost_user() const {
840 return (*Dictionary())[kEnableGpuVhostUser].asBool();
841 }
842
843 static constexpr char kEnableGpuExternalBlob[] = "enable_gpu_external_blob";
set_enable_gpu_external_blob(const bool enable_gpu_external_blob)844 void CuttlefishConfig::MutableInstanceSpecific::set_enable_gpu_external_blob(
845 const bool enable_gpu_external_blob) {
846 (*Dictionary())[kEnableGpuExternalBlob] = enable_gpu_external_blob;
847 }
enable_gpu_external_blob() const848 bool CuttlefishConfig::InstanceSpecific::enable_gpu_external_blob() const {
849 return (*Dictionary())[kEnableGpuExternalBlob].asBool();
850 }
851
852 static constexpr char kEnableGpuSystemBlob[] = "enable_gpu_system_blob";
set_enable_gpu_system_blob(const bool enable_gpu_system_blob)853 void CuttlefishConfig::MutableInstanceSpecific::set_enable_gpu_system_blob(
854 const bool enable_gpu_system_blob) {
855 (*Dictionary())[kEnableGpuSystemBlob] = enable_gpu_system_blob;
856 }
enable_gpu_system_blob() const857 bool CuttlefishConfig::InstanceSpecific::enable_gpu_system_blob() const {
858 return (*Dictionary())[kEnableGpuSystemBlob].asBool();
859 }
860
861 static constexpr char kEnableAudio[] = "enable_audio";
set_enable_audio(bool enable)862 void CuttlefishConfig::MutableInstanceSpecific::set_enable_audio(bool enable) {
863 (*Dictionary())[kEnableAudio] = enable;
864 }
enable_audio() const865 bool CuttlefishConfig::InstanceSpecific::enable_audio() const {
866 return (*Dictionary())[kEnableAudio].asBool();
867 }
868
869 static constexpr char kEnableGnssGrpcProxy[] = "enable_gnss_grpc_proxy";
set_enable_gnss_grpc_proxy(const bool enable_gnss_grpc_proxy)870 void CuttlefishConfig::MutableInstanceSpecific::set_enable_gnss_grpc_proxy(const bool enable_gnss_grpc_proxy) {
871 (*Dictionary())[kEnableGnssGrpcProxy] = enable_gnss_grpc_proxy;
872 }
enable_gnss_grpc_proxy() const873 bool CuttlefishConfig::InstanceSpecific::enable_gnss_grpc_proxy() const {
874 return (*Dictionary())[kEnableGnssGrpcProxy].asBool();
875 }
876
877 static constexpr char kEnableBootAnimation[] = "enable_bootanimation";
enable_bootanimation() const878 bool CuttlefishConfig::InstanceSpecific::enable_bootanimation() const {
879 return (*Dictionary())[kEnableBootAnimation].asBool();
880 }
set_enable_bootanimation(bool enable_bootanimation)881 void CuttlefishConfig::MutableInstanceSpecific::set_enable_bootanimation(
882 bool enable_bootanimation) {
883 (*Dictionary())[kEnableBootAnimation] = enable_bootanimation;
884 }
885
886 static constexpr char kEnableUsb[] = "enable_usb";
set_enable_usb(bool enable)887 void CuttlefishConfig::MutableInstanceSpecific::set_enable_usb(bool enable) {
888 (*Dictionary())[kEnableUsb] = enable;
889 }
enable_usb() const890 bool CuttlefishConfig::InstanceSpecific::enable_usb() const {
891 return (*Dictionary())[kEnableUsb].asBool();
892 }
893
894 static constexpr char kExtraBootconfigArgsInstanced[] = "extra_bootconfig_args";
895 std::vector<std::string>
extra_bootconfig_args() const896 CuttlefishConfig::InstanceSpecific::extra_bootconfig_args() const {
897 std::string extra_bootconfig_args_str =
898 (*Dictionary())[kExtraBootconfigArgsInstanced].asString();
899 std::vector<std::string> bootconfig;
900 if (!extra_bootconfig_args_str.empty()) {
901 for (const auto& arg :
902 android::base::Split(extra_bootconfig_args_str, " ")) {
903 bootconfig.push_back(arg);
904 }
905 }
906 return bootconfig;
907 }
908
set_extra_bootconfig_args(const std::string & transport)909 void CuttlefishConfig::MutableInstanceSpecific::set_extra_bootconfig_args(
910 const std::string& transport) {
911 (*Dictionary())[kExtraBootconfigArgsInstanced] = transport;
912 }
913
914 static constexpr char kRecordScreen[] = "record_screen";
set_record_screen(bool record_screen)915 void CuttlefishConfig::MutableInstanceSpecific::set_record_screen(
916 bool record_screen) {
917 (*Dictionary())[kRecordScreen] = record_screen;
918 }
record_screen() const919 bool CuttlefishConfig::InstanceSpecific::record_screen() const {
920 return (*Dictionary())[kRecordScreen].asBool();
921 }
922
923 static constexpr char kGem5DebugFile[] = "gem5_debug_file";
gem5_debug_file() const924 std::string CuttlefishConfig::InstanceSpecific::gem5_debug_file() const {
925 return (*Dictionary())[kGem5DebugFile].asString();
926 }
set_gem5_debug_file(const std::string & gem5_debug_file)927 void CuttlefishConfig::MutableInstanceSpecific::set_gem5_debug_file(const std::string& gem5_debug_file) {
928 (*Dictionary())[kGem5DebugFile] = gem5_debug_file;
929 }
930
931 static constexpr char kProtectedVm[] = "protected_vm";
set_protected_vm(bool protected_vm)932 void CuttlefishConfig::MutableInstanceSpecific::set_protected_vm(bool protected_vm) {
933 (*Dictionary())[kProtectedVm] = protected_vm;
934 }
protected_vm() const935 bool CuttlefishConfig::InstanceSpecific::protected_vm() const {
936 return (*Dictionary())[kProtectedVm].asBool();
937 }
938
939 static constexpr char kMte[] = "mte";
set_mte(bool mte)940 void CuttlefishConfig::MutableInstanceSpecific::set_mte(bool mte) {
941 (*Dictionary())[kMte] = mte;
942 }
mte() const943 bool CuttlefishConfig::InstanceSpecific::mte() const {
944 return (*Dictionary())[kMte].asBool();
945 }
946
947 static constexpr char kEnableKernelLog[] = "enable_kernel_log";
set_enable_kernel_log(bool enable_kernel_log)948 void CuttlefishConfig::MutableInstanceSpecific::set_enable_kernel_log(bool enable_kernel_log) {
949 (*Dictionary())[kEnableKernelLog] = enable_kernel_log;
950 }
enable_kernel_log() const951 bool CuttlefishConfig::InstanceSpecific::enable_kernel_log() const {
952 return (*Dictionary())[kEnableKernelLog].asBool();
953 }
954
955 static constexpr char kBootSlot[] = "boot_slot";
set_boot_slot(const std::string & boot_slot)956 void CuttlefishConfig::MutableInstanceSpecific::set_boot_slot(const std::string& boot_slot) {
957 (*Dictionary())[kBootSlot] = boot_slot;
958 }
boot_slot() const959 std::string CuttlefishConfig::InstanceSpecific::boot_slot() const {
960 return (*Dictionary())[kBootSlot].asString();
961 }
962
963 static constexpr char kFailFast[] = "fail_fast";
set_fail_fast(bool fail_fast)964 void CuttlefishConfig::MutableInstanceSpecific::set_fail_fast(bool fail_fast) {
965 (*Dictionary())[kFailFast] = fail_fast;
966 }
fail_fast() const967 bool CuttlefishConfig::InstanceSpecific::fail_fast() const {
968 return (*Dictionary())[kFailFast].asBool();
969 }
970
971 static constexpr char kEnableWebRTC[] = "enable_webrtc";
set_enable_webrtc(bool enable_webrtc)972 void CuttlefishConfig::MutableInstanceSpecific::set_enable_webrtc(bool enable_webrtc) {
973 (*Dictionary())[kEnableWebRTC] = enable_webrtc;
974 }
enable_webrtc() const975 bool CuttlefishConfig::InstanceSpecific::enable_webrtc() const {
976 return (*Dictionary())[kEnableWebRTC].asBool();
977 }
978
979 static constexpr char kWebRTCAssetsDir[] = "webrtc_assets_dir";
set_webrtc_assets_dir(const std::string & webrtc_assets_dir)980 void CuttlefishConfig::MutableInstanceSpecific::set_webrtc_assets_dir(const std::string& webrtc_assets_dir) {
981 (*Dictionary())[kWebRTCAssetsDir] = webrtc_assets_dir;
982 }
webrtc_assets_dir() const983 std::string CuttlefishConfig::InstanceSpecific::webrtc_assets_dir() const {
984 return (*Dictionary())[kWebRTCAssetsDir].asString();
985 }
986
987 static constexpr char kWebrtcTcpPortRange[] = "webrtc_tcp_port_range";
set_webrtc_tcp_port_range(std::pair<uint16_t,uint16_t> range)988 void CuttlefishConfig::MutableInstanceSpecific::set_webrtc_tcp_port_range(
989 std::pair<uint16_t, uint16_t> range) {
990 Json::Value arr(Json::ValueType::arrayValue);
991 arr[0] = range.first;
992 arr[1] = range.second;
993 (*Dictionary())[kWebrtcTcpPortRange] = arr;
994 }
webrtc_tcp_port_range() const995 std::pair<uint16_t, uint16_t> CuttlefishConfig::InstanceSpecific::webrtc_tcp_port_range() const {
996 std::pair<uint16_t, uint16_t> ret;
997 ret.first = (*Dictionary())[kWebrtcTcpPortRange][0].asInt();
998 ret.second = (*Dictionary())[kWebrtcTcpPortRange][1].asInt();
999 return ret;
1000 }
1001
1002 static constexpr char kWebrtcUdpPortRange[] = "webrtc_udp_port_range";
set_webrtc_udp_port_range(std::pair<uint16_t,uint16_t> range)1003 void CuttlefishConfig::MutableInstanceSpecific::set_webrtc_udp_port_range(
1004 std::pair<uint16_t, uint16_t> range) {
1005 Json::Value arr(Json::ValueType::arrayValue);
1006 arr[0] = range.first;
1007 arr[1] = range.second;
1008 (*Dictionary())[kWebrtcUdpPortRange] = arr;
1009 }
webrtc_udp_port_range() const1010 std::pair<uint16_t, uint16_t> CuttlefishConfig::InstanceSpecific::webrtc_udp_port_range() const {
1011 std::pair<uint16_t, uint16_t> ret;
1012 ret.first = (*Dictionary())[kWebrtcUdpPortRange][0].asInt();
1013 ret.second = (*Dictionary())[kWebrtcUdpPortRange][1].asInt();
1014 return ret;
1015 }
1016
1017 static constexpr char kGrpcConfig[] = "grpc_config";
grpc_socket_path() const1018 std::string CuttlefishConfig::InstanceSpecific::grpc_socket_path() const {
1019 return (*Dictionary())[kGrpcConfig].asString();
1020 }
1021
set_grpc_socket_path(const std::string & socket_path)1022 void CuttlefishConfig::MutableInstanceSpecific::set_grpc_socket_path(
1023 const std::string& socket_path) {
1024 (*Dictionary())[kGrpcConfig] = socket_path;
1025 }
1026
1027 static constexpr char kSmt[] = "smt";
set_smt(bool smt)1028 void CuttlefishConfig::MutableInstanceSpecific::set_smt(bool smt) {
1029 (*Dictionary())[kSmt] = smt;
1030 }
smt() const1031 bool CuttlefishConfig::InstanceSpecific::smt() const {
1032 return (*Dictionary())[kSmt].asBool();
1033 }
1034
1035 static constexpr char kCrosvmBinary[] = "crosvm_binary";
crosvm_binary() const1036 std::string CuttlefishConfig::InstanceSpecific::crosvm_binary() const {
1037 return (*Dictionary())[kCrosvmBinary].asString();
1038 }
set_crosvm_binary(const std::string & crosvm_binary)1039 void CuttlefishConfig::MutableInstanceSpecific::set_crosvm_binary(
1040 const std::string& crosvm_binary) {
1041 (*Dictionary())[kCrosvmBinary] = crosvm_binary;
1042 }
1043
SetPath(const std::string & key,const std::string & path)1044 void CuttlefishConfig::MutableInstanceSpecific::SetPath(
1045 const std::string& key, const std::string& path) {
1046 if (!path.empty()) {
1047 (*Dictionary())[key] = AbsolutePath(path);
1048 }
1049 }
1050
1051 static constexpr char kSeccompPolicyDir[] = "seccomp_policy_dir";
set_seccomp_policy_dir(const std::string & seccomp_policy_dir)1052 void CuttlefishConfig::MutableInstanceSpecific::set_seccomp_policy_dir(
1053 const std::string& seccomp_policy_dir) {
1054 if (seccomp_policy_dir.empty()) {
1055 (*Dictionary())[kSeccompPolicyDir] = seccomp_policy_dir;
1056 return;
1057 }
1058 SetPath(kSeccompPolicyDir, seccomp_policy_dir);
1059 }
seccomp_policy_dir() const1060 std::string CuttlefishConfig::InstanceSpecific::seccomp_policy_dir() const {
1061 return (*Dictionary())[kSeccompPolicyDir].asString();
1062 }
1063
1064 static constexpr char kQemuBinaryDir[] = "qemu_binary_dir";
qemu_binary_dir() const1065 std::string CuttlefishConfig::InstanceSpecific::qemu_binary_dir() const {
1066 return (*Dictionary())[kQemuBinaryDir].asString();
1067 }
set_qemu_binary_dir(const std::string & qemu_binary_dir)1068 void CuttlefishConfig::MutableInstanceSpecific::set_qemu_binary_dir(
1069 const std::string& qemu_binary_dir) {
1070 (*Dictionary())[kQemuBinaryDir] = qemu_binary_dir;
1071 }
1072
1073 static constexpr char kVhostNet[] = "vhost_net";
set_vhost_net(bool vhost_net)1074 void CuttlefishConfig::MutableInstanceSpecific::set_vhost_net(bool vhost_net) {
1075 (*Dictionary())[kVhostNet] = vhost_net;
1076 }
vhost_net() const1077 bool CuttlefishConfig::InstanceSpecific::vhost_net() const {
1078 return (*Dictionary())[kVhostNet].asBool();
1079 }
1080
1081 static constexpr char kOpenThreadNodeId[] = "openthread_node_id";
set_openthread_node_id(int node_id)1082 void CuttlefishConfig::MutableInstanceSpecific::set_openthread_node_id(int node_id) {
1083 (*Dictionary())[kOpenThreadNodeId] = node_id;
1084 }
openthread_node_id() const1085 int CuttlefishConfig::InstanceSpecific::openthread_node_id() const {
1086 return (*Dictionary())[kOpenThreadNodeId].asInt();
1087 }
1088
1089 static constexpr char kVhostUserVsock[] = "vhost_user_vsock";
set_vhost_user_vsock(bool vhost_user_vsock)1090 void CuttlefishConfig::MutableInstanceSpecific::set_vhost_user_vsock(
1091 bool vhost_user_vsock) {
1092 (*Dictionary())[kVhostUserVsock] = vhost_user_vsock;
1093 }
vhost_user_vsock() const1094 bool CuttlefishConfig::InstanceSpecific::vhost_user_vsock() const {
1095 return (*Dictionary())[kVhostUserVsock].asBool();
1096 }
1097
1098 static constexpr char kRilDns[] = "ril_dns";
set_ril_dns(const std::string & ril_dns)1099 void CuttlefishConfig::MutableInstanceSpecific::set_ril_dns(const std::string& ril_dns) {
1100 (*Dictionary())[kRilDns] = ril_dns;
1101 }
ril_dns() const1102 std::string CuttlefishConfig::InstanceSpecific::ril_dns() const {
1103 return (*Dictionary())[kRilDns].asString();
1104 }
1105
1106 static constexpr char kRilIpaddr[] = "ril_ipaddr";
set_ril_ipaddr(const std::string & ril_ipaddr)1107 void CuttlefishConfig::MutableInstanceSpecific::set_ril_ipaddr(
1108 const std::string& ril_ipaddr) {
1109 (*Dictionary())[kRilIpaddr] = ril_ipaddr;
1110 }
ril_ipaddr() const1111 std::string CuttlefishConfig::InstanceSpecific::ril_ipaddr() const {
1112 return (*Dictionary())[kRilIpaddr].asString();
1113 }
1114
1115 static constexpr char kRilGateway[] = "ril_gateway";
set_ril_gateway(const std::string & ril_gateway)1116 void CuttlefishConfig::MutableInstanceSpecific::set_ril_gateway(
1117 const std::string& ril_gateway) {
1118 (*Dictionary())[kRilGateway] = ril_gateway;
1119 }
ril_gateway() const1120 std::string CuttlefishConfig::InstanceSpecific::ril_gateway() const {
1121 return (*Dictionary())[kRilGateway].asString();
1122 }
1123
1124 static constexpr char kRilBroadcast[] = "ril_broadcast";
set_ril_broadcast(const std::string & ril_broadcast)1125 void CuttlefishConfig::MutableInstanceSpecific::set_ril_broadcast(
1126 const std::string& ril_broadcast) {
1127 (*Dictionary())[kRilBroadcast] = ril_broadcast;
1128 }
ril_broadcast() const1129 std::string CuttlefishConfig::InstanceSpecific::ril_broadcast() const {
1130 return (*Dictionary())[kRilBroadcast].asString();
1131 }
1132
1133 static constexpr char kRilPrefixlen[] = "ril_prefixlen";
set_ril_prefixlen(uint8_t ril_prefixlen)1134 void CuttlefishConfig::MutableInstanceSpecific::set_ril_prefixlen(
1135 uint8_t ril_prefixlen) {
1136 (*Dictionary())[kRilPrefixlen] = static_cast<Json::UInt>(ril_prefixlen);
1137 }
ril_prefixlen() const1138 uint8_t CuttlefishConfig::InstanceSpecific::ril_prefixlen() const {
1139 return static_cast<uint8_t>((*Dictionary())[kRilPrefixlen].asUInt());
1140 }
1141
1142 static constexpr char kDisplayConfigs[] = "display_configs";
1143 static constexpr char kXRes[] = "x_res";
1144 static constexpr char kYRes[] = "y_res";
1145 static constexpr char kDpi[] = "dpi";
1146 static constexpr char kRefreshRateHz[] = "refresh_rate_hz";
1147 std::vector<CuttlefishConfig::DisplayConfig>
display_configs() const1148 CuttlefishConfig::InstanceSpecific::display_configs() const {
1149 std::vector<DisplayConfig> display_configs;
1150 for (auto& display_config_json : (*Dictionary())[kDisplayConfigs]) {
1151 DisplayConfig display_config = {};
1152 display_config.width = display_config_json[kXRes].asInt();
1153 display_config.height = display_config_json[kYRes].asInt();
1154 display_config.dpi = display_config_json[kDpi].asInt();
1155 display_config.refresh_rate_hz =
1156 display_config_json[kRefreshRateHz].asInt();
1157 display_configs.emplace_back(display_config);
1158 }
1159 return display_configs;
1160 }
set_display_configs(const std::vector<DisplayConfig> & display_configs)1161 void CuttlefishConfig::MutableInstanceSpecific::set_display_configs(
1162 const std::vector<DisplayConfig>& display_configs) {
1163 Json::Value display_configs_json(Json::arrayValue);
1164
1165 for (const DisplayConfig& display_configs : display_configs) {
1166 Json::Value display_config_json(Json::objectValue);
1167 display_config_json[kXRes] = display_configs.width;
1168 display_config_json[kYRes] = display_configs.height;
1169 display_config_json[kDpi] = display_configs.dpi;
1170 display_config_json[kRefreshRateHz] = display_configs.refresh_rate_hz;
1171 display_configs_json.append(display_config_json);
1172 }
1173
1174 (*Dictionary())[kDisplayConfigs] = display_configs_json;
1175 }
1176
1177 static constexpr char kTouchpadConfigs[] = "touchpad_configs";
1178
Serialize(const CuttlefishConfig::TouchpadConfig & config)1179 Json::Value CuttlefishConfig::TouchpadConfig::Serialize(
1180 const CuttlefishConfig::TouchpadConfig& config) {
1181 Json::Value config_json(Json::objectValue);
1182 config_json[kXRes] = config.width;
1183 config_json[kYRes] = config.height;
1184
1185 return config_json;
1186 }
1187
Deserialize(const Json::Value & config_json)1188 CuttlefishConfig::TouchpadConfig CuttlefishConfig::TouchpadConfig::Deserialize(
1189 const Json::Value& config_json) {
1190 TouchpadConfig touchpad_config = {};
1191 touchpad_config.width = config_json[kXRes].asInt();
1192 touchpad_config.height = config_json[kYRes].asInt();
1193
1194 return touchpad_config;
1195 }
1196
1197 std::vector<CuttlefishConfig::TouchpadConfig>
touchpad_configs() const1198 CuttlefishConfig::InstanceSpecific::touchpad_configs() const {
1199 std::vector<TouchpadConfig> touchpad_configs;
1200 for (auto& touchpad_config_json : (*Dictionary())[kTouchpadConfigs]) {
1201 auto touchpad_config = TouchpadConfig::Deserialize(touchpad_config_json);
1202 touchpad_configs.emplace_back(touchpad_config);
1203 }
1204 return touchpad_configs;
1205 }
set_touchpad_configs(const std::vector<TouchpadConfig> & touchpad_configs)1206 void CuttlefishConfig::MutableInstanceSpecific::set_touchpad_configs(
1207 const std::vector<TouchpadConfig>& touchpad_configs) {
1208 Json::Value touchpad_configs_json(Json::arrayValue);
1209
1210 for (const TouchpadConfig& touchpad_config : touchpad_configs) {
1211 touchpad_configs_json.append(TouchpadConfig::Serialize(touchpad_config));
1212 }
1213
1214 (*Dictionary())[kTouchpadConfigs] = touchpad_configs_json;
1215 }
1216
1217 static constexpr char kTargetArch[] = "target_arch";
set_target_arch(Arch target_arch)1218 void CuttlefishConfig::MutableInstanceSpecific::set_target_arch(
1219 Arch target_arch) {
1220 (*Dictionary())[kTargetArch] = static_cast<int>(target_arch);
1221 }
target_arch() const1222 Arch CuttlefishConfig::InstanceSpecific::target_arch() const {
1223 return static_cast<Arch>((*Dictionary())[kTargetArch].asInt());
1224 }
1225
1226 static constexpr char kEnableSandbox[] = "enable_sandbox";
set_enable_sandbox(const bool enable_sandbox)1227 void CuttlefishConfig::MutableInstanceSpecific::set_enable_sandbox(const bool enable_sandbox) {
1228 (*Dictionary())[kEnableSandbox] = enable_sandbox;
1229 }
enable_sandbox() const1230 bool CuttlefishConfig::InstanceSpecific::enable_sandbox() const {
1231 return (*Dictionary())[kEnableSandbox].asBool();
1232 }
1233 static constexpr char kEnableVirtiofs[] = "enable_virtiofs";
set_enable_virtiofs(const bool enable_virtiofs)1234 void CuttlefishConfig::MutableInstanceSpecific::set_enable_virtiofs(
1235 const bool enable_virtiofs) {
1236 (*Dictionary())[kEnableVirtiofs] = enable_virtiofs;
1237 }
enable_virtiofs() const1238 bool CuttlefishConfig::InstanceSpecific::enable_virtiofs() const {
1239 return (*Dictionary())[kEnableVirtiofs].asBool();
1240 }
1241 static constexpr char kConsole[] = "console";
set_console(bool console)1242 void CuttlefishConfig::MutableInstanceSpecific::set_console(bool console) {
1243 (*Dictionary())[kConsole] = console;
1244 }
console() const1245 bool CuttlefishConfig::InstanceSpecific::console() const {
1246 return (*Dictionary())[kConsole].asBool();
1247 }
console_dev() const1248 std::string CuttlefishConfig::InstanceSpecific::console_dev() const {
1249 auto can_use_virtio_console = !kgdb() && !use_bootloader();
1250 std::string console_dev;
1251 if (can_use_virtio_console || config_->vm_manager() == VmmMode::kGem5) {
1252 // If kgdb and the bootloader are disabled, the Android serial console
1253 // spawns on a virtio-console port. If the bootloader is enabled, virtio
1254 // console can't be used since uboot doesn't support it.
1255 console_dev = "hvc1";
1256 } else {
1257 // QEMU and Gem5 emulate pl011 on ARM/ARM64, but QEMU and crosvm on other
1258 // architectures emulate ns16550a/uart8250 instead.
1259 Arch target = target_arch();
1260 if ((target == Arch::Arm64 || target == Arch::Arm) &&
1261 config_->vm_manager() != VmmMode::kCrosvm) {
1262 console_dev = "ttyAMA0";
1263 } else {
1264 console_dev = "ttyS0";
1265 }
1266 }
1267 return console_dev;
1268 }
1269
logcat_pipe_name() const1270 std::string CuttlefishConfig::InstanceSpecific::logcat_pipe_name() const {
1271 return AbsolutePath(PerInstanceInternalPath("logcat-pipe"));
1272 }
1273
restore_adbd_pipe_name() const1274 std::string CuttlefishConfig::InstanceSpecific::restore_adbd_pipe_name() const {
1275 return AbsolutePath(PerInstanceInternalPath("restore-pipe-adbd"));
1276 }
1277
access_kregistry_path() const1278 std::string CuttlefishConfig::InstanceSpecific::access_kregistry_path() const {
1279 return AbsolutePath(PerInstancePath("access-kregistry"));
1280 }
1281
hwcomposer_pmem_path() const1282 std::string CuttlefishConfig::InstanceSpecific::hwcomposer_pmem_path() const {
1283 return AbsolutePath(PerInstancePath("hwcomposer-pmem"));
1284 }
1285
pstore_path() const1286 std::string CuttlefishConfig::InstanceSpecific::pstore_path() const {
1287 return AbsolutePath(PerInstancePath("pstore"));
1288 }
1289
pflash_path() const1290 std::string CuttlefishConfig::InstanceSpecific::pflash_path() const {
1291 return AbsolutePath(PerInstancePath("pflash.img"));
1292 }
1293
console_path() const1294 std::string CuttlefishConfig::InstanceSpecific::console_path() const {
1295 return AbsolutePath(PerInstancePath("console"));
1296 }
1297
logcat_path() const1298 std::string CuttlefishConfig::InstanceSpecific::logcat_path() const {
1299 return AbsolutePath(PerInstanceLogPath("logcat"));
1300 }
1301
launcher_monitor_socket_path() const1302 std::string CuttlefishConfig::InstanceSpecific::launcher_monitor_socket_path()
1303 const {
1304 return AbsolutePath(PerInstanceUdsPath("launcher_monitor.sock"));
1305 }
1306
1307 static constexpr char kModemSimulatorPorts[] = "modem_simulator_ports";
modem_simulator_ports() const1308 std::string CuttlefishConfig::InstanceSpecific::modem_simulator_ports() const {
1309 return (*Dictionary())[kModemSimulatorPorts].asString();
1310 }
set_modem_simulator_ports(const std::string & modem_simulator_ports)1311 void CuttlefishConfig::MutableInstanceSpecific::set_modem_simulator_ports(
1312 const std::string& modem_simulator_ports) {
1313 (*Dictionary())[kModemSimulatorPorts] = modem_simulator_ports;
1314 }
1315
launcher_log_path() const1316 std::string CuttlefishConfig::InstanceSpecific::launcher_log_path() const {
1317 return AbsolutePath(PerInstanceLogPath("launcher.log"));
1318 }
1319
metadata_image() const1320 std::string CuttlefishConfig::InstanceSpecific::metadata_image() const {
1321 return AbsolutePath(PerInstancePath("metadata.img"));
1322 }
1323
misc_image() const1324 std::string CuttlefishConfig::InstanceSpecific::misc_image() const {
1325 return AbsolutePath(PerInstancePath("misc.img"));
1326 }
1327
sdcard_path() const1328 std::string CuttlefishConfig::InstanceSpecific::sdcard_path() const {
1329 return AbsolutePath(PerInstancePath("sdcard.img"));
1330 }
1331
sdcard_overlay_path() const1332 std::string CuttlefishConfig::InstanceSpecific::sdcard_overlay_path() const {
1333 return AbsolutePath(PerInstancePath("sdcard_overlay.img"));
1334 }
1335
persistent_composite_disk_path() const1336 std::string CuttlefishConfig::InstanceSpecific::persistent_composite_disk_path()
1337 const {
1338 return AbsolutePath(PerInstancePath("persistent_composite.img"));
1339 }
1340
1341 std::string
persistent_composite_overlay_path() const1342 CuttlefishConfig::InstanceSpecific::persistent_composite_overlay_path() const {
1343 return AbsolutePath(PerInstancePath("persistent_composite_overlay.img"));
1344 }
1345
persistent_ap_composite_disk_path() const1346 std::string CuttlefishConfig::InstanceSpecific::persistent_ap_composite_disk_path()
1347 const {
1348 return AbsolutePath(PerInstancePath("ap_persistent_composite.img"));
1349 }
1350
1351 std::string
persistent_ap_composite_overlay_path() const1352 CuttlefishConfig::InstanceSpecific::persistent_ap_composite_overlay_path()
1353 const {
1354 return AbsolutePath(PerInstancePath("ap_persistent_composite_overlay.img"));
1355 }
1356
os_composite_disk_path() const1357 std::string CuttlefishConfig::InstanceSpecific::os_composite_disk_path()
1358 const {
1359 return AbsolutePath(PerInstancePath("os_composite.img"));
1360 }
1361
ap_composite_disk_path() const1362 std::string CuttlefishConfig::InstanceSpecific::ap_composite_disk_path()
1363 const {
1364 return AbsolutePath(PerInstancePath("ap_composite.img"));
1365 }
1366
vbmeta_path() const1367 std::string CuttlefishConfig::InstanceSpecific::vbmeta_path() const {
1368 return AbsolutePath(PerInstancePath("persistent_vbmeta.img"));
1369 }
1370
ap_vbmeta_path() const1371 std::string CuttlefishConfig::InstanceSpecific::ap_vbmeta_path() const {
1372 return AbsolutePath(PerInstancePath("ap_vbmeta.img"));
1373 }
1374
uboot_env_image_path() const1375 std::string CuttlefishConfig::InstanceSpecific::uboot_env_image_path() const {
1376 return AbsolutePath(PerInstancePath("uboot_env.img"));
1377 }
1378
ap_uboot_env_image_path() const1379 std::string CuttlefishConfig::InstanceSpecific::ap_uboot_env_image_path() const {
1380 return AbsolutePath(PerInstancePath("ap_uboot_env.img"));
1381 }
1382
chromeos_state_image() const1383 std::string CuttlefishConfig::InstanceSpecific::chromeos_state_image() const {
1384 return AbsolutePath(PerInstancePath("chromeos_state.img"));
1385 }
1386
esp_image_path() const1387 std::string CuttlefishConfig::InstanceSpecific::esp_image_path() const {
1388 return AbsolutePath(PerInstancePath("esp.img"));
1389 }
1390
ap_esp_image_path() const1391 std::string CuttlefishConfig::InstanceSpecific::ap_esp_image_path() const {
1392 return AbsolutePath(PerInstancePath("ap_esp.img"));
1393 }
1394
otheros_esp_grub_config() const1395 std::string CuttlefishConfig::InstanceSpecific::otheros_esp_grub_config() const {
1396 return AbsolutePath(PerInstancePath("grub.cfg"));
1397 }
1398
ap_esp_grub_config() const1399 std::string CuttlefishConfig::InstanceSpecific::ap_esp_grub_config() const {
1400 return AbsolutePath(PerInstancePath("ap_grub.cfg"));
1401 }
1402
1403 static constexpr char kMobileBridgeName[] = "mobile_bridge_name";
1404
audio_server_path() const1405 std::string CuttlefishConfig::InstanceSpecific::audio_server_path() const {
1406 return AbsolutePath(PerInstanceInternalUdsPath("audio_server.sock"));
1407 }
1408
boot_flow() const1409 CuttlefishConfig::InstanceSpecific::BootFlow CuttlefishConfig::InstanceSpecific::boot_flow() const {
1410 const bool android_efi_loader_flow_used = !android_efi_loader().empty();
1411
1412 const bool chromeos_disk_flow_used = !chromeos_disk().empty();
1413
1414 const bool chromeos_flow_used =
1415 !chromeos_kernel_path().empty() || !chromeos_root_image().empty();
1416
1417 const bool linux_flow_used = !linux_kernel_path().empty()
1418 || !linux_initramfs_path().empty()
1419 || !linux_root_image().empty();
1420
1421 const bool fuchsia_flow_used = !fuchsia_zedboot_path().empty()
1422 || !fuchsia_root_image().empty()
1423 || !fuchsia_multiboot_bin_path().empty();
1424
1425 if (android_efi_loader_flow_used) {
1426 return BootFlow::AndroidEfiLoader;
1427 } else if (chromeos_flow_used) {
1428 return BootFlow::ChromeOs;
1429 } else if (chromeos_disk_flow_used) {
1430 return BootFlow::ChromeOsDisk;
1431 } else if (linux_flow_used) {
1432 return BootFlow::Linux;
1433 } else if (fuchsia_flow_used) {
1434 return BootFlow::Fuchsia;
1435 } else {
1436 return BootFlow::Android;
1437 }
1438 }
1439
mobile_bridge_name() const1440 std::string CuttlefishConfig::InstanceSpecific::mobile_bridge_name() const {
1441 return (*Dictionary())[kMobileBridgeName].asString();
1442 }
set_mobile_bridge_name(const std::string & mobile_bridge_name)1443 void CuttlefishConfig::MutableInstanceSpecific::set_mobile_bridge_name(
1444 const std::string& mobile_bridge_name) {
1445 (*Dictionary())[kMobileBridgeName] = mobile_bridge_name;
1446 }
1447
1448 static constexpr char kMobileTapName[] = "mobile_tap_name";
mobile_tap_name() const1449 std::string CuttlefishConfig::InstanceSpecific::mobile_tap_name() const {
1450 return (*Dictionary())[kMobileTapName].asString();
1451 }
set_mobile_tap_name(const std::string & mobile_tap_name)1452 void CuttlefishConfig::MutableInstanceSpecific::set_mobile_tap_name(
1453 const std::string& mobile_tap_name) {
1454 (*Dictionary())[kMobileTapName] = mobile_tap_name;
1455 }
1456
1457 static constexpr char kMobileMac[] = "mobile_mac";
mobile_mac() const1458 std::string CuttlefishConfig::InstanceSpecific::mobile_mac() const {
1459 return (*Dictionary())[kMobileMac].asString();
1460 }
set_mobile_mac(const std::string & mac)1461 void CuttlefishConfig::MutableInstanceSpecific::set_mobile_mac(
1462 const std::string& mac) {
1463 (*Dictionary())[kMobileMac] = mac;
1464 }
1465
1466 // TODO(b/199103204): remove this as well when
1467 // PRODUCT_ENFORCE_MAC80211_HWSIM is removed
1468 static constexpr char kWifiTapName[] = "wifi_tap_name";
wifi_tap_name() const1469 std::string CuttlefishConfig::InstanceSpecific::wifi_tap_name() const {
1470 return (*Dictionary())[kWifiTapName].asString();
1471 }
set_wifi_tap_name(const std::string & wifi_tap_name)1472 void CuttlefishConfig::MutableInstanceSpecific::set_wifi_tap_name(
1473 const std::string& wifi_tap_name) {
1474 (*Dictionary())[kWifiTapName] = wifi_tap_name;
1475 }
1476
1477 static constexpr char kWifiBridgeName[] = "wifi_bridge_name";
wifi_bridge_name() const1478 std::string CuttlefishConfig::InstanceSpecific::wifi_bridge_name() const {
1479 return (*Dictionary())[kWifiBridgeName].asString();
1480 }
set_wifi_bridge_name(const std::string & wifi_bridge_name)1481 void CuttlefishConfig::MutableInstanceSpecific::set_wifi_bridge_name(
1482 const std::string& wifi_bridge_name) {
1483 (*Dictionary())[kWifiBridgeName] = wifi_bridge_name;
1484 }
1485
1486 static constexpr char kWifiMac[] = "wifi_mac";
wifi_mac() const1487 std::string CuttlefishConfig::InstanceSpecific::wifi_mac() const {
1488 return (*Dictionary())[kWifiMac].asString();
1489 }
set_wifi_mac(const std::string & mac)1490 void CuttlefishConfig::MutableInstanceSpecific::set_wifi_mac(
1491 const std::string& mac) {
1492 (*Dictionary())[kWifiMac] = mac;
1493 }
1494
1495 static constexpr char kUseBridgedWifiTap[] = "use_bridged_wifi_tap";
use_bridged_wifi_tap() const1496 bool CuttlefishConfig::InstanceSpecific::use_bridged_wifi_tap() const {
1497 return (*Dictionary())[kUseBridgedWifiTap].asBool();
1498 }
set_use_bridged_wifi_tap(bool use_bridged_wifi_tap)1499 void CuttlefishConfig::MutableInstanceSpecific::set_use_bridged_wifi_tap(
1500 bool use_bridged_wifi_tap) {
1501 (*Dictionary())[kUseBridgedWifiTap] = use_bridged_wifi_tap;
1502 }
1503
1504 static constexpr char kEthernetTapName[] = "ethernet_tap_name";
ethernet_tap_name() const1505 std::string CuttlefishConfig::InstanceSpecific::ethernet_tap_name() const {
1506 return (*Dictionary())[kEthernetTapName].asString();
1507 }
set_ethernet_tap_name(const std::string & ethernet_tap_name)1508 void CuttlefishConfig::MutableInstanceSpecific::set_ethernet_tap_name(
1509 const std::string& ethernet_tap_name) {
1510 (*Dictionary())[kEthernetTapName] = ethernet_tap_name;
1511 }
1512
1513 static constexpr char kEthernetBridgeName[] = "ethernet_bridge_name";
ethernet_bridge_name() const1514 std::string CuttlefishConfig::InstanceSpecific::ethernet_bridge_name() const {
1515 return (*Dictionary())[kEthernetBridgeName].asString();
1516 }
set_ethernet_bridge_name(const std::string & ethernet_bridge_name)1517 void CuttlefishConfig::MutableInstanceSpecific::set_ethernet_bridge_name(
1518 const std::string& ethernet_bridge_name) {
1519 (*Dictionary())[kEthernetBridgeName] = ethernet_bridge_name;
1520 }
1521
1522 static constexpr char kEthernetMac[] = "ethernet_mac";
ethernet_mac() const1523 std::string CuttlefishConfig::InstanceSpecific::ethernet_mac() const {
1524 return (*Dictionary())[kEthernetMac].asString();
1525 }
set_ethernet_mac(const std::string & mac)1526 void CuttlefishConfig::MutableInstanceSpecific::set_ethernet_mac(
1527 const std::string& mac) {
1528 (*Dictionary())[kEthernetMac] = mac;
1529 }
1530
1531 static constexpr char kEthernetIPV6[] = "ethernet_ipv6";
ethernet_ipv6() const1532 std::string CuttlefishConfig::InstanceSpecific::ethernet_ipv6() const {
1533 return (*Dictionary())[kEthernetIPV6].asString();
1534 }
set_ethernet_ipv6(const std::string & ip)1535 void CuttlefishConfig::MutableInstanceSpecific::set_ethernet_ipv6(
1536 const std::string& ip) {
1537 (*Dictionary())[kEthernetIPV6] = ip;
1538 }
1539
1540 static constexpr char kUseAllocd[] = "use_allocd";
use_allocd() const1541 bool CuttlefishConfig::InstanceSpecific::use_allocd() const {
1542 return (*Dictionary())[kUseAllocd].asBool();
1543 }
set_use_allocd(bool use_allocd)1544 void CuttlefishConfig::MutableInstanceSpecific::set_use_allocd(
1545 bool use_allocd) {
1546 (*Dictionary())[kUseAllocd] = use_allocd;
1547 }
1548
1549 static constexpr char kSessionId[] = "session_id";
session_id() const1550 uint32_t CuttlefishConfig::InstanceSpecific::session_id() const {
1551 return (*Dictionary())[kSessionId].asUInt();
1552 }
set_session_id(uint32_t session_id)1553 void CuttlefishConfig::MutableInstanceSpecific::set_session_id(
1554 uint32_t session_id) {
1555 (*Dictionary())[kSessionId] = session_id;
1556 }
1557
1558 static constexpr char kVsockGuestCid[] = "vsock_guest_cid";
vsock_guest_cid() const1559 int CuttlefishConfig::InstanceSpecific::vsock_guest_cid() const {
1560 return (*Dictionary())[kVsockGuestCid].asInt();
1561 }
set_vsock_guest_cid(int vsock_guest_cid)1562 void CuttlefishConfig::MutableInstanceSpecific::set_vsock_guest_cid(
1563 int vsock_guest_cid) {
1564 (*Dictionary())[kVsockGuestCid] = vsock_guest_cid;
1565 }
1566
1567 static constexpr char kVsockGuestGroup[] = "vsock_guest_group";
vsock_guest_group() const1568 std::string CuttlefishConfig::InstanceSpecific::vsock_guest_group() const {
1569 return (*Dictionary())[kVsockGuestGroup].asString();
1570 }
set_vsock_guest_group(const std::string & vsock_guest_group)1571 void CuttlefishConfig::MutableInstanceSpecific::set_vsock_guest_group(
1572 const std::string& vsock_guest_group) {
1573 (*Dictionary())[kVsockGuestGroup] = vsock_guest_group;
1574 }
1575
1576 static constexpr char kUuid[] = "uuid";
uuid() const1577 std::string CuttlefishConfig::InstanceSpecific::uuid() const {
1578 return (*Dictionary())[kUuid].asString();
1579 }
set_uuid(const std::string & uuid)1580 void CuttlefishConfig::MutableInstanceSpecific::set_uuid(const std::string& uuid) {
1581 (*Dictionary())[kUuid] = uuid;
1582 }
1583
1584 static constexpr char kEnvironmentName[] = "environment_name";
environment_name() const1585 std::string CuttlefishConfig::InstanceSpecific::environment_name() const {
1586 return (*Dictionary())[kEnvironmentName].asString();
1587 }
set_environment_name(const std::string & environment_name)1588 void CuttlefishConfig::MutableInstanceSpecific::set_environment_name(
1589 const std::string& environment_name) {
1590 (*Dictionary())[kEnvironmentName] = environment_name;
1591 }
1592
CrosvmSocketPath() const1593 std::string CuttlefishConfig::InstanceSpecific::CrosvmSocketPath() const {
1594 return PerInstanceInternalUdsPath("crosvm_control.sock");
1595 }
1596
OpenwrtCrosvmSocketPath() const1597 std::string CuttlefishConfig::InstanceSpecific::OpenwrtCrosvmSocketPath()
1598 const {
1599 return PerInstanceInternalUdsPath("ap_control.sock");
1600 }
1601
1602 static constexpr char kHostPort[] = "adb_host_port";
adb_host_port() const1603 int CuttlefishConfig::InstanceSpecific::adb_host_port() const {
1604 return (*Dictionary())[kHostPort].asInt();
1605 }
set_adb_host_port(int port)1606 void CuttlefishConfig::MutableInstanceSpecific::set_adb_host_port(int port) {
1607 (*Dictionary())[kHostPort] = port;
1608 }
1609
1610 static constexpr char kFastbootHostPort[] = "fastboot_host_port";
fastboot_host_port() const1611 int CuttlefishConfig::InstanceSpecific::fastboot_host_port() const {
1612 return (*Dictionary())[kFastbootHostPort].asInt();
1613 }
set_fastboot_host_port(int port)1614 void CuttlefishConfig::MutableInstanceSpecific::set_fastboot_host_port(int port) {
1615 (*Dictionary())[kFastbootHostPort] = port;
1616 }
1617
1618 static constexpr char kModemSimulatorId[] = "modem_simulator_host_id";
modem_simulator_host_id() const1619 int CuttlefishConfig::InstanceSpecific::modem_simulator_host_id() const {
1620 return (*Dictionary())[kModemSimulatorId].asInt();
1621 }
set_modem_simulator_host_id(int id)1622 void CuttlefishConfig::MutableInstanceSpecific::set_modem_simulator_host_id(
1623 int id) {
1624 (*Dictionary())[kModemSimulatorId] = id;
1625 }
1626
1627 static constexpr char kAdbIPAndPort[] = "adb_ip_and_port";
adb_ip_and_port() const1628 std::string CuttlefishConfig::InstanceSpecific::adb_ip_and_port() const {
1629 return (*Dictionary())[kAdbIPAndPort].asString();
1630 }
set_adb_ip_and_port(const std::string & ip_port)1631 void CuttlefishConfig::MutableInstanceSpecific::set_adb_ip_and_port(
1632 const std::string& ip_port) {
1633 (*Dictionary())[kAdbIPAndPort] = ip_port;
1634 }
1635
adb_device_name() const1636 std::string CuttlefishConfig::InstanceSpecific::adb_device_name() const {
1637 if (adb_ip_and_port() != "") {
1638 return adb_ip_and_port();
1639 }
1640 LOG(ERROR) << "no adb_mode found, returning bad device name";
1641 return "NO_ADB_MODE_SET_NO_VALID_DEVICE_NAME";
1642 }
1643
1644 static constexpr char kQemuVncServerPort[] = "qemu_vnc_server_port";
qemu_vnc_server_port() const1645 int CuttlefishConfig::InstanceSpecific::qemu_vnc_server_port() const {
1646 return (*Dictionary())[kQemuVncServerPort].asInt();
1647 }
set_qemu_vnc_server_port(int qemu_vnc_server_port)1648 void CuttlefishConfig::MutableInstanceSpecific::set_qemu_vnc_server_port(
1649 int qemu_vnc_server_port) {
1650 (*Dictionary())[kQemuVncServerPort] = qemu_vnc_server_port;
1651 }
1652
1653 static constexpr char kTombstoneReceiverPort[] = "tombstone_receiver_port";
tombstone_receiver_port() const1654 int CuttlefishConfig::InstanceSpecific::tombstone_receiver_port() const {
1655 return (*Dictionary())[kTombstoneReceiverPort].asInt();
1656 }
set_tombstone_receiver_port(int tombstone_receiver_port)1657 void CuttlefishConfig::MutableInstanceSpecific::set_tombstone_receiver_port(int tombstone_receiver_port) {
1658 (*Dictionary())[kTombstoneReceiverPort] = tombstone_receiver_port;
1659 }
1660
1661 static constexpr char kAudioControlServerPort[] = "audiocontrol_server_port";
audiocontrol_server_port() const1662 int CuttlefishConfig::InstanceSpecific::audiocontrol_server_port() const {
1663 return (*Dictionary())[kAudioControlServerPort].asInt();
1664 }
set_audiocontrol_server_port(int audiocontrol_server_port)1665 void CuttlefishConfig::MutableInstanceSpecific::set_audiocontrol_server_port(int audiocontrol_server_port) {
1666 (*Dictionary())[kAudioControlServerPort] = audiocontrol_server_port;
1667 }
1668
1669 static constexpr char kConfigServerPort[] = "config_server_port";
config_server_port() const1670 int CuttlefishConfig::InstanceSpecific::config_server_port() const {
1671 return (*Dictionary())[kConfigServerPort].asInt();
1672 }
set_config_server_port(int config_server_port)1673 void CuttlefishConfig::MutableInstanceSpecific::set_config_server_port(int config_server_port) {
1674 (*Dictionary())[kConfigServerPort] = config_server_port;
1675 }
1676
1677 static constexpr char kLightsServerPort[] = "lights_server_port";
lights_server_port() const1678 int CuttlefishConfig::InstanceSpecific::lights_server_port() const {
1679 return (*Dictionary())[kLightsServerPort].asInt();
1680 }
set_lights_server_port(int lights_server_port)1681 void CuttlefishConfig::MutableInstanceSpecific::set_lights_server_port(int lights_server_port) {
1682 (*Dictionary())[kLightsServerPort] = lights_server_port;
1683 }
1684
1685 static constexpr char kCameraServerPort[] = "camera_server_port";
camera_server_port() const1686 int CuttlefishConfig::InstanceSpecific::camera_server_port() const {
1687 return (*Dictionary())[kCameraServerPort].asInt();
1688 }
set_camera_server_port(int camera_server_port)1689 void CuttlefishConfig::MutableInstanceSpecific::set_camera_server_port(
1690 int camera_server_port) {
1691 (*Dictionary())[kCameraServerPort] = camera_server_port;
1692 }
1693
1694 static constexpr char kWebrtcDeviceId[] = "webrtc_device_id";
set_webrtc_device_id(const std::string & id)1695 void CuttlefishConfig::MutableInstanceSpecific::set_webrtc_device_id(
1696 const std::string& id) {
1697 (*Dictionary())[kWebrtcDeviceId] = id;
1698 }
webrtc_device_id() const1699 std::string CuttlefishConfig::InstanceSpecific::webrtc_device_id() const {
1700 return (*Dictionary())[kWebrtcDeviceId].asString();
1701 }
1702
1703 static constexpr char kGroupId[] = "group_id";
set_group_id(const std::string & id)1704 void CuttlefishConfig::MutableInstanceSpecific::set_group_id(
1705 const std::string& id) {
1706 (*Dictionary())[kGroupId] = id;
1707 }
group_id() const1708 std::string CuttlefishConfig::InstanceSpecific::group_id() const {
1709 return (*Dictionary())[kGroupId].asString();
1710 }
1711
1712 static constexpr char kStartSigServer[] = "webrtc_start_sig_server";
set_start_webrtc_signaling_server(bool start)1713 void CuttlefishConfig::MutableInstanceSpecific::set_start_webrtc_signaling_server(bool start) {
1714 (*Dictionary())[kStartSigServer] = start;
1715 }
start_webrtc_sig_server() const1716 bool CuttlefishConfig::InstanceSpecific::start_webrtc_sig_server() const {
1717 return (*Dictionary())[kStartSigServer].asBool();
1718 }
1719
1720 static constexpr char kStartSigServerProxy[] = "webrtc_start_sig_server_proxy";
1721 void CuttlefishConfig::MutableInstanceSpecific::
set_start_webrtc_sig_server_proxy(bool start)1722 set_start_webrtc_sig_server_proxy(bool start) {
1723 (*Dictionary())[kStartSigServerProxy] = start;
1724 }
start_webrtc_sig_server_proxy() const1725 bool CuttlefishConfig::InstanceSpecific::start_webrtc_sig_server_proxy() const {
1726 return (*Dictionary())[kStartSigServerProxy].asBool();
1727 }
1728
1729 static constexpr char kStartRootcanal[] = "start_rootcanal";
set_start_rootcanal(bool start)1730 void CuttlefishConfig::MutableInstanceSpecific::set_start_rootcanal(
1731 bool start) {
1732 (*Dictionary())[kStartRootcanal] = start;
1733 }
start_rootcanal() const1734 bool CuttlefishConfig::InstanceSpecific::start_rootcanal() const {
1735 return (*Dictionary())[kStartRootcanal].asBool();
1736 }
1737
1738 static constexpr char kStartCasimir[] = "start_casimir";
set_start_casimir(bool start)1739 void CuttlefishConfig::MutableInstanceSpecific::set_start_casimir(bool start) {
1740 (*Dictionary())[kStartCasimir] = start;
1741 }
start_casimir() const1742 bool CuttlefishConfig::InstanceSpecific::start_casimir() const {
1743 return (*Dictionary())[kStartCasimir].asBool();
1744 }
1745
1746 static constexpr char kStartPica[] = "start_pica";
set_start_pica(bool start)1747 void CuttlefishConfig::MutableInstanceSpecific::set_start_pica(
1748 bool start) {
1749 (*Dictionary())[kStartPica] = start;
1750 }
start_pica() const1751 bool CuttlefishConfig::InstanceSpecific::start_pica() const {
1752 return (*Dictionary())[kStartPica].asBool();
1753 }
1754
1755 static constexpr char kStartNetsim[] = "start_netsim";
set_start_netsim(bool start)1756 void CuttlefishConfig::MutableInstanceSpecific::set_start_netsim(bool start) {
1757 (*Dictionary())[kStartNetsim] = start;
1758 }
start_netsim() const1759 bool CuttlefishConfig::InstanceSpecific::start_netsim() const {
1760 return (*Dictionary())[kStartNetsim].asBool();
1761 }
1762
1763 // TODO(b/288987294) Remove this when separating environment is done
1764 static constexpr char kStartWmediumdInstance[] = "start_wmediumd_instance";
set_start_wmediumd_instance(bool start)1765 void CuttlefishConfig::MutableInstanceSpecific::set_start_wmediumd_instance(
1766 bool start) {
1767 (*Dictionary())[kStartWmediumdInstance] = start;
1768 }
start_wmediumd_instance() const1769 bool CuttlefishConfig::InstanceSpecific::start_wmediumd_instance() const {
1770 return (*Dictionary())[kStartWmediumdInstance].asBool();
1771 }
1772
1773 static constexpr char kMcu[] = "mcu";
set_mcu(const Json::Value & cfg)1774 void CuttlefishConfig::MutableInstanceSpecific::set_mcu(const Json::Value& cfg) {
1775 (*Dictionary())[kMcu] = cfg;
1776 }
mcu() const1777 const Json::Value& CuttlefishConfig::InstanceSpecific::mcu() const {
1778 return (*Dictionary())[kMcu];
1779 }
1780
1781 static constexpr char kApBootFlow[] = "ap_boot_flow";
set_ap_boot_flow(APBootFlow flow)1782 void CuttlefishConfig::MutableInstanceSpecific::set_ap_boot_flow(APBootFlow flow) {
1783 (*Dictionary())[kApBootFlow] = static_cast<int>(flow);
1784 }
ap_boot_flow() const1785 APBootFlow CuttlefishConfig::InstanceSpecific::ap_boot_flow() const {
1786 return static_cast<APBootFlow>((*Dictionary())[kApBootFlow].asInt());
1787 }
1788
1789 static constexpr char kCrosvmUseBalloon[] = "crosvm_use_balloon";
set_crosvm_use_balloon(const bool use_balloon)1790 void CuttlefishConfig::MutableInstanceSpecific::set_crosvm_use_balloon(
1791 const bool use_balloon) {
1792 (*Dictionary())[kCrosvmUseBalloon] = use_balloon;
1793 }
crosvm_use_balloon() const1794 bool CuttlefishConfig::InstanceSpecific::crosvm_use_balloon() const {
1795 return (*Dictionary())[kCrosvmUseBalloon].asBool();
1796 }
1797
1798 static constexpr char kCrosvmUseRng[] = "crosvm_use_rng";
set_crosvm_use_rng(const bool use_rng)1799 void CuttlefishConfig::MutableInstanceSpecific::set_crosvm_use_rng(
1800 const bool use_rng) {
1801 (*Dictionary())[kCrosvmUseRng] = use_rng;
1802 }
crosvm_use_rng() const1803 bool CuttlefishConfig::InstanceSpecific::crosvm_use_rng() const {
1804 return (*Dictionary())[kCrosvmUseRng].asBool();
1805 }
1806
1807 static constexpr char kCrosvmUsePmem[] = "use_pmem";
set_use_pmem(const bool use_pmem)1808 void CuttlefishConfig::MutableInstanceSpecific::set_use_pmem(
1809 const bool use_pmem) {
1810 (*Dictionary())[kCrosvmUsePmem] = use_pmem;
1811 }
use_pmem() const1812 bool CuttlefishConfig::InstanceSpecific::use_pmem() const {
1813 return (*Dictionary())[kCrosvmUsePmem].asBool();
1814 }
1815
touch_socket_path(int touch_dev_idx) const1816 std::string CuttlefishConfig::InstanceSpecific::touch_socket_path(
1817 int touch_dev_idx) const {
1818 return PerInstanceInternalUdsPath(
1819 ("touch_" + std::to_string(touch_dev_idx) + ".sock").c_str());
1820 }
1821
rotary_socket_path() const1822 std::string CuttlefishConfig::InstanceSpecific::rotary_socket_path() const {
1823 return PerInstanceInternalPath("rotary.sock");
1824 }
1825
keyboard_socket_path() const1826 std::string CuttlefishConfig::InstanceSpecific::keyboard_socket_path() const {
1827 return PerInstanceInternalUdsPath("keyboard.sock");
1828 }
1829
switches_socket_path() const1830 std::string CuttlefishConfig::InstanceSpecific::switches_socket_path() const {
1831 return PerInstanceInternalUdsPath("switches.sock");
1832 }
1833
1834 static constexpr char kFrameSockPath[] = "frame_sock_path";
set_frames_socket_path(const std::string & frame_socket_path)1835 void CuttlefishConfig::MutableInstanceSpecific::set_frames_socket_path(
1836 const std::string& frame_socket_path) {
1837 (*Dictionary())[kFrameSockPath] = frame_socket_path;
1838 }
1839
frames_socket_path() const1840 std::string CuttlefishConfig::InstanceSpecific::frames_socket_path() const {
1841 return (*Dictionary())[kFrameSockPath].asString();
1842 }
1843
1844 static constexpr char kWifiMacPrefix[] = "wifi_mac_prefix";
wifi_mac_prefix() const1845 int CuttlefishConfig::InstanceSpecific::wifi_mac_prefix() const {
1846 return (*Dictionary())[kWifiMacPrefix].asInt();
1847 }
set_wifi_mac_prefix(int wifi_mac_prefix)1848 void CuttlefishConfig::MutableInstanceSpecific::set_wifi_mac_prefix(
1849 int wifi_mac_prefix) {
1850 (*Dictionary())[kWifiMacPrefix] = wifi_mac_prefix;
1851 }
1852
1853 static constexpr char kStartVhalProxyServer[] = "start_vhal_proxy_server";
set_start_vhal_proxy_server(bool start_vhal_proxy_server)1854 void CuttlefishConfig::MutableInstanceSpecific::set_start_vhal_proxy_server(
1855 bool start_vhal_proxy_server) {
1856 (*Dictionary())[kStartVhalProxyServer] = start_vhal_proxy_server;
1857 }
start_vhal_proxy_server() const1858 bool CuttlefishConfig::InstanceSpecific::start_vhal_proxy_server() const {
1859 return (*Dictionary())[kStartVhalProxyServer].asBool();
1860 }
1861
factory_reset_protected_path() const1862 std::string CuttlefishConfig::InstanceSpecific::factory_reset_protected_path() const {
1863 return PerInstanceInternalPath("factory_reset_protected.img");
1864 }
1865
persistent_bootconfig_path() const1866 std::string CuttlefishConfig::InstanceSpecific::persistent_bootconfig_path()
1867 const {
1868 return PerInstanceInternalPath("bootconfig");
1869 }
1870
PerInstancePath(const std::string & file_name) const1871 std::string CuttlefishConfig::InstanceSpecific::PerInstancePath(
1872 const std::string& file_name) const {
1873 return (instance_dir() + "/") + file_name;
1874 }
1875
PerInstanceInternalPath(const std::string & file_name) const1876 std::string CuttlefishConfig::InstanceSpecific::PerInstanceInternalPath(
1877 const std::string& file_name) const {
1878 if (file_name[0] == '\0') {
1879 // Don't append a / if file_name is empty.
1880 return PerInstancePath(kInternalDirName);
1881 }
1882 auto relative_path = (std::string(kInternalDirName) + "/") + file_name;
1883 return PerInstancePath(relative_path.c_str());
1884 }
1885
PerInstanceUdsPath(const std::string & file_name) const1886 std::string CuttlefishConfig::InstanceSpecific::PerInstanceUdsPath(
1887 const std::string& file_name) const {
1888 return (instance_uds_dir() + "/") + file_name;
1889 }
1890
PerInstanceInternalUdsPath(const std::string & file_name) const1891 std::string CuttlefishConfig::InstanceSpecific::PerInstanceInternalUdsPath(
1892 const std::string& file_name) const {
1893 if (file_name[0] == '\0') {
1894 // Don't append a / if file_name is empty.
1895 return PerInstanceUdsPath(kInternalDirName);
1896 }
1897 auto relative_path = (std::string(kInternalDirName) + "/") + file_name;
1898 return PerInstanceUdsPath(relative_path.c_str());
1899 }
1900
PerInstanceGrpcSocketPath(const std::string & socket_name) const1901 std::string CuttlefishConfig::InstanceSpecific::PerInstanceGrpcSocketPath(
1902 const std::string& socket_name) const {
1903 if (socket_name.size() == 0) {
1904 // Don't append a / if file_name is empty.
1905 return PerInstanceUdsPath(kGrpcSocketDirName);
1906 }
1907 auto relative_path = (std::string(kGrpcSocketDirName) + "/") + socket_name;
1908 return PerInstanceUdsPath(relative_path.c_str());
1909 }
1910
PerInstanceLogPath(const std::string & file_name) const1911 std::string CuttlefishConfig::InstanceSpecific::PerInstanceLogPath(
1912 const std::string& file_name) const {
1913 if (file_name.size() == 0) {
1914 // Don't append a / if file_name is empty.
1915 return PerInstancePath(kLogDirName);
1916 }
1917 auto relative_path = (std::string(kLogDirName) + "/") + file_name;
1918 return PerInstancePath(relative_path.c_str());
1919 }
1920
instance_name() const1921 std::string CuttlefishConfig::InstanceSpecific::instance_name() const {
1922 return IdToName(id_);
1923 }
1924
id() const1925 std::string CuttlefishConfig::InstanceSpecific::id() const { return id_; }
1926
1927 } // namespace cuttlefish
1928