BackgroundDeviceAction

public class BackgroundDeviceAction
extends Thread

java.lang.Object
java.lang.Thread
  com.android.tradefed.device.BackgroundDeviceAction


在给定设备上运行命令,并根据需要重复运行,直到操作被取消。

运行该类时,命令会在单独的线程中在设备上运行,并且输出会 收集在临时主机文件中。

这样做是为了:

  • 如果设备在测试期间永久离线,则会保留日志数据。
  • 捕获比设备循环日志中可能容纳的更多数据。

摘要

常量

String BACKGROUND_DEVICE_ACTION

公共构造函数

BackgroundDeviceAction(String command, String descriptor, ITestDevice device, IShellOutputReceiver receiver, int startDelay)
BackgroundDeviceAction(String command, String descriptor, ITestDevice device, IShellOutputReceiver receiver, int startDelay, boolean noRepetitiveLogging)

创建 BackgroundDeviceAction

公共方法

void cancel()

取消命令。

boolean isCancelled()

如果命令被取消。

void run()

重复运行命令,直到取消。

受保护的方法

void waitForDeviceRecovery(String exceptionType)

如果设备因任何原因离线,恢复将从主线程触发 ,因此我们只需阻塞,直到设备恢复或因设备不可用而调用失败。

常量

BACKGROUND_DEVICE_ACTION

public static final String BACKGROUND_DEVICE_ACTION

常量值: "BackgroundDeviceAction"

公共构造函数

BackgroundDeviceAction

public BackgroundDeviceAction (String command, 
                String descriptor, 
                ITestDevice device, 
                IShellOutputReceiver receiver, 
                int startDelay)

参数
command String

descriptor String

device ITestDevice

receiver IShellOutputReceiver

startDelay int

BackgroundDeviceAction

public BackgroundDeviceAction (String command, 
                String descriptor, 
                ITestDevice device, 
                IShellOutputReceiver receiver, 
                int startDelay, 
                boolean noRepetitiveLogging)

创建 BackgroundDeviceAction

参数
command String:要运行的命令

descriptor String:命令的说明。仅用于日志记录。

device ITestDevice:要在其上运行命令的设备

receiver IShellOutputReceiver:用于收集命令输出的接收器

startDelay int:设备上线后要等待的延迟时间

noRepetitiveLogging boolean:是否禁止重复日志记录

公共方法

cancel

public void cancel ()

取消命令。

isCancelled

public boolean isCancelled ()

如果命令被取消。

返回
boolean

run

public void run ()

重复运行命令,直到取消。

受保护的方法

waitForDeviceRecovery

protected void waitForDeviceRecovery (String exceptionType)

如果设备因任何原因离线,恢复将从主线程 触发,因此我们只需阻塞,直到设备恢复或因设备不可用而调用失败。