InvocationContext

public class InvocationContext
extends Object implements IInvocationContext

java.lang.Object
   ↳ com.android.tradefed.invoker.InvocationContext


Generic implementation of a IInvocationContext.

Summary

Public constructors

InvocationContext()

Creates a BuildInfo using default attribute values.

Public methods

void addAllocatedDevice( deviceWithName)

Track a map of configuration device name associated to a ITestDevice.

void addAllocatedDevice(String devicename, ITestDevice testDevice)

Add a ITestDevice to be tracked by the meta data when the device is allocated.

void addDeviceBuildInfo(String deviceName, IBuildInfo buildinfo)

Add a IBuildInfo to be tracked with the device configuration name.

void addInvocationAttribute(String attributeName, String attributeValue)

Add an Invocation attribute.

void addInvocationAttributes(MultiMap<String, String> attributesMap)

Add several invocation attributes at once through a UniqueMultiMap.

void addSerialsFromShard(Integer index, serials)

Add a serial to be tracked as assigned to one of the shard running some tests.

static InvocationContext fromProto(InvocationContext.Context protoContext)

Inverse operation to InvocationContext#toProto() to get the instance back.

MultiMap<String, String> getAttributes()

Returns a copy of the map containing all the invocation attributes.

IBuildInfo getBuildInfo(String deviceName)

Return the IBuildInfo associated with the device configuration name provided.

IBuildInfo getBuildInfo(ITestDevice testDevice)

Return the IBuildInfo associated with the ITestDevice

String getBuildInfoName(IBuildInfo info)

Returns the name of device set in the xml configuration from the IBuildInfo.

getBuildInfos()

Return all the IBuildInfo tracked for this invocation.

ConfigurationDescriptor getConfigurationDescriptor()

Returns the descriptor associated with the test configuration that launched the invocation

ITestDevice getDevice(String deviceName)

Return the ITestDevice associated with the device configuration name provided.

getDeviceBuildMap()

Return the map of Device/build info association

ITestDevice getDeviceBySerial(String serial)

Returns the ITestDevice associated with the serial provided.

getDeviceConfigNames()

Return the list of device config names of the device tracked in this invocation

String getDeviceName(ITestDevice device)

Returns the name of the device set in the xml configuration from the ITestDevice.

getDevices()

Return all the allocated device tracked for this invocation.

String getInvocationId()
IInvocationContext getModuleInvocationContext()

Returns the invocation context of module while being executed as part of a suite.

int getNumDevicesAllocated()

Return the number of devices allocated for the invocation.

getSerials()

Return the list of serials of the device tracked in this invocation

getShardsSerials()

Returns the Map of all tracked serials and their shard involved in sharding.

String getTestTag()

Returns the invocation test-tag.

void lockAttributes()

Lock the context to prevent more invocation attributes to be added.

void logInvocationMetrics()

Log the InvocationMetricLogger attributes to the invocation.

void markReleasedEarly()

Mark the devices are getting released early.

void setConfigurationDescriptor(ConfigurationDescriptor configurationDescriptor)

Sets the descriptor associated with the test configuration that launched the invocation

void setModuleInvocationContext(IInvocationContext invocationContext)

Sets the invocation context of module while being executed as part of a suite.

void setRecoveryModeForAllDevices(ITestDevice.RecoveryMode mode)

Sets the RecoveryMode of all the devices part of the context

void setTestTag(String testTag)

Sets the invocation test-tag.

InvocationContext.Context toProto()

Serialize a the context instance into a protobuf.

boolean wasReleasedEarly()

Returns whether or not the devices were released early and won't be used anymore.

Public constructors

InvocationContext

public InvocationContext ()

Creates a BuildInfo using default attribute values.

Public methods

addAllocatedDevice

public void addAllocatedDevice ( deviceWithName)

Track a map of configuration device name associated to a ITestDevice. Doesn't clear the previous tracking before adding.

Parameters
deviceWithName : the ERROR(/Map) of additional device to track

addAllocatedDevice

public void addAllocatedDevice (String devicename, 
                ITestDevice testDevice)

Add a ITestDevice to be tracked by the meta data when the device is allocated. will set the build info to null in the map.

Parameters
devicename String: the device configuration name to associate with the ITestDevice

testDevice ITestDevice: to be added to the allocated devices.

addDeviceBuildInfo

public void addDeviceBuildInfo (String deviceName, 
                IBuildInfo buildinfo)

Add a IBuildInfo to be tracked with the device configuration name.

Parameters
deviceName String: the device configuration name

buildinfo IBuildInfo: a IBuildInfo associated to the device configuration name.

addInvocationAttribute

public void addInvocationAttribute (String attributeName, 
                String attributeValue)

Add an Invocation attribute.

Parameters
attributeName String

attributeValue String

addInvocationAttributes

