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.HashMap; 25 import java.util.Map; 26 27 /** 28 * Host options holder class. 29 * This class is used to store host-wide options. 30 */ 31 @OptionClass(alias = "host_options", global_namespace = false) 32 public class HostOptions implements IHostOptions { 33 34 @Option(name = "concurrent-flasher-limit", description = 35 "The maximum number of concurrent flashers (may be useful to avoid memory constraints)") 36 private Integer mConcurrentFlasherLimit = 1; 37 38 @Option( 39 name = "concurrent-download-limit", 40 description = 41 "The maximum number of concurrent downloads (may be useful to avoid network " 42 + "constraints)" 43 ) 44 private Integer mConcurrentDownloadLimit = null; 45 46 @Option( 47 name = "fastboot-tmpdir", 48 description = "The location of temporary directory used by fastboot" 49 ) 50 private File mFastbootTmpDir = null; 51 52 @Option(name = "download-cache-dir", description = "the directory for caching downloaded " 53 + "flashing files. Should be on the same filesystem as java.io.tmpdir. Consider " 54 + "changing the java.io.tmpdir property if you want to move downloads to a different " 55 + "filesystem.") 56 private File mDownloadCacheDir = new File(System.getProperty("java.io.tmpdir"), "lc_cache"); 57 58 @Option(name = "use-sso-client", description = "Use a SingleSignOn client for HTTP requests.") 59 private Boolean mUseSsoClient = true; 60 61 @Option( 62 name = "service-account-json-key-file", 63 description = 64 "Specify a service account json key file, and a String key name to identify it." 65 ) 66 private Map<String, File> mJsonServiceAccountMap = new HashMap<>(); 67 68 /** 69 * {@inheritDoc} 70 */ 71 @Override getConcurrentFlasherLimit()72 public Integer getConcurrentFlasherLimit() { 73 return mConcurrentFlasherLimit; 74 } 75 76 /** {@inheritDoc} */ 77 @Override getConcurrentDownloadLimit()78 public Integer getConcurrentDownloadLimit() { 79 return mConcurrentDownloadLimit; 80 } 81 82 /** {@inheritDoc} */ 83 @Override getFastbootTmpDir()84 public File getFastbootTmpDir() { 85 return mFastbootTmpDir; 86 } 87 88 /** {@inheritDoc} */ 89 @Override getDownloadCacheDir()90 public File getDownloadCacheDir() { 91 return mDownloadCacheDir; 92 } 93 94 /** {@inheritDoc} */ 95 @Override shouldUseSsoClient()96 public Boolean shouldUseSsoClient() { 97 return mUseSsoClient; 98 } 99 100 /** {@inheritDoc} */ 101 @Override getServiceAccountJsonKeyFiles()102 public Map<String, File> getServiceAccountJsonKeyFiles() { 103 return new HashMap<>(mJsonServiceAccountMap); 104 } 105 106 /** {@inheritDoc} */ 107 @Override validateOptions()108 public void validateOptions() throws ConfigurationException { 109 // Validation of host options 110 } 111 } 112