ICommandScheduler

public interface ICommandScheduler

com.android.tradefed.command.ICommandScheduler


用于运行 TradeFederation 命令的调度程序。

概括

嵌套类

interface ICommandScheduler.IScheduledInvocationListener

调用完成时调用事件的侦听器。

公共方法

abstract Pair <Boolean, Integer> addCommand (String[] args)

向调度程序添加命令。

abstract void addCommandFile (String cmdFile, extraArgs) addCommandFile (String cmdFile, extraArgs)

将给定文件中的所有命令添加到调度程序

abstract void await ()

等待调度程序开始运行,包括等待旧 TF 的切换完成(如果适用)。

abstract void displayCommandQueue (PrintWriter printWriter)

输出有关命令执行队列状态的详细调试信息。

abstract void displayCommandsInfo (PrintWriter printWriter, String regex)

输出当前命令的列表。

abstract void displayInvocationsInfo (PrintWriter printWriter)

显示当前调用的列表。

abstract void dumpCommandsXml (PrintWriter printWriter, String regex)

转储命令的扩展 xml 文件,其中包含为所有当前命令指定的所有Option值。

abstract long execCommand ( IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, String[] args)

直接分配设备并执行命令,而不使用已存在的IInvocationContext将其添加到命令队列。

abstract long execCommand ( ICommandScheduler.IScheduledInvocationListener listener, String[] args)

直接分配设备并执行命令,而不将其添加到命令队列中。

abstract long execCommand ( ICommandScheduler.IScheduledInvocationListener listener, devices, String[] args) execCommand ( ICommandScheduler.IScheduledInvocationListener listener, devices, String[] args)

直接在已经分配的设备上执行命令。

abstract CommandFileWatcher getCommandFileWatcher ()

为此调度程序获取适当的CommandFileWatcher

abstract int getExecutingCommandCount ()

返回处于执行状态的命令数。

abstract String getInvocationInfo (int invocationId)

返回有关指定调用 ID 的调用的信息。

abstract CommandRunner.ExitCode getLastInvocationExitCode ()

返回最后一次运行的调用的错误代码。

abstract Throwable getLastInvocationThrowable ()

从最后一次运行的调用中返回ERROR(/Throwable)

abstract int getReadyCommandCount ()

返回队列中处于就绪状态的命令数。

abstract boolean isDeviceInInvocationThread ( ITestDevice device)

如果设备由活动调用线程使用,则返回 true。

abstract void join ()

等待调度程序完成。

abstract void join (long millis)

在指定的持续时间(以毫秒为单位)后等待调度程序完成或超时。

abstract void removeAllCommands ()

从调度程序中删除所有命令

abstract void setClearcutClient (ClearcutClient client)

设置客户端上报线束数据

abstract boolean shouldShutdownOnCmdfileError ()

如果我们需要在命令错误时关闭调度程序,则返回 true

default void shutdown ()

尝试正常关闭命令调度程序。

abstract void shutdown (boolean notifyStop)

尝试正常关闭命令调度程序。

abstract void shutdownHard (boolean killAdb)

尝试强制关闭命令调度程序。

abstract void shutdownHard ()

尝试强制关闭命令调度程序。

abstract void shutdownOnEmpty ()

类似于shutdown() ,但会在退出前等待所有命令执行完毕。

abstract void start ()

启动ICommandScheduler

abstract boolean stopInvocation (int invocationId, String cause)

通过指定它的 id 来停止正在运行的调用。

default boolean stopInvocation (int invocationId)

通过指定它的 id 来停止正在运行的调用。

abstract boolean stopInvocation ( ITestInvocation invocation)

停止正在运行的调用。

公共方法

添加命令

public abstract Pair<Boolean, Integer> addCommand (String[] args)

向调度程序添加命令。

命令本质上是要运行的配置及其相关参数的实例。

如果指定了“--help”参数,配置的帮助文本将输出到标准输出。否则,配置将被添加到队列中以运行。

参数
args String :配置参数。

退货
Pair <Boolean, Integer>一对值,如果成功添加命令,第一个值为布尔值true 。第二个值是已知的命令跟踪器id(非负值)如果命令添加成功,则为所有设备添加命令时返回0,否则返回-1。

投掷
ConfigurationException如果无法解析命令

添加命令文件

public abstract void addCommandFile (String cmdFile, 
                 extraArgs)

将给定文件中的所有命令添加到调度程序

参数
cmdFile String : 命令文件的文件系统路径

extraArgs : 一个ERROR(/List)ERROR(/String)参数附加到从文件解析的每个命令。可以为空但不应为空。

投掷
ConfigurationException如果无法解析命令文件

也可以看看:

等待

public abstract void await ()

等待调度程序开始运行,包括等待旧 TF 的切换完成(如果适用)。

显示命令队列

public abstract void displayCommandQueue (PrintWriter printWriter)

输出有关命令执行队列状态的详细调试信息。

显示命令信息

public abstract void displayCommandsInfo (PrintWriter printWriter, 
                String regex)

输出当前命令的列表。

参数
printWriter PrintWriter :要输出到的ERROR(/PrintWriter)

regex String :为了打印命令应该匹配的正则表达式。如果为空,则将打印所有命令。

显示调用信息

public abstract void displayInvocationsInfo (PrintWriter printWriter)

显示当前调用的列表。

参数
printWriter PrintWriter :要输出到的ERROR(/PrintWriter)

dumpCommandsXml

public abstract void dumpCommandsXml (PrintWriter printWriter, 
                String regex)

转储命令的扩展 xml 文件,其中包含为所有当前命令指定的所有Option值。

