1 /* 2 * Copyright (C) 2016 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 package com.android.tradefed.host; 18 19 import com.android.tradefed.config.ConfigurationException; 20 import com.android.tradefed.config.Option; 21 import com.android.tradefed.config.OptionClass; 22 23 import java.io.File; 24 import java.util.ArrayList; 25 import java.util.HashMap; 26 import java.util.HashSet; 27 import java.util.List; 28 import java.util.Map; 29 import java.util.Set; 30 31 /** 32 * Host options holder class. 33 * This class is used to store host-wide options. 34 */ 35 @OptionClass(alias = "host_options", global_namespace = false) 36 public class HostOptions implements IHostOptions { 37 38 @Option(name = "concurrent-flasher-limit", description = 39 "The maximum number of concurrent flashers (may be useful to avoid memory constraints)") 40 private Integer mConcurrentFlasherLimit = 1; 41 42 @Option( 43 name = "concurrent-download-limit", 44 description = 45 "The maximum number of concurrent downloads (may be useful to avoid network " 46 + "constraints)" 47 ) 48 private Integer mConcurrentDownloadLimit = null; 49 50 @Option( 51 name = "fastboot-tmpdir", 52 description = "The location of temporary directory used by fastboot" 53 ) 54 private File mFastbootTmpDir = null; 55 56 @Option( 57 name = "enable-fastbootd-mode", 58 description = "Feature flag to enable the support for fastbootd.") 59 private boolean mEnableFastbootdMode = false; 60 61 @Option(name = "download-cache-dir", description = "the directory for caching downloaded " 62 + "flashing files. Should be on the same filesystem as java.io.tmpdir. Consider " 63 + "changing the java.io.tmpdir property if you want to move downloads to a different " 64 + "filesystem.") 65 private File mDownloadCacheDir = new File(System.getProperty("java.io.tmpdir"), "lc_cache"); 66 67 @Option(name = "use-sso-client", description = "Use a SingleSignOn client for HTTP requests.") 68 private Boolean mUseSsoClient = true; 69 70 @Option( 71 name = "service-account-json-key-file", 72 description = 73 "Specify a service account json key file, and a String key name to identify it." 74 ) 75 private Map<String, File> mJsonServiceAccountMap = new HashMap<>(); 76 77 @Option(name = "label", description = "Labels to describe the host.") 78 private List<String> mLabels = new ArrayList<>(); 79 80 @Option( 81 name = "known-tcp-device-ip-pool", 82 description = 83 "known remote device available via ip associated with the " 84 + "tcp-device placeholder.") 85 private Set<String> mKnownTcpDeviceIpPool = new HashSet<>(); 86 87 @Option( 88 name = "known-gce-device-ip-pool", 89 description = 90 "known remote device available via ip associated with the " 91 + "gce-device placeholder.") 92 private Set<String> mKnownGceDeviceIpPool = new HashSet<>(); 93 94 @Option( 95 name = "use-zip64-in-partial-download", 96 description = "Whether to use zip64 format in partial download.") 97 private boolean mUseZip64InPartialDownload = false; 98 99 /** {@inheritDoc} */ 100 @Override getConcurrentFlasherLimit()101 public Integer getConcurrentFlasherLimit() { 102 return mConcurrentFlasherLimit; 103 } 104 105 /** {@inheritDoc} */ 106 @Override getConcurrentDownloadLimit()107 public Integer getConcurrentDownloadLimit() { 108 return mConcurrentDownloadLimit; 109 } 110 111 /** {@inheritDoc} */ 112 @Override getFastbootTmpDir()113 public File getFastbootTmpDir() { 114 return mFastbootTmpDir; 115 } 116 117 /** {@inheritDoc} */ 118 @Override isFastbootdEnable()119 public boolean isFastbootdEnable() { 120 return mEnableFastbootdMode; 121 } 122 123 /** {@inheritDoc} */ 124 @Override getDownloadCacheDir()125 public File getDownloadCacheDir() { 126 return mDownloadCacheDir; 127 } 128 129 /** {@inheritDoc} */ 130 @Override shouldUseSsoClient()131 public Boolean shouldUseSsoClient() { 132 return mUseSsoClient; 133 } 134 135 /** {@inheritDoc} */ 136 @Override getServiceAccountJsonKeyFiles()137 public Map<String, File> getServiceAccountJsonKeyFiles() { 138 return new HashMap<>(mJsonServiceAccountMap); 139 } 140 141 /** {@inheritDoc} */ 142 @Override validateOptions()143 public void validateOptions() throws ConfigurationException { 144 // Validation of host options 145 } 146 147 /** {@inheritDoc} */ 148 @Override getLabels()149 public List<String> getLabels() { 150 return new ArrayList<>(mLabels); 151 } 152 153 /** {@inheritDoc} */ 154 @Override getKnownTcpDeviceIpPool()155 public Set<String> getKnownTcpDeviceIpPool() { 156 return new HashSet<>(mKnownTcpDeviceIpPool); 157 } 158 159 /** {@inheritDoc} */ 160 @Override getKnownGceDeviceIpPool()161 public Set<String> getKnownGceDeviceIpPool() { 162 return new HashSet<>(mKnownGceDeviceIpPool); 163 } 164 165 /** {@inheritDoc} */ 166 @Override getUseZip64InPartialDownload()167 public boolean getUseZip64InPartialDownload() { 168 return mUseZip64InPartialDownload; 169 } 170 } 171