Configuration

public class Configuration
extends Object implements IConfiguration

java.lang.Object
   ↳ com.android.tradefed.config.Configuration


A concrete IConfiguration implementation that stores the loaded config objects in a map.

Summary

Constants

String BUILD_PROVIDER_TYPE_NAME

String CMD_OPTIONS_TYPE_NAME

String CONFIGURATION_DESCRIPTION_TYPE_NAME

String DEVICE_NAME

String DEVICE_OPTIONS_TYPE_NAME

String DEVICE_RECOVERY_TYPE_NAME

String DEVICE_REQUIREMENTS_TYPE_NAME

String LOGGER_TYPE_NAME

String LOG_SAVER_TYPE_NAME

String MULTI_PREPARER_TYPE_NAME

String RESULT_REPORTER_TYPE_NAME

String SYSTEM_STATUS_CHECKER_TYPE_NAME

String TARGET_PREPARER_TYPE_NAME

String TEST_PROFILER_TYPE_NAME

String TEST_TYPE_NAME

Public constructors

Configuration(String name, String description)

Creates an Configuration with default config objects.

Public methods

Configuration clone()

Creates a shallow copy of this object.

void dumpXml(PrintWriter output)

Gets the expanded XML file for the config with all options shown for this IConfiguration as a String.

IBuildProvider getBuildProvider()

Gets the IBuildProvider from the configuration.

String getCommandLine()

Gets the the command line used to create this IConfiguration.

ICommandOptions getCommandOptions()

Gets the ICommandOptions to use from the configuration.

ConfigurationDescriptor getConfigurationDescription()

Returns the ConfigurationDescriptor provided in the configuration.

Object getConfigurationObject(String typeName)

Generic interface to get the configuration object with the given type name.

List<?> getConfigurationObjectList(String typeName)

Similar to getConfigurationObject(String), but for configuration object types that support multiple objects.

String getDescription()
List<IDeviceConfiguration> getDeviceConfig()

Gets the IDeviceConfigurations from the configuration.

IDeviceConfiguration getDeviceConfigByName(String nameDevice)

Return the IDeviceConfiguration associated to the name provided, null if not found.

TestDeviceOptions getDeviceOptions()

Gets the TestDeviceOptions to use from the configuration.

IDeviceRecovery getDeviceRecovery()

Gets the IDeviceRecovery to use from the configuration.

IDeviceSelection getDeviceRequirements()

Gets the IDeviceSelection to use from the configuration.

JSONArray getJsonCommandUsage()

Returns a JSON representation of this configuration.

ILeveledLogOutput getLogOutput()

Gets the ILeveledLogOutput to use from the configuration.

ILogSaver getLogSaver()

Gets the ILogSaver to use from the configuration.

List<IMultiTargetPreparer> getMultiTargetPreparers()

Gets the IMultiTargetPreparers from the configuration.

String getName()
ITestProfiler getProfiler()

Gets the ITestProfiler from the configuration.

List<ISystemStatusChecker> getSystemStatusCheckers()

Gets the ISystemStatusCheckers from the configuration.

List<ITargetPreparer> getTargetPreparers()

Gets the ITargetPreparers from the configuration.

List<ITestInvocationListener> getTestInvocationListeners()

Gets the ITestInvocationListeners to use from the configuration.

List<IRemoteTest> getTests()

Gets the IRemoteTests to run from the configuration.

void injectOptionValue(String optionName, String optionValue)

Inject a option value into the set of configuration objects.

void injectOptionValue(String optionName, String optionKey, String optionValue)

Inject a option value into the set of configuration objects.

void injectOptionValueWithSource(String optionName, String optionKey, String optionValue, String source)

Inject a option value into the set of configuration objects.

void injectOptionValues(List<ConfigurationDef.OptionDef> optionDefs)

Inject multiple option values into the set of configuration objects.

void printCommandUsage(boolean importantOnly, PrintStream out)

Outputs a command line usage help text for this configuration to given printStream.

void setBuildProvider(IBuildProvider provider)

Replace the current IBuildProvider in the configuration.

void setCommandLine(String[] arrayArgs)

Sets the command line used to create this IConfiguration.

void setCommandOptions(ICommandOptions cmdOptions)

