IShellEnabledDevice

public interface IShellEnabledDevice

com.android.ddmlib.IShellEnabledDevice


可接收 shell 命令的抽象设备。

摘要

公共方法

abstract void executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)

在设备上执行 shell 命令,并将结果发送到 receiver。

abstract void executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)

在设备上执行 shell 命令,并将结果发送到 receiver。

abstract String getName()

返回此设备的(人性化)名称。

abstract ListenableFuture<String> getSystemProperty(String name)

对系统属性执行潜在的异步查询。

公共方法

executeShellCommand

public abstract void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeout, 
                long maxTimeToOutputResponse, 
                TimeUnit maxTimeUnits)

在设备上执行 shell 命令,并将结果发送到 receiver。

maxTimeToOutputResponse 用作等待设备命令输出的最长等待时间。
在任何时候,如果 shell 命令在超过 maxTimeToOutputResponse 的时间内未输出任何内容,则该方法将抛出 ShellCommandUnresponsiveException。

对于日志输出等命令,应使用 maxTimeToOutputResponse 值 0,这意味着该方法永远不会抛出异常,并且会一直阻塞,直到接收器的 IShellOutputReceiver.isCancelled() 返回 true。

参数
command String:要执行的 shell 命令

receiver IShellOutputReceiver:将接收 shell 命令输出的 IShellOutputReceiver

maxTimeout long:命令返回结果的最长超时时间。值为 0 表示不应用最大超时。

maxTimeToOutputResponse long:允许命令不输出任何响应的最长时间。值为 0 表示该方法将永远等待(直到 receiver 取消执行)命令输出,并且永远不会抛出异常。

maxTimeUnits TimeUnit:非零 maxTimeout 和 maxTimeToOutputResponse 值的单位。

抛出
AdbCommandRejectedException 如果 adb 拒绝该命令,则会返回此错误。
ShellCommandUnresponsiveException 如果 shell 命令在超过 maxTimeToOutputResponse 的时间内未发送任何输出,则会发生这种情况。
TimeoutException (以防发送命令时连接超时)。
IOException 如果连接发生 I/O 错误。

executeShellCommand

public abstract void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeToOutputResponse, 
                TimeUnit maxTimeUnits)

在设备上执行 shell 命令,并将结果发送到 receiver。

maxTimeToOutputResponse 用作等待设备命令输出的最长等待时间。
在任何时候,如果 shell 命令在超过 maxTimeToOutputResponse 的时间内未输出任何内容,则该方法将抛出 ShellCommandUnresponsiveException。

对于日志输出等命令,应使用 maxTimeToOutputResponse 值 0,这意味着该方法永远不会抛出异常,并且会一直阻塞,直到接收器的 IShellOutputReceiver.isCancelled() 返回 true。

参数
command String:要执行的 shell 命令

receiver IShellOutputReceiver:将接收 shell 命令输出的 IShellOutputReceiver

maxTimeToOutputResponse long:允许命令不输出任何响应的最长时间。值为 0 表示该方法将永远等待(直到 receiver 取消执行)命令输出,并且永远不会抛出异常。

maxTimeUnits TimeUnit:非零 maxTimeToOutputResponse 值的单位。

抛出
AdbCommandRejectedException 如果 adb 拒绝该命令,则会返回此错误。
ShellCommandUnresponsiveException 如果 shell 命令在超过 maxTimeToOutputResponse 的时间内未发送任何输出,则会发生这种情况。
TimeoutException (以防发送命令时连接超时)。
IOException 如果连接发生 I/O 错误。

getName

public abstract String getName ()

返回此设备的(人性化)名称。通常,对于 AVD,这是 AVD 名称;对于设备,这是制造商名称、型号名称和序列号的组合。

返回
String

getSystemProperty

public abstract ListenableFuture<String> getSystemProperty (String name)

对系统属性执行潜在的异步查询。

参数
name String:要返回的值的名称。

返回
ListenableFuture<String> ListenableFuture. get 可能会返回 null。