LargeOutputReceiver

public class LargeOutputReceiver
extends Object implements IShellOutputReceiver

java.lang.Object
   ↳ com.android.tradefed.device.LargeOutputReceiver


旨在帮助运行长时间运行的命令并收集输出的类。

临时文件的大小上限约为 maxFileSize。 为防止达到限制时丢失数据,此文件会保留一组临时主机文件。

摘要

公共构造函数

LargeOutputReceiver(String descriptor, String serialNumber, long maxDataSize)

创建 LargeOutputReceiver。

公共方法

void addOutput(byte[] data, int offset, int length)

每次有新数据可用时都会调用。

void cancel()

取消命令。

void clear()

删除当前累积的数据,然后重新创建新文件。

void delete()

删除所有累积的数据。

void flush()

在进程执行结束时调用(除非进程被取消)。

InputStreamSource getData()

以 InputStreamSource 形式获取收集的输出。

InputStreamSource getData(int maxBytes)

以 InputStreamSource 形式获取收集的输出的最后一个 maxBytes。

InputStreamSource getData(int maxBytes, int offset)

以 InputStreamSource 形式获取收集的输出的最后一个 maxBytes。

boolean isCancelled()

用于停止执行远程 shell 命令的取消方法。

公共构造函数

LargeOutputReceiver

public LargeOutputReceiver (String descriptor, 
                String serialNumber, 
                long maxDataSize)

创建 LargeOutputReceiver。

参数
descriptor String:要运行的命令的描述符。仅用于记录日志。

serialNumber String:设备的序列号。仅用于记录日志。

maxDataSize long:要保留的数据量的大致上限。

公共方法

addOutput

public void addOutput (byte[] data, 
                int offset, 
                int length)

每次有新数据可用时调用。

参数
data byte:新数据。

offset int:新数据的起始偏移量。

length int:新数据的长度。

取消

public void cancel ()

取消命令。

清除

public void clear ()

删除当前累积的数据,然后重新创建一个新文件。

删除

public void delete ()

删除所有累积的数据。

flush

public void flush ()

在进程执行结束时调用(除非进程被取消)。这允许接收方终止并刷新尚未处理的任何数据。

getData

public InputStreamSource getData ()

以 InputStreamSource 形式获取收集的输出。

返回
InputStreamSource 命令的收集输出。

getData

public InputStreamSource getData (int maxBytes)

以 InputStreamSource 形式获取所收集输出的最后一个 maxBytes。

参数
maxBytes int:要返回的数据量上限。应为可轻松容纳在内存中的量

返回
InputStreamSource 命令的收集输出,存储在内存中

getData

public InputStreamSource getData (int maxBytes, 
                int offset)

以 InputStreamSource 形式获取所收集输出的最后一个 maxBytes。

参数
maxBytes int:要返回的数据量上限。应为可轻松容纳在内存中的量

offset int:从缓冲区开始获取数据的偏移量。

返回
InputStreamSource 命令的收集输出,存储在内存中

isCancelled

public boolean isCancelled ()

用于停止执行远程 shell 命令的取消方法。

返回
boolean 如果为 true,则取消命令的执行。