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)

设置在 waitForDeviceAvailable() 中等待设备可用的时间(以毫秒为单位)。

void setDefaultOnlineTimeout(long timeoutMs)

waitForDeviceOnline() 中设置设备在线等待的等待时间(以毫秒为单位)。

void setFastbootSerialNumber(String serial)

设置 fastboot 模式序列号。

void setIDevice(IDevice newDevice)
void setState(TestDeviceState deviceState)

boolean waitForBootComplete(long waitTime)

IDevice waitForDeviceAvailable(long waitTime)

IDevice waitForDeviceAvailable()

boolean waitForDeviceBootloader(long time)

void waitForDeviceBootloaderStateUpdate()
boolean waitForDeviceFastbootd(String fastbootPath, long time)

IDevice waitForDeviceInRecovery()
boolean waitForDeviceInRecovery(long waitTime)

boolean waitForDeviceInSideload(long waitTime)

boolean waitForDeviceNotAvailable(long waitTime)

IDevice waitForDeviceOnline()

IDevice waitForDeviceOnline(long waitTime)

boolean waitForDeviceShell(long waitTime)

受保护的方法

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

常量值: 30000 (0x0000000000007530)

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

公共方法

getDeviceState

public TestDeviceState getDeviceState ()

返回
TestDeviceState

getFastbootSerialNumber

public String getFastbootSerialNumber ()

返回
String

getMountPoint

public String getMountPoint (String mountName)

参数
mountName String

返回
String

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

setIDevice

public void setIDevice (IDevice newDevice)

参数
newDevice IDevice

setState

public void setState (TestDeviceState deviceState)

参数
deviceState TestDeviceState

waitForBootComplete

public boolean waitForBootComplete (long waitTime)

参数
waitTime long

返回
boolean

waitForDeviceAvailable

public IDevice waitForDeviceAvailable (long waitTime)

参数
waitTime long

返回
IDevice

waitForDeviceAvailable

public IDevice waitForDeviceAvailable ()

返回
IDevice

waitForDeviceBootloader

public boolean waitForDeviceBootloader (long time)

参数
time long

返回
boolean

waitForDeviceBootloaderStateUpdate

public void waitForDeviceBootloaderStateUpdate ()

waitForDeviceFastbootd

public boolean waitForDeviceFastbootd (String fastbootPath, 
                long time)

参数
fastbootPath String

time long

返回
boolean

等待设备恢复

public IDevice waitForDeviceInRecovery ()

返回
IDevice

waitForDeviceInRecovery

public boolean waitForDeviceInRecovery (long waitTime)

参数
waitTime long

返回
boolean

waitForDeviceInSideload

public boolean waitForDeviceInSideload (long waitTime)

参数
waitTime long

返回
boolean

waitForDeviceNotAvailable

public boolean waitForDeviceNotAvailable (long waitTime)

参数
waitTime long

返回
boolean

waitForDeviceOnline

public IDevice waitForDeviceOnline ()

返回
IDevice

waitForDeviceOnline

public IDevice waitForDeviceOnline (long waitTime)

参数
waitTime long

返回
IDevice

waitForDeviceShell

public boolean waitForDeviceShell (long waitTime)

参数
waitTime long

返回
boolean

受保护的方法

createOutputReceiver

protected CollectingOutputReceiver createOutputReceiver ()

可供测试

返回
CollectingOutputReceiver CollectingOutputReceiver

getCheckPollTime

protected long getCheckPollTime ()

公开以供测试

返回
long

获取当前时间

protected long getCurrentTime ()

公开以供测试

返回
long

getIDevice

protected IDevice getIDevice ()

返回
IDevice IDevice 与状态监视器相关联

postOnlineCheck

protected boolean postOnlineCheck (long waitTime)

对在线设备执行的其他检查

参数
waitTime long:放弃前等待的时间(毫秒)

返回
boolean 如果检查在 waitTime 过期之前成功完成,则返回 true。否则返回 false

waitForStoreMount

protected boolean waitForStoreMount (long waitTime)

等待挂载设备的外部存储空间。

参数
waitTime long:放弃前等待的时间(毫秒)

返回
boolean 如果在等待时间到期之前装载外部存储空间,则为 true。否则返回 false