IDeviceStateMonitor

public interface IDeviceStateMonitor

com.android.tradefed.device.IDeviceStateMonitor
Known Indirect Subclasses
DeviceStateMonitor Helper class for monitoring the state of a IDevice
NativeDeviceStateMonitor Helper class for monitoring the state of a IDevice with no framework support. 


Provides facilities for monitoring the state of a IDevice.

Summary

Public methods

abstract TestDeviceState getDeviceState()

Gets the device state.

abstract String getMountPoint(String mountName)

Returns a mount point.

abstract String getSerialNumber()

Gets the serial number of the device.

abstract boolean isAdbTcp()
abstract void setDefaultAvailableTimeout(long timeoutMs)

Set the time in ms to wait for a device to be available in waitForDeviceAvailable().

abstract void setDefaultOnlineTimeout(long timeoutMs)

Set the time in ms to wait for a device to be online in waitForDeviceOnline().

abstract void setIDevice(IDevice device)

Updates the current IDevice.

abstract void setState(TestDeviceState deviceState)

Sets the device current state.

abstract boolean waitForBootComplete(long waitTime)

Blocks until the device's boot complete flag is set

abstract IDevice waitForDeviceAvailable()

Waits for the device to be responsive and available for testing.

abstract IDevice waitForDeviceAvailable(long waitTime)

Waits for the device to be responsive and available for testing.

abstract boolean waitForDeviceBootloader(long waitTime)

Waits for the device to be in bootloader.

abstract void waitForDeviceBootloaderStateUpdate()

Waits for device bootloader state to be refreshed

abstract boolean waitForDeviceInRecovery(long waitTime)

Waits for the device to be in the 'adb recovery' state

abstract boolean waitForDeviceNotAvailable(long waitTime)

Waits for the device to be not available

abstract IDevice waitForDeviceOnline()

Waits for device to be online using standard boot timeout.

abstract IDevice waitForDeviceOnline(long time)

Waits for device to be online.

abstract boolean waitForDeviceShell(long waitTime)

Waits for device to be responsive to a basic adb shell command.

Public methods

getDeviceState

TestDeviceState getDeviceState ()

Gets the device state.

Returns
TestDeviceState the TestDeviceState of device

getMountPoint

String getMountPoint (String mountName)

Returns a mount point.

Queries the device directly if the cached info in IDevice is not available.

TODO: move this behavior to getMountPoint(String)

Parameters
mountName String: the name of the mount point
Returns
String the mount point or null

getSerialNumber

String getSerialNumber ()

Gets the serial number of the device.

Returns
String

isAdbTcp

boolean isAdbTcp ()

Returns
boolean true if device is connected to adb via tcp

setDefaultAvailableTimeout

void setDefaultAvailableTimeout (long timeoutMs)

Set the time in ms to wait for a device to be available in waitForDeviceAvailable().

Parameters
timeoutMs long

setDefaultOnlineTimeout

void setDefaultOnlineTimeout (long timeoutMs)

Set the time in ms to wait for a device to be online in waitForDeviceOnline().

Parameters
timeoutMs long

setIDevice

void setIDevice (IDevice device)

Updates the current IDevice.

setState

void setState (TestDeviceState deviceState)

Sets the device current state.

waitForBootComplete

boolean waitForBootComplete (long waitTime)

Blocks until the device's boot complete flag is set

Parameters
waitTime long: the amount in ms to wait
Returns
boolean

waitForDeviceAvailable

IDevice waitForDeviceAvailable ()

Waits for the device to be responsive and available for testing.

Equivalent to waitForDeviceAvailable(long), but uses default device boot timeout.

Returns
IDevice the IDevice if device becomes online before time expires. null otherwise.

waitForDeviceAvailable

IDevice waitForDeviceAvailable (long waitTime)

Waits for the device to be responsive and available for testing. Currently this means that the package manager and external storage are available.

Parameters
waitTime long: the time in ms to wait
Returns
IDevice the IDevice if device becomes online before time expires. null otherwise.

waitForDeviceBootloader

boolean waitForDeviceBootloader (long waitTime)

Waits for the device to be in bootloader.

Parameters
waitTime long: the maximum time in ms to wait
Returns
boolean true if device is in bootloader before time expires

waitForDeviceBootloaderStateUpdate

void waitForDeviceBootloaderStateUpdate ()

Waits for device bootloader state to be refreshed

waitForDeviceInRecovery

boolean waitForDeviceInRecovery (long waitTime)

Waits for the device to be in the 'adb recovery' state

Parameters
waitTime long: the maximum time in ms to wait
Returns
boolean True if the device is in Recovery before the timeout, False otherwise.

waitForDeviceNotAvailable

boolean waitForDeviceNotAvailable (long waitTime)

Waits for the device to be not available

Parameters
waitTime long: the maximum time in ms to wait
Returns
boolean true if device becomes unavailable

waitForDeviceOnline

IDevice waitForDeviceOnline ()

Waits for device to be online using standard boot timeout.

Note: this method will return once device is visible via DDMS. It does not guarantee that the device is actually responsive to adb commands - use waitForDeviceAvailable() instead.

Returns
IDevice the IDevice if device becomes online before time expires. null otherwise.

waitForDeviceOnline

IDevice waitForDeviceOnline (long time)

Waits for device to be online.

Note: this method will return once device is visible via DDMS. It does not guarantee that the device is actually responsive to adb commands - use waitForDeviceAvailable() instead.

Parameters
time long: the maximum time in ms to wait
Returns
IDevice the IDevice if device becomes online before time expires. null otherwise.

waitForDeviceShell

boolean waitForDeviceShell (long waitTime)

Waits for device to be responsive to a basic adb shell command.

Parameters
waitTime long: the time in ms to wait
Returns
boolean true if device becomes responsive before waitTime elapses.