public interface

IDeviceStateMonitor

com.android.tradefed.device.IDeviceStateMonitor

Class Overview

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 IDevice waitForDeviceAvailable(long waitTime)
Waits for the device to be responsive and available for testing.
abstract IDevice waitForDeviceAvailable()
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

public abstract TestDeviceState getDeviceState ()

Gets the device state.

Returns

public abstract 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 the name of the mount point
Returns
  • the mount point or null

public abstract String getSerialNumber ()

Gets the serial number of the device.

public abstract boolean isAdbTcp ()

Returns
  • true if device is connected to adb via tcp

public abstract void setDefaultAvailableTimeout (long timeoutMs)

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

public abstract void setDefaultOnlineTimeout (long timeoutMs)

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

public abstract void setIDevice (IDevice device)

public abstract void setState (TestDeviceState deviceState)

Sets the device current state.

public abstract 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 the time in ms to wait
Returns
  • the IDevice if device becomes online before time expires. null otherwise.

public abstract IDevice waitForDeviceAvailable ()

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

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

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

public abstract boolean waitForDeviceBootloader (long waitTime)

Waits for the device to be in bootloader.

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

public abstract void waitForDeviceBootloaderStateUpdate ()

Waits for device bootloader state to be refreshed

public abstract boolean waitForDeviceInRecovery (long waitTime)

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

Parameters
waitTime the maximum time in ms to wait

public abstract boolean waitForDeviceNotAvailable (long waitTime)

Waits for the device to be not available

Parameters
waitTime the maximum time in ms to wait
Returns
  • true if device becomes unavailable

public abstract 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
  • the IDevice if device becomes online before time expires. null otherwise.

public abstract 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 the maximum time in ms to wait
Returns
  • the IDevice if device becomes online before time expires. null otherwise.

public abstract boolean waitForDeviceShell (long waitTime)

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

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