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      * Pass one of the allowed objects that the Configuration Holder can keep track of.
46      * <p>
47      * Complete list of allowed objects are: {@link IBuildProvider}, {@link ITargetPreparer},
48      * {@link IDeviceRecovery}, {@link IDeviceSelection}, {@link TestDeviceOptions}
49      *
50      * @param config object from a type above.
51      * @throws ConfigurationException in case the object passed doesn't match the allowed types.
52      */
addSpecificConfig(Object config)53     public void addSpecificConfig(Object config) throws ConfigurationException;
54 
55     /**
56      * Keep track of the frequency of the object so we can properly inject option against it.
57      *
58      * @param config the object we are tracking the frequency.
59      * @param frequency frequency associated with the object.
60      */
addFrequency(Object config, Integer frequency)61     public void addFrequency(Object config, Integer frequency);
62 
63     /** Returns the frequency of the object. */
getFrequency(Object config)64     public Integer getFrequency(Object config);
65 
66     /** Return {@link IBuildProvider} that the device configuration holder has reference to. */
getBuildProvider()67     public IBuildProvider getBuildProvider();
68 
69     /**
70      * Return a list of {@link ITargetPreparer} that the device configuration holder has.
71      */
getTargetPreparers()72     public List<ITargetPreparer> getTargetPreparers();
73 
74     /**
75      * Return {@link IDeviceRecovery} that the device configuration holder has.
76      */
getDeviceRecovery()77     public IDeviceRecovery getDeviceRecovery();
78 
79     /**
80      * Return {@link TestDeviceOptions} that the device configuration holder has.
81      */
getDeviceOptions()82     public TestDeviceOptions getDeviceOptions();
83 
84     /**
85      * Return {@link IDeviceSelection} that the device configuration holder has.
86      */
getDeviceRequirements()87     public IDeviceSelection getDeviceRequirements();
88 
89     /**
90      * Return a shallow copy of this {@link IDeviceConfiguration} object.
91      */
clone()92     public IDeviceConfiguration clone();
93 }
94