NativeDeviceStateMonitor
public class NativeDeviceStateMonitor
extends Object
implements IDeviceStateMonitor
java.lang.Object | |
↳ | com.android.tradefed.device.NativeDeviceStateMonitor |
用于在没有框架支持的情况下监视IDevice
状态的帮助程序类。
概括
常数 | |
---|---|
long | MAX_CHECK_POLL_TIME |
int | MAX_OP_TIME “轮询响应能力”命令的最大操作时间(以毫秒为单位) |
领域 | |
---|---|
protected static final String | PERM_DENIED_ERROR_PATTERN
|
公共构造函数 | |
---|---|
NativeDeviceStateMonitor ( IDeviceManager mgr, IDevice device, boolean fastbootEnabled) |
公共方法 | |
---|---|
TestDeviceState | getDeviceState () 获取设备状态。 |
String | getFastbootSerialNumber () 获取快速启动模式序列号。 |
String | getMountPoint (String mountName) 返回一个挂载点。 |
String | getSerialNumber () 获取设备的序列号。 |
boolean | isAdbTcp () |
void | setDefaultAvailableTimeout (long timeoutMs) 在 |
void | setDefaultOnlineTimeout (long timeoutMs) 在 |
void | setFastbootSerialNumber (String serial) 设置fastboot模式序列号。 |
void | setIDevice (IDevice newDevice) 更新当前的 IDevice。 |
void | setState ( TestDeviceState deviceState) 设置设备当前状态。 |
boolean | waitForBootComplete (long waitTime) 阻塞直到设置设备的启动完成标志 |
IDevice | waitForDeviceAvailable (long waitTime) 等待设备响应并可用于测试。 |
IDevice | waitForDeviceAvailable () 等待设备响应并可用于测试。 |
IDevice | waitForDeviceAvailableInRecoverPath (long waitTime) 在恢复路径期间调用 |
boolean | waitForDeviceBootloader (long time) 等待设备进入引导加载程序。 |
void | waitForDeviceBootloaderStateUpdate () 等待设备引导加载程序状态刷新 |
boolean | waitForDeviceFastbootd (String fastbootPath, long time) 等待设备进入 fastbootd。 |
IDevice | waitForDeviceInRecovery () 使用标准启动超时等待设备进入恢复模式。 |
boolean | waitForDeviceInRecovery (long waitTime) 等待设备处于“adb recovery”状态 |
boolean | waitForDeviceInSideload (long waitTime) 等待设备处于“adb sideload”状态 |
boolean | waitForDeviceNotAvailable (long waitTime) 等待设备不可用 |
IDevice | waitForDeviceOnline () 使用标准启动超时等待设备上线。 |
IDevice | waitForDeviceOnline (long waitTime) 等待设备上线。 |
boolean | waitForDeviceShell (long waitTime) 等待设备响应基本的 adb shell 命令。 |
受保护的方法 | |
---|---|
CollectingOutputReceiver | createOutputReceiver () 暴露测试 |
long | getCheckPollTime () 暴露测试 |
long | getCurrentTime () 暴露测试 |
IDevice | getIDevice () |
boolean | postOnlineCheck (long waitTime) 在在线设备上进行额外检查 |
boolean | waitForStoreMount (long waitTime) 等待安装设备的外部存储。 |
常数
MAX_CHECK_POLL_TIME
protected static final long MAX_CHECK_POLL_TIME
常量值:10000 (0x0000000000002710)
最长操作时间
protected static final int MAX_OP_TIME
“轮询响应能力”命令的最大操作时间(以毫秒为单位)
常量值:10000 (0x00002710)
领域
PERM_DENIED_ERROR_PATTERN
protected static final String PERM_DENIED_ERROR_PATTERN
公共构造函数
NativeDeviceStateMonitor
public NativeDeviceStateMonitor (IDeviceManager mgr, IDevice device, boolean fastbootEnabled)
参数 | |
---|---|
mgr | IDeviceManager |
device | IDevice |
fastbootEnabled | boolean |
公共方法
获取Fastboot序列号
public String getFastbootSerialNumber ()
获取快速启动模式序列号。
退货 | |
---|---|
String |
获取挂载点
public String getMountPoint (String mountName)
返回一个挂载点。
如果IDevice
中的缓存信息不可用,则直接查询设备。
TODO:将此行为移至IDevice#getMountPoint(String)
参数 | |
---|---|
mountName | String : 挂载点的名称 |
退货 | |
---|---|
String | 挂载点或null |
投掷 | |
---|---|
DeviceNotAvailableException |
获取序列号
public String getSerialNumber ()
获取设备的序列号。
退货 | |
---|---|
String |
是AdbTcp
public boolean isAdbTcp ()
退货 | |
---|---|
boolean |
设置默认可用超时
public void setDefaultAvailableTimeout (long timeoutMs)
在waitForDeviceAvailable()
中设置等待设备可用的时间(以毫秒为单位)。
参数 | |
---|---|
timeoutMs | long |
设置默认在线超时
public void setDefaultOnlineTimeout (long timeoutMs)
在waitForDeviceOnline()
中设置等待设备上线的时间(以毫秒为单位)。
参数 | |
---|---|
timeoutMs | long |
设置快速启动序列号
public void setFastbootSerialNumber (String serial)
设置fastboot模式序列号。
参数 | |
---|---|
serial | String |
设置设备
public void setIDevice (IDevice newDevice)
更新当前的 IDevice。
等待启动完成
public boolean waitForBootComplete (long waitTime)
阻塞直到设置设备的启动完成标志
参数 | |
---|---|
waitTime | long :等待的时间(以毫秒为单位) |
退货 | |
---|---|
boolean |
等待设备可用
public IDevice waitForDeviceAvailable (long waitTime)
等待设备响应并可用于测试。目前这意味着包管理器和外部存储可用。
参数 | |
---|---|
waitTime | long :等待时间(以毫秒为单位) |
退货 | |
---|---|
IDevice | 如果设备在时间到期之前上线,则IDevice 。否则为null 。 |
等待设备可用
public IDevice waitForDeviceAvailable ()
等待设备响应并可用于测试。
相当于waitForDeviceAvailable(long)
,但使用默认设备启动超时。退货 | |
---|---|
IDevice | 如果设备在时间到期之前上线,则IDevice 。否则为null 。 |
waitForDeviceAvailableInRecoverPath
public IDevice waitForDeviceAvailableInRecoverPath (long waitTime)
在恢复路径期间调用waitForDeviceAvailable(long)
的特殊变体以定制处理。
参数 | |
---|---|
waitTime | long |
退货 | |
---|---|
IDevice |
投掷 | |
---|---|
DeviceNotAvailableException |
等待设备引导加载程序
public boolean waitForDeviceBootloader (long time)
等待设备进入引导加载程序。
参数 | |
---|---|
time | long :等待的最长时间(以毫秒为单位) |
退货 | |
---|---|
boolean | 如果设备在时间到期之前处于引导加载程序中,则为true |
waitForDeviceBootloaderStateUpdate
public void waitForDeviceBootloaderStateUpdate ()
等待设备引导加载程序状态刷新
等待设备快速启动
public boolean waitForDeviceFastbootd (String fastbootPath, long time)
等待设备进入 fastbootd。
参数 | |
---|---|
fastbootPath | String :要使用的 fastboot 二进制文件的路径。 |
time | long :等待的最长时间(以毫秒为单位) |
退货 | |
---|---|
boolean | 如果设备在时间到期之前处于 fastbootd 状态, true |
等待设备恢复
public IDevice waitForDeviceInRecovery ()
使用标准启动超时等待设备进入恢复模式。
退货 | |
---|---|
IDevice | 如果设备在时间到期之前恢复,则IDevice 。否则为null 。 |
等待设备恢复
public boolean waitForDeviceInRecovery (long waitTime)
等待设备处于“adb recovery”状态
参数 | |
---|---|
waitTime | long :等待的最长时间(以毫秒为单位) |
退货 | |
---|---|
boolean | 如果设备在超时前处于恢复状态,则为 True,否则为 False。 |
waitForDeviceInSideload
public boolean waitForDeviceInSideload (long waitTime)
等待设备处于“adb sideload”状态
参数 | |
---|---|
waitTime | long :等待的最长时间(以毫秒为单位) |
退货 | |
---|---|
boolean | 如果设备在超时之前处于旁加载状态,则为 True,否则为 False。 |
等待设备不可用
public boolean waitForDeviceNotAvailable (long waitTime)
等待设备不可用
参数 | |
---|---|
waitTime | long :等待的最长时间(以毫秒为单位) |
退货 | |
---|---|
boolean | 如果设备不可用则为true |
等待设备在线
public IDevice waitForDeviceOnline ()
使用标准启动超时等待设备上线。
注意:一旦设备通过 DDMS 可见,此方法就会返回。它不保证设备实际上响应 adb 命令 - 请改用waitForDeviceAvailable()
。退货 | |
---|---|
IDevice | 如果设备在时间到期之前上线,则IDevice 。否则为null 。 |
等待设备在线
public IDevice waitForDeviceOnline (long waitTime)
等待设备上线。
注意:一旦设备通过 DDMS 可见,此方法就会返回。它不保证设备实际上响应 adb 命令 - 请改用waitForDeviceAvailable()
。参数 | |
---|---|
waitTime | long :等待的最长时间(以毫秒为单位) |
退货 | |
---|---|
IDevice | 如果设备在时间到期之前上线,则IDevice 。否则为null 。 |
等待设备外壳
public boolean waitForDeviceShell (long waitTime)
等待设备响应基本的 adb shell 命令。
参数 | |
---|---|
waitTime | long :等待时间(以毫秒为单位) |
退货 | |
---|---|
boolean | 如果设备在waitTime过去之前变得响应,则为true 。 |
受保护的方法
创建输出接收器
protected CollectingOutputReceiver createOutputReceiver ()
暴露测试
退货 | |
---|---|
CollectingOutputReceiver | CollectingOutputReceiver |
获取检查轮询时间
protected long getCheckPollTime ()
暴露测试
退货 | |
---|---|
long |
获取当前时间
protected long getCurrentTime ()
暴露测试
退货 | |
---|---|
long |
在线检查后
protected boolean postOnlineCheck (long waitTime)
在在线设备上进行额外检查
参数 | |
---|---|
waitTime | long :放弃之前等待的时间(以毫秒为单位) |
退货 | |
---|---|
boolean | 如果在 waitTime 到期之前检查成功,则为true 。否则为false |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
等待StoreMount
protected boolean waitForStoreMount (long waitTime)
等待安装设备的外部存储。
参数 | |
---|---|
waitTime | long :放弃之前等待的时间(以毫秒为单位) |
退货 | |
---|---|
boolean | 如果在 waitTime 到期之前安装了外部存储,则为true 。否则为false |
投掷 | |
---|---|
DeviceNotAvailableException |