BuildInfo

public class BuildInfo
extends Object implements IBuildInfo

java.lang.Object
   ↳ com.android.tradefed.build.BuildInfo


Generic implementation of a IBuildInfo that should be associated with a ITestDevice.

Summary

Public constructors

BuildInfo()

Creates a BuildInfo using default attribute values.

BuildInfo(String buildId, String buildTargetName)

Creates a BuildInfo

Public methods

void addAppPackageFile(File appPackageFile, String version)

Adds the local apk file and its associated version.

void addBuildAttribute(String attributeName, String attributeValue)

Add a build attribute.

void addBuildAttributes( buildAttributes)

Add build attributes

void cleanUp()

Clean up any temporary build files

void cleanUp( doNotClean)

Version of cleanUp() where some files are not deleted.

IBuildInfo clone()

final void copyAllFileFrom(BuildInfo build)

Copy all the VersionedFile from a given build to this one.

boolean equals(Object obj)

static IBuildInfo fromProto(BuildInformation.BuildInfo protoBuild)

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

getAppPackageFiles()

Gets a copy of the set of local app apk file(s) and their versions.

getBuildAttributes()

Get a set of name-value pairs of additional attributes describing the build.

String getBuildBranch()

Optional method to return the source control branch that the build being tested was produced from.

String getBuildFlavor()

Optional method to return the type of build being tested.

String getBuildId()

Returns the unique identifier of build under test.

String getBuildTargetName()

Return complete name for the build being tested.

String getDeviceSerial()

File getFile(String name)

Helper method to retrieve a file with given name.

