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 package com.android.tradefed.config; 17 18 import com.android.tradefed.build.IBuildProvider; 19 import com.android.tradefed.device.IDeviceRecovery; 20 import com.android.tradefed.device.IDeviceSelection; 21 import com.android.tradefed.device.TestDeviceOptions; 22 import com.android.tradefed.targetprep.ITargetPreparer; 23 24 import java.util.List; 25 26 /** 27 * Device Configuration Holder Interface. 28 * Use to represent an object that can hold the information for the configuration of a device. 29 */ 30 public interface IDeviceConfiguration { 31 32 /** Returns The Name of the device specified in the field "name" of the configuration. */ getDeviceName()33 public String getDeviceName(); 34 35 /** Returns whether the container is for a Device Under Test or not. */ isFake()36 public boolean isFake(); 37 38 /** 39 * Return The list of all the configuration objects held the instance of 40 * {@link IDeviceConfiguration} 41 */ getAllObjects()42 public List<Object> getAllObjects(); 43 44 /** 45 * Return The list of all the configuration objects held the instance of {@link 46 * IDeviceConfiguration} that match the configuration type requested. 47 */ getAllObjectOfType(String configType)48 public List<Object> getAllObjectOfType(String configType); 49 50 /** 51 * Pass one of the allowed objects that the Configuration Holder can keep track of. 52 * <p> 53 * Complete list of allowed objects are: {@link IBuildProvider}, {@link ITargetPreparer}, 54 * {@link IDeviceRecovery}, {@link IDeviceSelection}, {@link TestDeviceOptions} 55 * 56 * @param config object from a type above. 57 * @throws ConfigurationException in case the object passed doesn't match the allowed types. 58 */ addSpecificConfig(Object config)59 public void addSpecificConfig(Object config) throws ConfigurationException; 60 61 /** 62 * Pass one of the allowed objects that the Configuration Holder can keep track of. 63 * 64 * <p>Complete list of allowed objects are: {@link IBuildProvider}, {@link ITargetPreparer}, 65 * {@link IDeviceRecovery}, {@link IDeviceSelection}, {@link TestDeviceOptions} 66 * 67 * @param config object from a type above. 68 * @param type the type of configuration object being passed. 69 * @throws ConfigurationException in case the object passed doesn't match the allowed types. 70 */ addSpecificConfig(Object config, String type)71 public void addSpecificConfig(Object config, String type) throws ConfigurationException; 72 73 /** 74 * Remove the specified object type from the device configuration holder. 75 * 76 * @param type The type of the object to remove. 77 * @throws ConfigurationException in case the type is not supported. 78 */ removeObjectType(String type)79 public void removeObjectType(String type) throws ConfigurationException; 80 81 /** 82 * Keep track of the frequency of the object so we can properly inject option against it. 83 * 84 * @param config the object we are tracking the frequency. 85 * @param frequency frequency associated with the object. 86 */ addFrequency(Object config, Integer frequency)87 public void addFrequency(Object config, Integer frequency); 88 89 /** Returns the frequency of the object. */ getFrequency(Object config)90 public Integer getFrequency(Object config); 91 92 /** Return {@link IBuildProvider} that the device configuration holder has reference to. */ getBuildProvider()93 public IBuildProvider getBuildProvider(); 94 95 /** 96 * Return a list of {@link ITargetPreparer} that the device configuration holder has. 97 */ getTargetPreparers()98 public List<ITargetPreparer> getTargetPreparers(); 99 100 /** Return a list of {@link ITargetPreparer} that the device configuration holder has. */ getLabPreparers()101 public List<ITargetPreparer> getLabPreparers(); 102 103 /** 104 * Return {@link IDeviceRecovery} that the device configuration holder has. 105 */ getDeviceRecovery()106 public IDeviceRecovery getDeviceRecovery(); 107 108 /** 109 * Return {@link TestDeviceOptions} that the device configuration holder has. 110 */ getDeviceOptions()111 public TestDeviceOptions getDeviceOptions(); 112 113 /** 114 * Return {@link IDeviceSelection} that the device configuration holder has. 115 */ getDeviceRequirements()116 public IDeviceSelection getDeviceRequirements(); 117 118 /** 119 * Return a shallow copy of this {@link IDeviceConfiguration} object. 120 */ clone()121 public IDeviceConfiguration clone(); 122 123 /** Return a shallow copy of this {@link IDeviceConfiguration} object, under a new name. */ clone(String newName)124 public IDeviceConfiguration clone(String newName); 125 } 126