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
“轮询响应性”命令的最长操作时间(以毫秒为单位) |
String |
PERM_DENIED_ERROR_PATTERN
|
公共构造函数 | |
|---|---|
NativeDeviceStateMonitor(IDeviceManager mgr, IDevice device, boolean fastbootEnabled)
|
|
公共方法 | |
|---|---|
void
|
attachFinalState(TestDeviceState finalState)
附加一个最终状态,以便在达到该状态时中止 waitForDeviceState。 |
void
|
clearTcpFastbootMonitor()
清除设备管理器中的所有状态。 |
TestDeviceState
|
getDeviceState()
获取设备状态。 |
String
|
getFastbootSerialNumber()
获取 fastboot 模式序列号。 |
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
|
setSkipBootComplete(boolean skipBootComplete)
|
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
常量值: 3000 (0x0000000000000bb8)
MAX_OP_TIME
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 |
公共方法
attachFinalState
public void attachFinalState (TestDeviceState finalState)
附加一个最终状态,以便在达到该状态时中止 waitForDeviceState。
| 参数 | |
|---|---|
finalState |
TestDeviceState |
clearTcpFastbootMonitor
public void clearTcpFastbootMonitor ()
清除设备管理器中的所有状态。
getDeviceState
public TestDeviceState getDeviceState ()
获取设备状态。
| 返回 | |
|---|---|
TestDeviceState |
设备的 TestDeviceState |
getFastbootSerialNumber
public String getFastbootSerialNumber ()
获取 fastboot 模式序列号。
| 返回 | |
|---|---|
String |
|
getMountPoint
public String getMountPoint (String mountName)
返回装载点。
如果 IDevice 中的缓存信息不可用,则直接查询设备。
待办事项:将此行为移至 IDevice.getMountPoint(String)
| 参数 | |
|---|---|
mountName |
String:挂载点的名称 |
| 返回 | |
|---|---|
String |
装载点或 null |
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
getSerialNumber
public String getSerialNumber ()
获取设备的序列号。
| 返回 | |
|---|---|
String |
|
isAdbTcp
public boolean isAdbTcp ()
| 返回 | |
|---|---|
boolean |
|
setDefaultAvailableTimeout
public void setDefaultAvailableTimeout (long timeoutMs)
设置等待设备在 waitForDeviceAvailable() 中可用的时间(以毫秒为单位)。
| 参数 | |
|---|---|
timeoutMs |
long |
setDefaultOnlineTimeout
public void setDefaultOnlineTimeout (long timeoutMs)
设置在 waitForDeviceOnline() 中等待设备上线的时间(以毫秒为单位)。
| 参数 | |
|---|---|
timeoutMs |
long |
setFastbootSerialNumber
public void setFastbootSerialNumber (String serial)
设置 fastboot 模式序列号。
| 参数 | |
|---|---|
serial |
String |
setSkipBootComplete
public void setSkipBootComplete (boolean skipBootComplete)
| 参数 | |
|---|---|
skipBootComplete |
boolean |
waitForBootComplete
public boolean waitForBootComplete (long waitTime)
阻塞,直到设置了设备的启动完成标志
| 参数 | |
|---|---|
waitTime |
long:等待的时间量(以毫秒为单位) |
| 返回 | |
|---|---|
boolean |
|
waitForDeviceAvailable
public IDevice waitForDeviceAvailable (long waitTime)
等待设备响应并可用于测试。目前,这意味着软件包管理器和外部存储空间可用。
| 参数 | |
|---|---|
waitTime |
long:等待时间(以毫秒为单位) |
| 返回 | |
|---|---|
IDevice |
如果设备在时间到期之前变为在线状态,则为 IDevice。否则为 null。 |
waitForDeviceAvailable
public IDevice waitForDeviceAvailable ()
等待设备响应并可用于测试。
等同于 waitForDeviceAvailable(long),但使用默认设备启动超时时间。
| 返回 | |
|---|---|
IDevice |
如果设备在时间到期之前变为在线状态,则为 IDevice。否则为 null。 |
waitForDeviceAvailableInRecoverPath
public IDevice waitForDeviceAvailableInRecoverPath (long waitTime)
waitForDeviceAvailable(long) 的特殊变体,在恢复路径期间调用,用于定制处理。
| 参数 | |
|---|---|
waitTime |
long |
| 返回 | |
|---|---|
IDevice |
|
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|
waitForDeviceBootloader
public boolean waitForDeviceBootloader (long time)
等待设备进入引导加载程序。
| 参数 | |
|---|---|
time |
long:等待的最长时间(以毫秒为单位) |
| 返回 | |
|---|---|
boolean |
如果设备在时间到期之前处于引导加载程序中,则为 true |
waitForDeviceBootloaderStateUpdate
public void waitForDeviceBootloaderStateUpdate ()
等待设备引导加载程序状态刷新
waitForDeviceFastbootd
public boolean waitForDeviceFastbootd (String fastbootPath,
long time)等待设备进入 fastbootd。
| 参数 | |
|---|---|
fastbootPath |
String:要使用的 fastboot 二进制文件的路径。 |
time |
long:等待的最长时间(以毫秒为单位) |
| 返回 | |
|---|---|
boolean |
如果设备在时间到期之前处于 fastbootd 状态,则为 true |
waitForDeviceInRecovery
public IDevice waitForDeviceInRecovery ()
使用标准启动超时时间等待设备进入恢复模式。
| 返回 | |
|---|---|
IDevice |
如果设备在时间到期之前进入恢复模式,则为 IDevice。否则为 null。 |
waitForDeviceInRecovery
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。 |
waitForDeviceNotAvailable
public boolean waitForDeviceNotAvailable (long waitTime)
等待设备变为不可用状态
| 参数 | |
|---|---|
waitTime |
long:等待的最长时间(以毫秒为单位) |
| 返回 | |
|---|---|
boolean |
true 如果设备无法使用 |
waitForDeviceOnline
public IDevice waitForDeviceOnline ()
使用标准启动超时时间等待设备上线。
注意:此方法会在设备通过 DDMS 可见后立即返回。它无法保证设备实际上对 adb 命令做出响应 - 请改用 waitForDeviceAvailable()。
| 返回 | |
|---|---|
IDevice |
如果设备在时间到期之前变为在线状态,则为 IDevice。否则为 null。 |
waitForDeviceOnline
public IDevice waitForDeviceOnline (long waitTime)
等待设备上线。
注意:一旦设备通过 DDMS 可见,此方法就会返回。这无法保证设备实际上对 adb 命令做出响应 - 请改用 waitForDeviceAvailable()。
| 参数 | |
|---|---|
waitTime |
long:等待的最长时间(以毫秒为单位) |
| 返回 | |
|---|---|
IDevice |
如果设备在时间到期之前变为在线状态,则为 IDevice。否则为 null。 |
waitForDeviceShell
public boolean waitForDeviceShell (long waitTime)
等待设备响应基本的 adb shell 命令。
| 参数 | |
|---|---|
waitTime |
long:等待时间(以毫秒为单位) |
| 返回 | |
|---|---|
boolean |
如果设备在 waitTime 经过之前恢复响应,则为 true。 |
受保护的方法
createOutputReceiver
protected CollectingOutputReceiver createOutputReceiver ()
公开以进行测试
| 返回 | |
|---|---|
CollectingOutputReceiver |
CollectingOutputReceiver |
getCheckPollTime
protected long getCheckPollTime ()
公开以进行测试
| 返回 | |
|---|---|
long |
|
getCurrentTime
protected long getCurrentTime ()
公开以进行测试
| 返回 | |
|---|---|
long |
|
postOnlineCheck
protected boolean postOnlineCheck (long waitTime)
在联网设备上执行的其他检查
| 参数 | |
|---|---|
waitTime |
long:放弃之前等待的时间(以毫秒为单位) |
| 返回 | |
|---|---|
boolean |
true(如果检查在 waitTime 过期之前成功通过)。否则为 false
|
| 抛出 | |
|---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
|
waitForStoreMount
protected boolean waitForStoreMount (long waitTime)
等待设备的外部存储空间被装载。
| 参数 | |
|---|---|
waitTime |
long:放弃之前等待的时间(以毫秒为单位) |
| 返回 | |
|---|---|
boolean |
true 如果外部存储在 waitTime 过期之前已装载。否则为 false
|
| 抛出 | |
|---|---|
DeviceNotAvailableException |
|