构建信息
public class BuildInfo
extends Object
implements IBuildInfo
java.lang.Object | |
↳ | com.android.tradefed.build.BuildInfo |
应与ITestDevice
关联的IBuildInfo
的通用实现。
概括
公共构造函数 | |
---|---|
BuildInfo () 使用默认属性值创建 | |
BuildInfo (String buildId, String buildTargetName) 创建一个 |
公共方法 | |
---|---|
void | addAppPackageFile (File appPackageFile, String version) 添加本地 apk 文件及其关联版本。 |
void | addBuildAttribute (String attributeName, String attributeValue) 添加构建属性。 |
void | addBuildAttributes ( buildAttributes) addBuildAttributes ( buildAttributes) 添加构建属性 |
void | cleanUp () 清理所有临时构建文件 |
void | cleanUp ( doNotClean) cleanUp ( doNotClean) 不删除某些文件的 |
IBuildInfo | clone () |
final void | copyAllFileFrom ( BuildInfo build) 将给定构建中的所有 |
boolean | equals (Object obj) |
static IBuildInfo | fromProto (BuildInformation.BuildInfo protoBuild) 对 |
getAppPackageFiles () 获取一组本地应用程序 apk 文件及其版本的副本。 | |
getBuildAttributes () 获取一组描述构建的附加属性的名称-值对。 | |
String | getBuildBranch () 可选方法,用于返回生成被测试构建的源代码控制分支。 |
String | getBuildFlavor () 返回正在测试的构建类型的可选方法。 |
String | getBuildId () 返回被测构建的唯一标识符。 |
String | getBuildTargetName () 返回正在测试的构建的完整名称。 |
String | getDeviceSerial () |
File | getFile (String name) 检索具有给定名称的文件的辅助方法。 |
File | getFile ( BuildInfoKey.BuildInfoFileKey key) 使用给定的 |
getFiles () 返回存储在此 | |
getProperties () 返回当前在 | |
getRemoteFiles () 获取延迟下载的构建工件的路径。 | |
String | getTestTag () 返回正在运行的测试的唯一名称。 |
String | getVersion ( BuildInfoKey.BuildInfoFileKey key) 使用给定的 |
String | getVersion (String name) 用于检索具有给定名称的文件版本的帮助程序方法。 |
VersionedFile | getVersionedFile ( BuildInfoKey.BuildInfoFileKey key) 使用给定的 |
final VersionedFile | getVersionedFile (String name) 用于检索具有给定名称的 |
getVersionedFileKeys () 返回可用于通过 | |
final | getVersionedFiles ( BuildInfoKey.BuildInfoFileKey key) 检索与给定 |
int | hashCode () |
void | removeBuildAttribute (String attributeName) 从跟踪中删除给定的 attributeName。 |
void | setBuildBranch (String branch) 设置构建分支 |
void | setBuildFlavor (String buildFlavor) 设置构建风格。 |
void | setBuildId (String buildId) 设置被测构建的唯一标识符。 |
void | setDeviceSerial (String serial) 设置与此构建关联的 |
void | setFile (String name, File file, String version) 在此构建信息中存储具有给定名称的文件。 |
void | setFile ( BuildInfoKey.BuildInfoFileKey key, File file, String version) 在此构建信息中存储给定 |
void | setProperties ( BuildInfoProperties... properties) |
void | setTestTag (String testTag) 为正在运行的测试设置唯一名称。 |
File | stageRemoteFile (String fileName, File workingDir) 在构建信息的根目录中暂存一个属于远程文件的文件。 |
BuildInformation.BuildInfo | toProto () 将 BuildInfo 实例序列化为 protobuf。 |
String | toString ()
|
受保护的方法 | |
---|---|
void | addAllBuildAttributes ( BuildInfo build) 从其他构建复制构建属性、分支和风格的辅助方法。 |
void | addAllFiles ( BuildInfo build) 从其他构建复制所有文件的辅助方法。 |
boolean | applyBuildProperties ( VersionedFile origFileConsidered, IBuildInfo build, IBuildInfo receiver) 允许应用一些 |
MultiMap <String, String> | getAttributesMultiMap () |
getVersionedFileMap () | |
MultiMap <String, VersionedFile > | getVersionedFileMapFull () |
公共构造函数
构建信息
public BuildInfo (String buildId, String buildTargetName)
创建一个BuildInfo
参数 | |
---|---|
buildId | String :构建 ID |
buildTargetName | String : 构建目标名称 |
公共方法
添加应用程序包文件
public void addAppPackageFile (File appPackageFile, String version)
添加本地 apk 文件及其关联版本。请注意,apk 将按照此方法添加它们的顺序从getAppPackageFiles()
返回。
参数 | |
---|---|
appPackageFile | File |
version | String |
添加构建属性
public void addBuildAttribute (String attributeName, String attributeValue)
添加构建属性。这不允许覆盖现有的 attributeName。
参数 | |
---|---|
attributeName | String : 唯一的属性名称 |
attributeValue | String : 属性值 |
添加构建属性
public void addBuildAttributes (buildAttributes)
添加构建属性
参数 | |
---|---|
buildAttributes |
清理
public void cleanUp ()
清理所有临时构建文件
复制所有文件来源
public final void copyAllFileFrom (BuildInfo build)
将给定构建中的所有VersionedFile
复制到这个构建中。
参数 | |
---|---|
build | BuildInfo |
等于
public boolean equals (Object obj)
参数 | |
---|---|
obj | Object |
退货 | |
---|---|
boolean |
来自原型
public static IBuildInfo fromProto (BuildInformation.BuildInfo protoBuild)
对toProto()
进行逆向操作以取回实例。
参数 | |
---|---|
protoBuild | BuildInformation.BuildInfo |
退货 | |
---|---|
IBuildInfo |
获取应用程序包文件
publicgetAppPackageFiles ()
获取一组本地应用程序 apk 文件及其版本的副本。返回的顺序与将 apk 添加到IAppBuildInfo
顺序相匹配。
退货 | |
---|---|
获取构建分支
public String getBuildBranch ()
可选方法,用于返回生成被测试构建的源代码控制分支。
退货 | |
---|---|
String | 构建分支或null 如果未设置/不适用 |
获取BuildFlavor
public String getBuildFlavor ()
返回正在测试的构建类型的可选方法。
Android 平台构建的一个常见实现是返回(构建产品)-(构建操作系统)-(构建变体)。即通用-linux-userdebug退货 | |
---|---|
String | 构建风格或null 如果未设置/不适用 |
getBuildTargetName
public String getBuildTargetName ()
返回正在测试的构建的完整名称。
一个常见的实现是通过构建风格和分支名称的组合来构造构建目标名称。 [即(分支名称)-(构建风味)]退货 | |
---|---|
String |
获取设备序列号
public String getDeviceSerial ()
退货 | |
---|---|
String |
获取文件
public File getFile (String name)
检索具有给定名称的文件的辅助方法。
退货 | |
---|---|
File | 图像文件或null 如果找不到 |
获取文件
public File getFile (BuildInfoKey.BuildInfoFileKey key)
使用给定的BuildInfoFileKey
检索文件的辅助方法。
参数 | |
---|---|
key | BuildInfoKey.BuildInfoFileKey :请求的BuildInfoFileKey 。 |
退货 | |
---|---|
File | 图像文件或null 如果找不到 |
获取远程文件
publicgetRemoteFiles ()
获取延迟下载的构建工件的路径。
退货 | |
---|---|
获取测试标签
public String getTestTag ()
返回正在运行的测试的唯一名称。
退货 | |
---|---|
String |
获取版本
public String getVersion (BuildInfoKey.BuildInfoFileKey key)
使用给定的BuildInfoFileKey
检索文件版本的帮助程序方法。
参数 | |
---|---|
key | BuildInfoKey.BuildInfoFileKey :请求的BuildInfoFileKey 。 |
退货 | |
---|---|
String | 图像版本,如果未找到则为null |
获取版本
public String getVersion (String name)
用于检索具有给定名称的文件版本的帮助程序方法。
退货 | |
---|---|
String | 图像版本,如果未找到则为null |
获取版本文件
public VersionedFile getVersionedFile (BuildInfoKey.BuildInfoFileKey key)
使用给定的BuildInfoFileKey
检索VersionedFile
帮助程序方法。
参数 | |
---|---|
key | BuildInfoKey.BuildInfoFileKey :请求的BuildInfoFileKey 。 |
退货 | |
---|---|
VersionedFile | 版本化文件,如果未找到则为null |
获取版本文件
public final VersionedFile getVersionedFile (String name)
用于检索具有给定名称的VersionedFile
帮助程序方法。
退货 | |
---|---|
VersionedFile | 版本化文件,如果未找到则为null |
getVersionedFileKeys
publicgetVersionedFileKeys ()
返回可用于通过getFile(BuildInfoFileKey)
查询VersionedFile
键集。
退货 | |
---|---|
获取版本文件
public finalgetVersionedFiles (BuildInfoKey.BuildInfoFileKey key)
检索与给定BuildInfoFileKey
关联的VersionedFile
列表的辅助方法。如果密钥允许存储列表。
参数 | |
---|---|
key | BuildInfoKey.BuildInfoFileKey :请求的BuildInfoFileKey 。 |
退货 | |
---|---|
版本化文件,如果未找到则为null |
哈希码
public int hashCode ()
退货 | |
---|---|
int |
移除构建属性
public void removeBuildAttribute (String attributeName)
从跟踪中删除给定的 attributeName。
参数 | |
---|---|
attributeName | String : 停止跟踪的属性 |
设置BuildBranch
public void setBuildBranch (String branch)
设置构建分支
参数 | |
---|---|
branch | String : 分支名称 |
设置BuildFlavor
public void setBuildFlavor (String buildFlavor)
设置构建风格。
设置BuildId
public void setBuildId (String buildId)
设置被测构建的唯一标识符。永远不应该为空。
参数 | |
---|---|
buildId | String |
设置设备序列号
public void setDeviceSerial (String serial)
设置与此构建关联的ITestDevice
序列号。
参数 | |
---|---|
serial | String :执行此构建的ITestDevice 的序列号。 |
设置文件
public void setFile (String name, File file, String version)
在此构建信息中存储具有给定名称的文件。
参数 | |
---|---|
name | String : 文件的唯一名称 |
file | File :本地ERROR(/File) |
version | String :文件版本 |
设置文件
public void setFile (BuildInfoKey.BuildInfoFileKey key, File file, String version)
在此构建信息中存储给定BuildInfoFileKey
文件。
参数 | |
---|---|
key | BuildInfoKey.BuildInfoFileKey :基于BuildInfoFileKey 的文件的唯一名称。 |
file | File :本地ERROR(/File) |
version | String :文件版本 |
设置属性
public void setProperties (BuildInfoProperties... properties)
为IBuildInfo
实例设置BuildInfoProperties
。覆盖之前设置的任何现有属性。
参数 | |
---|---|
properties | BuildInfoProperties :要添加的属性列表。 |
设置测试标签
public void setTestTag (String testTag)
为正在运行的测试设置唯一名称。
参数 | |
---|---|
testTag | String |
阶段远程文件
public File stageRemoteFile (String fileName, File workingDir)
在构建信息的根目录中暂存一个属于远程文件的文件。
TODO(b/138416078):当测试所需的模块可以正确构建输出到测试模块目录本身时,删除此接口及其调用方。
参数 | |
---|---|
fileName | String :要位于远程文件中的文件的名称。 |
workingDir | File :用于暂存文件的目录的ERROR(/File) 对象。 |
退货 | |
---|---|
File | 在本地 workingDir 中暂存的文件的ERROR(/File) 对象。 |
到原型
public BuildInformation.BuildInfo toProto ()
将 BuildInfo 实例序列化为 protobuf。
退货 | |
---|---|
BuildInformation.BuildInfo |
到字符串
public String toString ()
退货 | |
---|---|
String |
受保护的方法
添加所有构建属性
protected void addAllBuildAttributes (BuildInfo build)
从其他构建复制构建属性、分支和风格的辅助方法。
参数 | |
---|---|
build | BuildInfo |
添加所有文件
protected void addAllFiles (BuildInfo build)
从其他构建复制所有文件的辅助方法。
为文件创建新的硬链接,以便每个构建都有一个唯一的文件路径。
参数 | |
---|---|
build | BuildInfo |
投掷 | |
---|---|
| 如果在创建硬链接时抛出异常。 |
applyBuildProperties
protected boolean applyBuildProperties (VersionedFile origFileConsidered, IBuildInfo build, IBuildInfo receiver)
允许应用一些IBuildInfo.BuildInfoProperties
并可能进行不同的处理。
参数 | |
---|---|
origFileConsidered | VersionedFile :当前查看的VersionedFile 。 |
build | IBuildInfo :被克隆的原始构建 |
receiver | IBuildInfo :接收信息的构建。 |
退货 | |
---|---|
boolean | 如果我们应用了这些属性并且应该跳过进一步的处理,则为真。否则为假。 |
getAttributesMultiMap
protected MultiMap<String, String> getAttributesMultiMap ()
退货 | |
---|---|
MultiMap <String, String> |
getVersionedFileMap
protectedgetVersionedFileMap ()
退货 | |
---|---|
getVersionedFileMapFull
protected MultiMap<String, VersionedFile> getVersionedFileMapFull ()
退货 | |
---|---|
MultiMap <String, VersionedFile > |