Set the ICommandOptions, replacing any existing values

void setConfigurationObject(String typeName, Object configObject)

Generic method to set the config object with the given name, replacing any existing value.

void setConfigurationObjectList(String typeName, List<?> configList)

Generic method to set the config object list for the given name, replacing any existing value.

void setDeviceConfig(IDeviceConfiguration deviceConfig)

Set a IDeviceConfiguration, replacing any existing value.

void setDeviceConfigList(List<IDeviceConfiguration> deviceConfigs)

Set the IDeviceConfigurations, replacing any existing value.

void setDeviceOptions(TestDeviceOptions devOptions)

Set the TestDeviceOptions, replacing any existing values

void setDeviceRecovery(IDeviceRecovery recovery)

Set the IDeviceRecovery, replacing any existing value.

void setDeviceRequirements(IDeviceSelection devRequirements)

Set the IDeviceSelection, replacing any existing values

void setLogOutput(ILeveledLogOutput logger)

Set the ILeveledLogOutput, replacing any existing value.

void setLogSaver(ILogSaver logSaver)

Set the ILogSaver, replacing any existing value.

void setMultiTargetPreparer(IMultiTargetPreparer multiTargPrep)

Convenience method to set a single IMultiTargetPreparer in this configuration, replacing any existing values

void setMultiTargetPreparers(List<IMultiTargetPreparer> multiTargPreps)

Set the list of IMultiTargetPreparers in this configuration, replacing any existing values

List<String> setOptionsFromCommandLineArgs(List<String> listArgs)

Set the config Option fields with given set of command line arguments

ArgsOptionParser for expected format

List<String> setOptionsFromCommandLineArgs(List<String> listArgs, IKeyStoreClient keyStoreClient)

Set the config Option fields with given set of command line arguments

See ArgsOptionParser for expected format

void setProfiler(ITestProfiler profiler)

Set the ITestProfiler, replacing any existing values

void setSystemStatusChecker(ISystemStatusChecker systemChecker)

Convenience method to set a single ISystemStatusChecker in this configuration, replacing any existing values

void setSystemStatusCheckers(List<ISystemStatusChecker> systemCheckers)

Set the list of ISystemStatusCheckers in this configuration, replacing any existing values

void setTargetPreparer(ITargetPreparer preparer)

Set the ITargetPreparer, replacing any existing value.

void setTest(IRemoteTest test)

Convenience method to set a single IRemoteTest in this configuration, replacing any existing values

void setTestInvocationListener(ITestInvocationListener listener)

Convenience method to set a single ITestInvocationListener

void setTestInvocationListeners(List<ITestInvocationListener> listeners)

Set the list of ITestInvocationListeners, replacing any existing values

void setTests(List<IRemoteTest> tests)

Set the list of IRemoteTests in this configuration, replacing any existing values

void validateOptions()

Validate option values.

Constants

BUILD_PROVIDER_TYPE_NAME

String BUILD_PROVIDER_TYPE_NAME

Constant Value: "build_provider"

CMD_OPTIONS_TYPE_NAME

String CMD_OPTIONS_TYPE_NAME

Constant Value: "cmd_options"

CONFIGURATION_DESCRIPTION_TYPE_NAME

String CONFIGURATION_DESCRIPTION_TYPE_NAME

Constant Value: "config_desc"

DEVICE_NAME

String DEVICE_NAME

Constant Value: "device"

DEVICE_OPTIONS_TYPE_NAME

String DEVICE_OPTIONS_TYPE_NAME

Constant Value: "device_options"

DEVICE_RECOVERY_TYPE_NAME

String DEVICE_RECOVERY_TYPE_NAME

Constant Value: "device_recovery"

DEVICE_REQUIREMENTS_TYPE_NAME

String DEVICE_REQUIREMENTS_TYPE_NAME

Constant Value: "device_requirements"

LOGGER_TYPE_NAME

String LOGGER_TYPE_NAME

Constant Value: "logger"

LOG_SAVER_TYPE_NAME

String LOG_SAVER_TYPE_NAME

Constant Value: "log_saver"

MULTI_PREPARER_TYPE_NAME

String MULTI_PREPARER_TYPE_NAME

Constant Value: "multi_target_preparer"

RESULT_REPORTER_TYPE_NAME