参数
printWriter PrintWriter :将状态输出到的ERROR(/PrintWriter)

regex String :为了转储 xml 文件,命令应与其匹配的正则表达式。如果为空,则将转储所有命令。

执行命令

public abstract long execCommand (IInvocationContext context, 
                ICommandScheduler.IScheduledInvocationListener listener, 
                String[] args)

直接分配设备并执行命令,而不使用已存在的IInvocationContext将其添加到命令队列。

参数
context IInvocationContext :一个现有的IInvocationContext

listener ICommandScheduler.IScheduledInvocationListener :要通知的ICommandScheduler.IScheduledInvocationListener

args String :命令参数

退货
long

投掷
ConfigurationException如果命令无效
NoDeviceException如果没有设备可以使用

执行命令

public abstract long execCommand (ICommandScheduler.IScheduledInvocationListener listener, 
                String[] args)

直接分配设备并执行命令,而不将其添加到命令队列中。

参数
listener ICommandScheduler.IScheduledInvocationListener :要通知的ICommandScheduler.IScheduledInvocationListener

args String :命令参数

退货
long计划命令的调用 ID。

投掷
ConfigurationException如果命令无效
NoDeviceException如果没有设备可以使用

执行命令

public abstract long execCommand (ICommandScheduler.IScheduledInvocationListener listener, 
                 devices, 
                String[] args)

直接在已经分配的设备上执行命令。

参数
listener ICommandScheduler.IScheduledInvocationListener :要通知的ICommandScheduler.IScheduledInvocationListener

devices : ERROR(/List ) ERROR(/List )使用

args String :命令参数

退货
long计划命令的调用 ID。

投掷
ConfigurationException如果命令无效

getCommandFileWatcher

public abstract CommandFileWatcher getCommandFileWatcher ()

为此调度程序获取适当的CommandFileWatcher

退货
CommandFileWatcher

getExecutingCommandCount

public abstract int getExecutingCommandCount ()

返回处于执行状态的命令数。

退货
int

获取调用信息

public abstract String getInvocationInfo (int invocationId)

返回有关指定调用 ID 的调用的信息。

参数
invocationId int :调用的跟踪 ID。

退货
String包含有关调用的信息的ERROR(/String)

getLastInvocationExitCode

public abstract CommandRunner.ExitCode getLastInvocationExitCode ()

返回最后一次运行的调用的错误代码。如果尚未运行任何调用,则返回 0(无错误)。

退货
CommandRunner.ExitCode

getLastInvocationThrowable

public abstract Throwable getLastInvocationThrowable ()

从最后一次运行的调用中返回ERROR(/Throwable) 。如果没有可用的 throwable,则返回 null。

退货
Throwable

getReadyCommandCount

public abstract int getReadyCommandCount ()

返回队列中处于就绪状态的命令数。

退货
int

isDeviceInInvocationThread

public abstract boolean isDeviceInInvocationThread (ITestDevice device)

如果设备由活动调用线程使用,则返回 true。

参数
device ITestDevice

退货
boolean

加入

public abstract void join ()

等待调度程序完成。

也可以看看:

加入

public abstract void join (long millis)

在指定的持续时间(以毫秒为单位)后等待调度程序完成或超时。

参数
millis long

也可以看看:

删除所有命令

public abstract void removeAllCommands ()

从调度程序中删除所有命令

设置清除客户端

public abstract void setClearcutClient (ClearcutClient client)

设置客户端上报线束数据

参数
client ClearcutClient

shouldShutdownOnCmdfileError

public abstract boolean shouldShutdownOnCmdfileError ()

如果我们需要在命令错误时关闭调度程序,则返回 true

退货
boolean

关闭

public void shutdown ()

尝试正常关闭命令调度程序。

清除等待测试的命令,并请求所有正在进行的调用正常关闭。

调用 shutdown 后,调度程序主循环将等待所有正在进行的调用完成,然后才完全退出。

关闭

public abstract void shutdown (boolean notifyStop)

尝试正常关闭命令调度程序。

参数
notifyStop boolean :如果为真,则通知调用 TF 关闭。

硬关机

public abstract void shutdownHard (boolean killAdb)

尝试强制关闭命令调度程序。

类似于shutdown() ,但也可以选择终止 adb 连接,以试图“激发”正在进行的调用以更快地完成。

参数
killAdb boolean

硬关机

public abstract void shutdownHard ()

尝试强制关闭命令调度程序。与 shutdownHard(true) 相同。

关机时空

public abstract void shutdownOnEmpty ()

类似于shutdown() ,但会在退出前等待所有命令执行完毕。

请注意,如果任何命令处于循环模式,调度程序将永远不会退出。

开始

public abstract void start ()

启动ICommandScheduler

必须在调用其他方法之前调用。

将运行直到shutdown()被调用。见ERROR(/Thread#start())

停止调用

public abstract boolean stopInvocation (int invocationId, 
                String cause)

通过指定它的 id 来停止正在运行的调用。

参数
invocationId int :调用的跟踪 ID。

cause String :停止调用的原因。

退货
boolean如果调用已停止,则为 true,否则为 false

投掷
如果实现不支持这个

停止调用

public boolean stopInvocation (int invocationId)

通过指定它的 id 来停止正在运行的调用。

参数
invocationId int

退货
boolean如果调用已停止,则为 true,否则为 false

投掷
如果实现不支持这个

停止调用

public abstract boolean stopInvocation (ITestInvocation invocation)

停止正在运行的调用。

参数
invocation ITestInvocation

退货
boolean如果调用已停止,则为 true,否则为 false

投掷
如果实现不支持这个