to top
public class

WaitDeviceRecovery

extends Object
implements IDeviceRecovery
java.lang.Object
   ↳ com.android.tradefed.device.WaitDeviceRecovery
Known Direct Subclasses

Class Overview

A simple implementation of a IDeviceRecovery that waits for device to be online and respond to simple commands.

Summary

Constants
int BOOTLOADER_POLL_ATTEMPTS The number of attempts to check if device is in bootloader.
long INITIAL_PAUSE_TIME the time in ms to wait before beginning recovery attempts
Fields
protected long mBootloaderWaitTime @Option(name = "bootloader-wait-time", description = "maximum time in ms to wait for device to be in fastboot.")
protected boolean mDisableUnresponsiveReboot @Option(name = "disable-unresponsive-reboot", description = "If this is set, we will not attempt to reboot an unresponsive devicethat is in userspace. Note that this will have no effect if the device is in fastboot or is expected to be in fastboot.")
protected long mFastbootWaitTime @Option(name = "fastboot-wait-time", description = "maximum time in ms to wait for a fastboot command result.")
protected long mOnlineWaitTime @Option(name = "online-wait-time", description = "maximum time in ms to wait for device to come online.")
protected int mRequiredMinBattery @Option(name = "min-battery-after-recovery", description = "require a min battery level after successful recovery, default to 0 for ignoring.")
protected long mShellWaitTime @Option(name = "shell-wait-time", description = "maximum time in ms to wait for device shell to be responsive.")
protected long mWaitTime @Option(name = "device-wait-time", description = "maximum time in ms to wait for a single device recovery command.")
Public Constructors
WaitDeviceRecovery()
Public Methods
void recoverDevice(IDeviceStateMonitor monitor, boolean recoverUntilOnline)
Attempt to recover the given device that can no longer be communicated with.
void recoverDeviceBootloader(IDeviceStateMonitor monitor)
Attempt to recover the given unresponsive device in bootloader mode.
void recoverDeviceRecovery(IDeviceStateMonitor monitor)
Attempt to recover the given unresponsive device in recovery mode.
Protected Methods
void checkMinBatteryLevel(IDevice device)
Checks if device battery level meets min requirement
IRunUtil getRunUtil()
Get the RunUtil instance to use.
void handleDeviceBootloaderNotAvailable(IDeviceStateMonitor monitor)
Handle situation where device is not available when expected to be in bootloader.
void handleDeviceBootloaderUnresponsive(IDeviceStateMonitor monitor)
void handleDeviceNotAvailable(IDeviceStateMonitor monitor, boolean recoverTillOnline)
Handle situation where device is not available.
void handleDeviceOnlineExpectedBootloader(IDeviceStateMonitor monitor)
Handle condition where device is online, but should be in bootloader state.
void handleDeviceUnresponsive(IDevice device, IDeviceStateMonitor monitor)
Handle situation where device is online but unresponsive.
void rebootDevice(IDevice device)
Reboot device into bootloader.
void rebootDeviceIntoBootloader(IDevice device)
Reboot device into bootloader.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.tradefed.device.IDeviceRecovery

Constants

public static final int BOOTLOADER_POLL_ATTEMPTS

The number of attempts to check if device is in bootloader.

Exposed for unit testing

Constant Value: 3 (0x00000003)

protected static final long INITIAL_PAUSE_TIME

the time in ms to wait before beginning recovery attempts

Constant Value: 5000 (0x0000000000001388)

Fields

protected long mBootloaderWaitTime

protected boolean mDisableUnresponsiveReboot

protected long mFastbootWaitTime

protected long mOnlineWaitTime

protected int mRequiredMinBattery

protected long mShellWaitTime

protected long mWaitTime

Public Constructors

public WaitDeviceRecovery ()

Public Methods

public void recoverDevice (IDeviceStateMonitor monitor, boolean recoverUntilOnline)

Attempt to recover the given device that can no longer be communicated with.

Method should block and only return when device is in requested state.

Parameters
monitor IDeviceStateMonitor: the IDeviceStateMonitor to use.
recoverUntilOnline boolean: if true, method should return as soon as device is online on adb. If false, method should block until device is fully available for testing (ie waitForDeviceAvailable() succeeds.
Throws
DeviceNotAvailableException

public void recoverDeviceBootloader (IDeviceStateMonitor monitor)

Attempt to recover the given unresponsive device in bootloader mode.

Parameters
monitor IDeviceStateMonitor: the IDeviceStateMonitor to use.
Throws
DeviceNotAvailableException

public void recoverDeviceRecovery (IDeviceStateMonitor monitor)

Attempt to recover the given unresponsive device in recovery mode.

Parameters
monitor IDeviceStateMonitor: the IDeviceStateMonitor to use.
Throws
DeviceNotAvailableException

Protected Methods

protected void checkMinBatteryLevel (IDevice device)

Checks if device battery level meets min requirement

Throws
DeviceNotAvailableException if battery level cannot be read or lower than min

protected IRunUtil getRunUtil ()

Get the RunUtil instance to use.

Exposed for unit testing.

Returns
IRunUtil

protected void handleDeviceBootloaderNotAvailable (IDeviceStateMonitor monitor)

Handle situation where device is not available when expected to be in bootloader.

Parameters
monitor IDeviceStateMonitor: the IDeviceStateMonitor
Throws
DeviceNotAvailableException

protected void handleDeviceBootloaderUnresponsive (IDeviceStateMonitor monitor)

protected void handleDeviceNotAvailable (IDeviceStateMonitor monitor, boolean recoverTillOnline)

Handle situation where device is not available.

Parameters
monitor IDeviceStateMonitor: the IDeviceStateMonitor
recoverTillOnline boolean: if true this method should return if device is online, and not check for responsiveness
Throws
DeviceNotAvailableException

protected void handleDeviceOnlineExpectedBootloader (IDeviceStateMonitor monitor)

Handle condition where device is online, but should be in bootloader state.

If this method

Throws
DeviceNotAvailableException

protected void handleDeviceUnresponsive (IDevice device, IDeviceStateMonitor monitor)

Handle situation where device is online but unresponsive.

Parameters
device IDevice
Throws
DeviceNotAvailableException

protected void rebootDevice (IDevice device)

Reboot device into bootloader.

Parameters
device IDevice: the IDevice to reboot.

protected void rebootDeviceIntoBootloader (IDevice device)

Reboot device into bootloader.

Parameters
device IDevice: the IDevice to reboot.