String RESULT_REPORTER_TYPE_NAME

Constant Value: "result_reporter"

SYSTEM_STATUS_CHECKER_TYPE_NAME

String SYSTEM_STATUS_CHECKER_TYPE_NAME

Constant Value: "system_checker"

TARGET_PREPARER_TYPE_NAME

String TARGET_PREPARER_TYPE_NAME

Constant Value: "target_preparer"

TEST_PROFILER_TYPE_NAME

String TEST_PROFILER_TYPE_NAME

Constant Value: "test_profiler"

TEST_TYPE_NAME

String TEST_TYPE_NAME

Constant Value: "test"

Public constructors

Configuration

Configuration (String name, 
                String description)

Creates an Configuration with default config objects.

Parameters
name String
description String

Public methods

clone

Configuration clone ()

Creates a shallow copy of this object.

Returns
Configuration

dumpXml

void dumpXml (PrintWriter output)

Gets the expanded XML file for the config with all options shown for this IConfiguration as a String.

Parameters
output PrintWriter: the writer to print the xml to.
Throws
IOException

getBuildProvider

IBuildProvider getBuildProvider ()

Gets the IBuildProvider from the configuration.

Returns
IBuildProvider the IBuildProvider provided in the configuration

getCommandLine

String getCommandLine ()

Gets the the command line used to create this IConfiguration.

Returns
String the command line used to create this IConfiguration.

getCommandOptions

ICommandOptions getCommandOptions ()

Gets the ICommandOptions to use from the configuration.

Returns
ICommandOptions the ICommandOptions provided in the configuration.

getConfigurationDescription

ConfigurationDescriptor getConfigurationDescription ()

Returns the ConfigurationDescriptor provided in the configuration.

Returns
ConfigurationDescriptor

getConfigurationObject

Object getConfigurationObject (String typeName)

Generic interface to get the configuration object with the given type name.

Parameters
typeName String: the unique type of the configuration object
Returns
Object the configuration object or null if the object type with given name does not exist.

getConfigurationObjectList

List<?> getConfigurationObjectList (String typeName)

Similar to getConfigurationObject(String), but for configuration object types that support multiple objects.

Parameters
typeName String: the unique type name of the configuration object
Returns
List<?> the list of configuration objects or null if the object type with given name does not exist.

getDescription

String getDescription ()

Returns
String a short user readable description this Configuration

getDeviceConfig

List<IDeviceConfiguration> getDeviceConfig ()

Gets the IDeviceConfigurations from the configuration.

Returns
List<IDeviceConfiguration> the IDeviceConfigurations provided in order in the configuration

getDeviceConfigByName

IDeviceConfiguration getDeviceConfigByName (String nameDevice)

Return the IDeviceConfiguration associated to the name provided, null if not found.

Parameters
nameDevice String
Returns
IDeviceConfiguration

getDeviceOptions

TestDeviceOptions getDeviceOptions ()

Gets the TestDeviceOptions to use from the configuration.

Returns
TestDeviceOptions the TestDeviceOptions provided in the configuration.

getDeviceRecovery

IDeviceRecovery getDeviceRecovery ()

Gets the IDeviceRecovery to use from the configuration.

Returns
IDeviceRecovery the IDeviceRecovery provided in the configuration.

getDeviceRequirements

IDeviceSelection getDeviceRequirements ()

Gets the IDeviceSelection to use from the configuration.

Returns
IDeviceSelection the IDeviceSelection provided in the configuration.

getJsonCommandUsage

JSONArray getJsonCommandUsage ()

Returns a JSON representation of this configuration.

The return value is a JSONArray containing JSONObjects to represent each configuration object. Each configuration object entry has the following structure:

 &#123;
     "alias": "device-unavail-email",
     "name": "result_reporter",
     "class": "com.android.tradefed.result.DeviceUnavailEmailResultReporter",
     "options": [ ... ]
   &#125;
 
 
The "options" entry is a JSONArray containing JSONObjects to represent each @Option annotated field. Each option entry has the following structure:
 &#123;
     "updateRule": "LAST",
     "isTimeVal": false,
     "source": "google\/template\/reporters\/asit",
     "importance": "IF_UNSET",
     "description": "The envelope-sender address to use for the messages.",
     "mandatory": false,
     "name": "sender",
     "javaClass": "java.lang.String",
     "value": "tffail@google.com"
   &#125;
 
 