public void addInvocationAttributes (MultiMap<String, String> attributesMap)

Add several invocation attributes at once through a UniqueMultiMap.

Parameters
attributesMap MultiMap

addSerialsFromShard

public void addSerialsFromShard (Integer index, 
                 serials)

Add a serial to be tracked as assigned to one of the shard running some tests.

Parameters
index Integer: the index of the shard using the serials

serials : The list of serials to be tracked.

fromProto

public static InvocationContext fromProto (InvocationContext.Context protoContext)

Inverse operation to InvocationContext#toProto() to get the instance back.

Parameters
protoContext InvocationContext.Context

Returns
InvocationContext

getAttributes

public MultiMap<String, String> getAttributes ()

Returns a copy of the map containing all the invocation attributes.

Returns
MultiMap<String, String>

getBuildInfo

public IBuildInfo getBuildInfo (String deviceName)

Return the IBuildInfo associated with the device configuration name provided. Returns null, if the deviceName cannot be matched.

Parameters
deviceName String

Returns
IBuildInfo

getBuildInfo

public IBuildInfo getBuildInfo (ITestDevice testDevice)

Return the IBuildInfo associated with the ITestDevice

Parameters
testDevice ITestDevice

Returns
IBuildInfo

getBuildInfoName

public String getBuildInfoName (IBuildInfo info)

Returns the name of device set in the xml configuration from the IBuildInfo. Returns null if the IBuildInfo cannot be matched

Parameters
info IBuildInfo

Returns
String

getBuildInfos

public  getBuildInfos ()

Return all the IBuildInfo tracked for this invocation.

Returns

getConfigurationDescriptor

public ConfigurationDescriptor getConfigurationDescriptor ()

Returns the descriptor associated with the test configuration that launched the invocation

Returns
ConfigurationDescriptor

getDevice

public ITestDevice getDevice (String deviceName)

Return the ITestDevice associated with the device configuration name provided.

Parameters
deviceName String

Returns
ITestDevice

getDeviceBuildMap

public  getDeviceBuildMap ()

Return the map of Device/build info association

Returns

getDeviceBySerial

public ITestDevice getDeviceBySerial (String serial)

Returns the ITestDevice associated with the serial provided. Refrain from using too much as it's not the fastest lookup.

Parameters
serial String

Returns
ITestDevice

getDeviceConfigNames

public  getDeviceConfigNames ()

Return the list of device config names of the device tracked in this invocation

Returns

getDeviceName

public String getDeviceName (ITestDevice device)

Returns the name of the device set in the xml configuration from the ITestDevice. Returns null, if ITestDevice cannot be matched.

Parameters
device ITestDevice

Returns
String

getDevices

public  getDevices ()

Return all the allocated device tracked for this invocation.

Returns

getInvocationId

public String getInvocationId ()

Returns
String

getModuleInvocationContext

public IInvocationContext getModuleInvocationContext ()

Returns the invocation context of module while being executed as part of a suite.

Returns
IInvocationContext

getNumDevicesAllocated

public int getNumDevicesAllocated ()

Return the number of devices allocated for the invocation.

Returns
int

getSerials

public  getSerials ()

Return the list of serials of the device tracked in this invocation

Returns

getShardsSerials

public  getShardsSerials ()

Returns the Map of all tracked serials and their shard involved in sharding. Empty if not a sharded invocation.

Returns

getTestTag

public String getTestTag ()

Returns the invocation test-tag.

Returns
String

lockAttributes

public void lockAttributes ()

Lock the context to prevent more invocation attributes to be added.

logInvocationMetrics

public void logInvocationMetrics ()

Log the InvocationMetricLogger attributes to the invocation.

markReleasedEarly

public void markReleasedEarly ()

Mark the devices are getting released early.

setConfigurationDescriptor

public void setConfigurationDescriptor (ConfigurationDescriptor configurationDescriptor)

Sets the descriptor associated with the test configuration that launched the invocation

Parameters
configurationDescriptor ConfigurationDescriptor

setModuleInvocationContext

public void setModuleInvocationContext (IInvocationContext invocationContext)

Sets the invocation context of module while being executed as part of a suite.

Parameters
invocationContext IInvocationContext

setRecoveryModeForAllDevices

public void setRecoveryModeForAllDevices (ITestDevice.RecoveryMode mode)

Sets the RecoveryMode of all the devices part of the context

Parameters
mode ITestDevice.RecoveryMode

setTestTag

public void setTestTag (String testTag)

Sets the invocation test-tag.

Parameters
testTag String

toProto

public InvocationContext.Context toProto ()

Serialize a the context instance into a protobuf.

Returns
InvocationContext.Context

wasReleasedEarly

public boolean wasReleasedEarly ()

Returns whether or not the devices were released early and won't be used anymore.

Returns
boolean