DeviceFileReporter

public class DeviceFileReporter
extends Object

java.lang.Object
   ↳ com.android.tradefed.result.DeviceFileReporter


一种实用程序类,用于检查设备上是否存在文件,如果存在,则将文件发送到 ITestInvocationListener.testLog(String,LogDataType,InputStreamSource)

摘要

公共构造函数

DeviceFileReporter(ITestDevice device, ITestInvocationListener listener)

使用提供的 ITestDevice 初始化新的 DeviceFileReporter

公共方法

void addPatterns(Map<String, LogDataType> patterns)

添加了具有相应日志数据类型的模式

void addPatterns(List<String> patterns)

添加了将日志数据类型设置为默认值的模式。

void addPatterns(String... patterns)

添加了将日志数据类型设置为默认值的模式。

List<String> run()

实际在文件系统中搜索指定模式,并在找到时将其发送到 ITestInvocationListener.testLog

void setDefaultLogDataType(LogDataType type)

为没有关联类型的模式设置默认日志数据类型集。

void setInferUnknownDataTypes(boolean infer)

是否通过将文件扩展名与列表进行比较来尝试推断 UNKNOWN 文件的数据类型。

void setSkipRepeatFiles(boolean skip)

是否跳过已报告的文件。

公共构造函数

DeviceFileReporter

public DeviceFileReporter (ITestDevice device, 
                ITestInvocationListener listener)

使用提供的 ITestDevice 初始化新的 DeviceFileReporter

参数
device ITestDevice

listener ITestInvocationListener

公共方法

addPatterns

public void addPatterns (Map<String, LogDataType> patterns)

添加具有相应日志数据类型的模式

参数
patterns Map:一个 Map,包含 String 文件名 glob 模式及其各自的 LogDataType。glob 应该是绝对路径。

addPatterns

public void addPatterns (List<String> patterns)

添加了日志数据类型设置为默认值的模式。

参数
patterns List:包含 String 文件名 glob 模式的 List。应为绝对路径。

addPatterns

public void addPatterns (String... patterns)

添加了日志数据类型设置为默认值的模式。

参数
patterns String:一个 String 文件名 glob 模式的可变实参数组。应为绝对路径。

run

public List<String> run ()

实际在文件系统中搜索指定模式,并在找到时将其发送到 ITestInvocationListener.testLog

返回
List<String>

抛出
DeviceNotAvailableException

setDefaultLogDataType

public void setDefaultLogDataType (LogDataType type)

为没有关联类型的模式设置默认日志数据类型集。

参数
type LogDataTypeLogDataType

另见:

setInferUnknownDataTypes

public void setInferUnknownDataTypes (boolean infer)

是否通过将文件扩展名与列表进行比较来尝试推断 UNKNOWN 文件的数据类型。

请注意,启用后,系统只会对文件类型为 UNKNOWN 的模式进行此类推理(包括添加时未指定类型且未手动设置默认类型的模式)。如果推断失败,数据类型将保持为 UNKNOWN

参数
infer boolean

setSkipRepeatFiles

public void setSkipRepeatFiles (boolean skip)

是否跳过已报告的文件。仅当使用多个模式且其中两个或更多个模式匹配同一文件时,此属性才相关。

请注意,此方法只能在调用 run() 之前调用。否则会导致未定义的行为。

参数
skip boolean