Most of the values come from the @Option annotation. 'javaClass' is the name of the underlying java class for this option. 'value' is a JSON representation of the field's current value. 'source' is the set of config names which set the field's value. For regular objects or Collections, 'source' is a JSONArray containing each contributing config's name. For map fields, sources for each key are tracked individually and stored in a JSONObject. Each key / value pair in the JSONObject corresponds to a key in the map and an array of its source configurations.

Returns
JSONArray
Throws
JSONException

getLogOutput

ILeveledLogOutput getLogOutput ()

Gets the ILeveledLogOutput to use from the configuration.

Returns
ILeveledLogOutput the ILeveledLogOutput provided in the configuration.

getLogSaver

ILogSaver getLogSaver ()

Gets the ILogSaver to use from the configuration.

Returns
ILogSaver the ILogSaver provided in the configuration.

getMultiTargetPreparers

List<IMultiTargetPreparer> getMultiTargetPreparers ()

Gets the IMultiTargetPreparers from the configuration.

Returns
List<IMultiTargetPreparer> the IMultiTargetPreparers provided in order in the configuration

getName

String getName ()

Returns
String the name of this Configuration

getProfiler

ITestProfiler getProfiler ()

Gets the ITestProfiler from the configuration.

Returns
ITestProfiler the ITestProfiler provided in the configuration.

getSystemStatusCheckers

List<ISystemStatusChecker> getSystemStatusCheckers ()

Gets the ISystemStatusCheckers from the configuration.

Returns
List<ISystemStatusChecker> the ISystemStatusCheckers provided in order in the configuration

getTargetPreparers

List<ITargetPreparer> getTargetPreparers ()

Gets the ITargetPreparers from the configuration.

Returns
List<ITargetPreparer> the ITargetPreparers provided in order in the configuration

getTestInvocationListeners

List<ITestInvocationListener> getTestInvocationListeners ()

Gets the ITestInvocationListeners to use from the configuration.

Returns
List<ITestInvocationListener> the ITestInvocationListeners provided in the configuration.

getTests

List<IRemoteTest> getTests ()

Gets the IRemoteTests to run from the configuration.

Returns
List<IRemoteTest> the tests provided in the configuration

injectOptionValue

void injectOptionValue (String optionName, 
                String optionValue)

Inject a option value into the set of configuration objects.

Useful to provide values for options that are generated dynamically.

Parameters
optionName String: the option name
optionValue String: the option value
Throws
ConfigurationException

injectOptionValue

void injectOptionValue (String optionName, 
                String optionKey, 
                String optionValue)

Inject a option value into the set of configuration objects.

Useful to provide values for options that are generated dynamically.

Parameters
optionName String: the option name
optionKey String: the optional key for map options, or null
optionValue String: the map option value
Throws
ConfigurationException

injectOptionValueWithSource

void injectOptionValueWithSource (String optionName, 
                String optionKey, 
                String optionValue, 
                String source)

Inject a option value into the set of configuration objects.

Useful to provide values for options that are generated dynamically.

Parameters
optionName String: the option name
optionKey String: the optional key for map options, or null
optionValue String: the map option value
source String: the source config that provided this option value
Throws
ConfigurationException

injectOptionValues

void injectOptionValues (List<ConfigurationDef.OptionDef> optionDefs)

Inject multiple option values into the set of configuration objects.

Useful to inject many option values at once after creating a new object.

Parameters
optionDefs List: a list of option defs to inject
Throws
ConfigurationException

printCommandUsage

void printCommandUsage (boolean importantOnly, 
                PrintStream out)

Outputs a command line usage help text for this configuration to given printStream.

Parameters
importantOnly boolean: if true only print help for the important options
out PrintStream: the PrintStream to use.
Throws
ConfigurationException

setBuildProvider

void setBuildProvider (IBuildProvider provider)

Replace the current IBuildProvider in the configuration.

Parameters
provider IBuildProvider: the new IBuildProvider

setCommandLine

void setCommandLine (String[] arrayArgs)

Sets the command line used to create this IConfiguration. This stores the whole command line, including the configuration name, unlike setOptionsFromCommandLineArgs.

