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.build.IBuildProvider; 20 import com.android.tradefed.config.ConfigurationException; 21 import com.android.tradefed.targetprep.DeviceFlashPreparer; 22 23 import java.io.File; 24 import java.util.HashSet; 25 import java.util.List; 26 import java.util.Map; 27 import java.util.Set; 28 29 /** 30 * Host options holder interface. 31 * This interface is used to access host-wide options. 32 */ 33 public interface IHostOptions { 34 35 /** 36 * Enum describing the possible permit limiters 37 */ 38 public enum PermitLimitType { 39 CONCURRENT_FLASHER, 40 CONCURRENT_DOWNLOAD, 41 CONCURRENT_VIRTUAL_DEVICE_STARTUP; 42 } 43 44 /** 45 * Returns the max number of concurrent flashing to allow. Used by {@link DeviceFlashPreparer}. 46 * 47 * @return the concurrent flasher limit. 48 */ getConcurrentFlasherLimit()49 Integer getConcurrentFlasherLimit(); 50 51 /** 52 * Returns the max number of concurrent downloads allowed. Used by {@link IBuildProvider} that 53 * downloads remote builds. 54 */ getConcurrentDownloadLimit()55 Integer getConcurrentDownloadLimit(); 56 57 /** 58 * Returns the max number of concurrent virtual device startup allowed. Used by {@link 59 * com.android.tradefed.device.cloud.RemoteAndroidVirtualDevice} that startup virtual device. 60 */ getConcurrentVirtualDeviceStartupLimit()61 Integer getConcurrentVirtualDeviceStartupLimit(); 62 63 /** Returns the path that fastboot should use as temporary folder. */ getFastbootTmpDir()64 File getFastbootTmpDir(); 65 66 /** Returns whether or not fastbootd mode support is enabled. */ isFastbootdEnable()67 boolean isFastbootdEnable(); 68 69 /** Returns the path used for storing downloaded artifacts. */ getDownloadCacheDir()70 File getDownloadCacheDir(); 71 72 /** Check if it should use the SingleSignOn client or not. */ shouldUseSsoClient()73 Boolean shouldUseSsoClient(); 74 75 /** Returns a Map of service account json key files. */ getServiceAccountJsonKeyFiles()76 Map<String, File> getServiceAccountJsonKeyFiles(); 77 78 /** Validate that the options set on {@link IHostOptions} are valid. */ validateOptions()79 void validateOptions() throws ConfigurationException; 80 81 /** Get labels for the host. */ getLabels()82 public List<String> getLabels(); 83 84 /** Known tcp-device associated with a specific IP. */ 85 @Deprecated getKnownTcpDeviceIpPool()86 default Set<String> getKnownTcpDeviceIpPool() { 87 return new HashSet<>(); 88 } 89 90 /** Known gce-device associated with a specific IP. */ getKnownGceDeviceIpPool()91 Set<String> getKnownGceDeviceIpPool(); 92 93 /** Known remote-device associated with a specific IP. */ getKnownRemoteDeviceIpPool()94 Set<String> getKnownRemoteDeviceIpPool(); 95 96 /** Known preconfigured virtual device pool. */ getKnownPreconfigureVirtualDevicePool()97 List<String> getKnownPreconfigureVirtualDevicePool(); 98 99 /** Known preconfigured native device ip pool. */ getKnownPreconfigureNativeDevicePool()100 List<String> getKnownPreconfigureNativeDevicePool(); 101 102 /** Check if it should use the zip64 format in partial download or not. */ getUseZip64InPartialDownload()103 boolean getUseZip64InPartialDownload(); 104 105 /** Returns the network interface used to connect to remote test devices. */ getNetworkInterface()106 String getNetworkInterface(); 107 108 /** Returns the Test Phase level timeout specified. Default will be 0 for no timeouts. */ getTestPhaseTimeout()109 long getTestPhaseTimeout(); 110 111 /** Initializes the concurrent locks */ initConcurrentLocks()112 public void initConcurrentLocks(); 113 114 /** Takes a permit of the given type */ takePermit(PermitLimitType type)115 public void takePermit(PermitLimitType type); 116 117 /** Returns a permit of the given type */ returnPermit(PermitLimitType type)118 public void returnPermit(PermitLimitType type); 119 120 /** Returns the number of available permit of a given type */ getAvailablePermits(PermitLimitType type)121 public Integer getAvailablePermits(PermitLimitType type); 122 123 /** Returns the number of permits in use for a given type */ getInUsePermits(PermitLimitType type)124 public int getInUsePermits(PermitLimitType type); 125 126 /** Returns whether or not flashing should be done with fuse mounted device image zip file. */ shouldFlashWithFuseZip()127 public boolean shouldFlashWithFuseZip(); 128 129 /** Return maximum allowed size(bytes) of the local file cache. */ getCacheSizeLimit()130 public Long getCacheSizeLimit(); 131 132 /** Returns whether or not incremental flashing is enabled. */ isIncrementalFlashingEnabled()133 public boolean isIncrementalFlashingEnabled(); 134 135 /** Returns whether the host is opt-out of incremental flashing. */ isOptOutOfIncrementalFlashing()136 public boolean isOptOutOfIncrementalFlashing(); 137 138 /** Returns whether host metric reporting should be disabled. */ isHostMetricReportingDisabled()139 public boolean isHostMetricReportingDisabled(); 140 } 141