File getFile(BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a file with given a BuildInfoFileKey.

getFiles()

Returns all VersionedFiles stored in this BuildInfo.

getProperties()

Returns a copy of the properties currently set on the IBuildInfo.

getRemoteFiles()

Get the paths for build artifacts that are delayed download.

String getTestTag()

Return a unique name for the tests being run.

String getVersion(BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a file version with given a BuildInfoFileKey.

String getVersion(String name)

Helper method to retrieve a file version with given name.

VersionedFile getVersionedFile(BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a VersionedFile with a given BuildInfoFileKey.

final VersionedFile getVersionedFile(String name)

Helper method to retrieve a VersionedFile with a given name.

getVersionedFileKeys()

Returns the set of keys available to query VersionedFile via getFile(BuildInfoFileKey).

final getVersionedFiles(BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a list of VersionedFiles associated with a given BuildInfoFileKey.

int hashCode()

void removeBuildAttribute(String attributeName)

Remove a given attributeName from tracking.

void setBuildBranch(String branch)

Set the build branch

void setBuildFlavor(String buildFlavor)

Set the build flavor.

void setBuildId(String buildId)

Sets the unique identifier of build under test.

void setDeviceSerial(String serial)

Set the ITestDevice serial associated with this build.

void setFile(String name, File file, String version)

Stores an file with given name in this build info.

void setFile(BuildInfoKey.BuildInfoFileKey key, File file, String version)

Stores an file given a BuildInfoFileKey in this build info.

void setProperties(BuildInfoProperties... properties)

Set the BuildInfoProperties for the IBuildInfo instance.

void setTestTag(String testTag)

Sets the unique name for the tests being run.

File stageRemoteFile(String fileName, File workingDir)

Stage a file that's part of remote files in the build info's root dir.

BuildInformation.BuildInfo toProto()

Serialize a the BuildInfo instance into a protobuf.

String toString()

Protected methods

void addAllBuildAttributes(BuildInfo build)

Helper method to copy build attributes, branch, and flavor from other build.

void addAllFiles(BuildInfo build)

Helper method to copy all files from the other build.

boolean applyBuildProperties(VersionedFile origFileConsidered, IBuildInfo build, IBuildInfo receiver)

Allow to apply some of the IBuildInfo.BuildInfoProperties and possibly do a different handling.

MultiMap<String, String> getAttributesMultiMap()
getVersionedFileMap()
MultiMap<String, VersionedFile> getVersionedFileMapFull()

Public constructors

BuildInfo

public BuildInfo ()

Creates a BuildInfo using default attribute values.

BuildInfo

public BuildInfo (String buildId, 
                String buildTargetName)

Creates a BuildInfo

Parameters
buildId String: the build id

buildTargetName String: the build target name

Public methods

addAppPackageFile

public void addAppPackageFile (File appPackageFile, 
                String version)

Adds the local apk file and its associated version. Note that apks will be returned from getAppPackageFiles() in the order in which they were added by this method.

Parameters
appPackageFile File

version String

addBuildAttribute

public void addBuildAttribute (String attributeName, 
                String attributeValue)

Add a build attribute. This doesn't allow overriding an existing attributeName.

Parameters
attributeName String: the unique attribute name

attributeValue String: the attribute value

addBuildAttributes

public void addBuildAttributes ( buildAttributes)

Add build attributes

Parameters
buildAttributes : Map of attributes to be added

cleanUp

public void cleanUp ()

Clean up any temporary build files

cleanUp

public void cleanUp ( doNotClean)

Version of cleanUp() where some files are not deleted.

Parameters
doNotClean

clone

public IBuildInfo clone ()

Returns
IBuildInfo

copyAllFileFrom

public final void copyAllFileFrom (BuildInfo build)

Copy all the VersionedFile from a given build to this one.

Parameters
build BuildInfo

equals

public boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

fromProto

public static IBuildInfo fromProto (BuildInformation.BuildInfo protoBuild)

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

Parameters
protoBuild BuildInformation.BuildInfo

Returns
IBuildInfo

getAppPackageFiles

public  getAppPackageFiles ()

Gets a copy of the set of local app apk file(s) and their versions. The returned order matches the order in which the apks were added to the IAppBuildInfo.

Returns

getBuildAttributes

public  getBuildAttributes ()

Get a set of name-value pairs of additional attributes describing the build.

Returns
a ERROR(/Map) of build attributes. Will not be null, but may be empty.

getBuildBranch

public String getBuildBranch ()

Optional method to return the source control branch that the build being tested was produced from.

Returns
String the build branch or null if unset/not applicable

getBuildFlavor

public String getBuildFlavor ()

Optional method to return the type of build being tested.

A common implementation for Android platform builds is to return (build product)-(build os)-(build variant). ie generic-linux-userdebug

Returns
String the build flavor or null if unset/not applicable

getBuildId

public String getBuildId ()

Returns the unique identifier of build under test. Should never be null. Defaults to UNKNOWN_BUILD_ID.

Returns
String

getBuildTargetName

public String getBuildTargetName ()

Return complete name for the build being tested.

A common implementation is to construct the build target name from a combination of the build flavor and branch name. [ie (branch name)-(build flavor)]

Returns
String

getDeviceSerial

public String getDeviceSerial ()

Returns
String

getFile

public File getFile (String name)

Helper method to retrieve a file with given name.

Returns
File the image file or null if not found

getFile

public File getFile (BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a file with given a BuildInfoFileKey.

Parameters
key BuildInfoKey.BuildInfoFileKey: the BuildInfoFileKey that is requested.

Returns
File the image file or null if not found

getFiles

public  getFiles ()

Returns all VersionedFiles stored in this BuildInfo.

Returns

getProperties

public  getProperties ()

Returns a copy of the properties currently set on the IBuildInfo.

Returns

getRemoteFiles

public  getRemoteFiles ()

Get the paths for build artifacts that are delayed download.

Returns

getTestTag

public String getTestTag ()

Return a unique name for the tests being run.

Returns
String

getVersion

public String getVersion (BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a file version with given a BuildInfoFileKey.

Parameters
key BuildInfoKey.BuildInfoFileKey: The BuildInfoFileKey requested.

Returns
String the image version or null if not found

getVersion

public String getVersion (String name)

Helper method to retrieve a file version with given name.

Returns
String the image version or null if not found

getVersionedFile

public VersionedFile getVersionedFile (BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a VersionedFile with a given BuildInfoFileKey.

Parameters
key BuildInfoKey.BuildInfoFileKey: The BuildInfoFileKey requested.

Returns
VersionedFile The versioned file or null if not found

getVersionedFile

public final VersionedFile getVersionedFile (String name)

Helper method to retrieve a VersionedFile with a given name.

Returns
VersionedFile The versioned file or null if not found

getVersionedFileKeys

public  getVersionedFileKeys ()

Returns the set of keys available to query VersionedFile via getFile(BuildInfoFileKey).

Returns

getVersionedFiles

public final  getVersionedFiles (BuildInfoKey.BuildInfoFileKey key)

Helper method to retrieve a list of VersionedFiles associated with a given BuildInfoFileKey. If the key allows to store a list.

Parameters
key BuildInfoKey.BuildInfoFileKey: The BuildInfoFileKey requested.

Returns
The versioned file or null if not found

hashCode

public int hashCode ()

Returns
int

removeBuildAttribute

public void removeBuildAttribute (String attributeName)

Remove a given attributeName from tracking.

Parameters
attributeName String: the attribute to stop tracking

setBuildBranch

public void setBuildBranch (String branch)

Set the build branch

Parameters
branch String: the branch name

setBuildFlavor

public void setBuildFlavor (String buildFlavor)

Set the build flavor.

setBuildId

public void setBuildId (String buildId)

Sets the unique identifier of build under test. Should never be null.

Parameters
buildId String

setDeviceSerial

public void setDeviceSerial (String serial)

Set the ITestDevice serial associated with this build.

Parameters
serial String: the serial number of the ITestDevice that this build was executed with.

setFile

public void setFile (String name, 
                File file, 
                String version)

Stores an file with given name in this build info.

Parameters
name String: the unique name of the file

file File: the local ERROR(/File)

version String: the file version

setFile

public void setFile (BuildInfoKey.BuildInfoFileKey key, 
                File file, 
                String version)

Stores an file given a BuildInfoFileKey in this build info.

Parameters
key BuildInfoKey.BuildInfoFileKey: the unique name of the file based on BuildInfoFileKey.

file File: the local ERROR(/File)

version String: the file version

setProperties

public void setProperties (BuildInfoProperties... properties)

Set the BuildInfoProperties for the IBuildInfo instance. Override any existing properties set before.

Parameters
properties BuildInfoProperties: The list of properties to add.

setTestTag

public void setTestTag (String testTag)

Sets the unique name for the tests being run.

Parameters
testTag String

stageRemoteFile

public File stageRemoteFile (String fileName, 
                File workingDir)

Stage a file that's part of remote files in the build info's root dir.

TODO(b/138416078): Remove this interface and its caller when modules required by a test can be properly built output to the test module's directory itself.

Parameters
fileName String: Name of the file to be located in remote files.

workingDir File: a ERROR(/File) object of the directory to stage the file.

Returns
File the ERROR(/File) object of the file staged in local workingDir.

toProto

public BuildInformation.BuildInfo toProto ()

Serialize a the BuildInfo instance into a protobuf.

Returns
BuildInformation.BuildInfo

toString

public String toString ()

Returns
String

Protected methods

addAllBuildAttributes

protected void addAllBuildAttributes (BuildInfo build)

Helper method to copy build attributes, branch, and flavor from other build.

Parameters
build BuildInfo

addAllFiles

protected void addAllFiles (BuildInfo build)

Helper method to copy all files from the other build.

Creates new hardlinks to the files so that each build will have a unique file path to the file.

Parameters
build BuildInfo

Throws
if an exception is thrown when creating the hardlink.

applyBuildProperties

protected boolean applyBuildProperties (VersionedFile origFileConsidered, 
                IBuildInfo build, 
                IBuildInfo receiver)

Allow to apply some of the IBuildInfo.BuildInfoProperties and possibly do a different handling.

Parameters
origFileConsidered VersionedFile: The currently looked at VersionedFile.

build IBuildInfo: the original build being cloned

receiver IBuildInfo: the build receiving the information.

Returns
boolean True if we applied the properties and further handling should be skipped. False otherwise.

getAttributesMultiMap

protected MultiMap<String, String> getAttributesMultiMap ()

Returns
MultiMap<String, String>

getVersionedFileMap

protected  getVersionedFileMap ()

Returns

getVersionedFileMapFull

protected MultiMap<String, VersionedFile> getVersionedFileMapFull ()

Returns
MultiMap<String, VersionedFile>