Parameters
arrayArgs String: the command line

setCommandOptions

void setCommandOptions (ICommandOptions cmdOptions)

Set the ICommandOptions, replacing any existing values

setConfigurationObject

void setConfigurationObject (String typeName, 
                Object configObject)

Generic method to set the config object with the given name, replacing any existing value.

Parameters
typeName String: the unique name of the config object type.
configObject Object: the config object
Throws
ConfigurationException

setConfigurationObjectList

void setConfigurationObjectList (String typeName, 
                List<?> configList)

Generic method to set the config object list for the given name, replacing any existing value.

Parameters
typeName String: the unique name of the config object type.
configList List: the config object list
Throws
ConfigurationException

setDeviceConfig

void setDeviceConfig (IDeviceConfiguration deviceConfig)

Set a IDeviceConfiguration, replacing any existing value.

setDeviceConfigList

void setDeviceConfigList (List<IDeviceConfiguration> deviceConfigs)

Set the IDeviceConfigurations, replacing any existing value.

setDeviceOptions

void setDeviceOptions (TestDeviceOptions devOptions)

Set the TestDeviceOptions, replacing any existing values

Parameters
devOptions TestDeviceOptions

setDeviceRecovery

void setDeviceRecovery (IDeviceRecovery recovery)

Set the IDeviceRecovery, replacing any existing value.

setDeviceRequirements

void setDeviceRequirements (IDeviceSelection devRequirements)

Set the IDeviceSelection, replacing any existing values

setLogOutput

void setLogOutput (ILeveledLogOutput logger)

Set the ILeveledLogOutput, replacing any existing value.

setLogSaver

void setLogSaver (ILogSaver logSaver)

Set the ILogSaver, replacing any existing value.

setMultiTargetPreparer

void setMultiTargetPreparer (IMultiTargetPreparer multiTargPrep)

Convenience method to set a single IMultiTargetPreparer in this configuration, replacing any existing values

setMultiTargetPreparers

void setMultiTargetPreparers (List<IMultiTargetPreparer> multiTargPreps)

Set the list of IMultiTargetPreparers in this configuration, replacing any existing values

setOptionsFromCommandLineArgs

List<String> setOptionsFromCommandLineArgs (List<String> listArgs)

Set the config Option fields with given set of command line arguments

ArgsOptionParser for expected format

Parameters
listArgs List: the command line arguments
Returns
List<String> the unconsumed arguments
Throws
ConfigurationException

setOptionsFromCommandLineArgs

List<String> setOptionsFromCommandLineArgs (List<String> listArgs, 
                IKeyStoreClient keyStoreClient)

Set the config Option fields with given set of command line arguments

See ArgsOptionParser for expected format

Parameters
listArgs List: the command line arguments
keyStoreClient IKeyStoreClient: IKeyStoreClient to use.
Returns
List<String> the unconsumed arguments
Throws
ConfigurationException

setProfiler

void setProfiler (ITestProfiler profiler)

Set the ITestProfiler, replacing any existing values

setSystemStatusChecker

void setSystemStatusChecker (ISystemStatusChecker systemChecker)

Convenience method to set a single ISystemStatusChecker in this configuration, replacing any existing values

setSystemStatusCheckers

void setSystemStatusCheckers (List<ISystemStatusChecker> systemCheckers)

Set the list of ISystemStatusCheckers in this configuration, replacing any existing values

setTargetPreparer

void setTargetPreparer (ITargetPreparer preparer)

Set the ITargetPreparer, replacing any existing value.

setTest

void setTest (IRemoteTest test)

Convenience method to set a single IRemoteTest in this configuration, replacing any existing values

setTestInvocationListener

void setTestInvocationListener (ITestInvocationListener listener)

Convenience method to set a single ITestInvocationListener

setTestInvocationListeners

void setTestInvocationListeners (List<ITestInvocationListener> listeners)

Set the list of ITestInvocationListeners, replacing any existing values

setTests

void setTests (List<IRemoteTest> tests)

Set the list of IRemoteTests in this configuration, replacing any existing values

validateOptions

void validateOptions ()

Validate option values.

Currently this will just validate that all mandatory options have been set

Throws
ConfigurationException