BackgroundDeviceAction

public class BackgroundDeviceAction
extends Object

java.lang.Object
   ↳ com.android.tradefed.device.BackgroundDeviceAction


Runs a command on a given device repeating as necessary until the action is canceled.

When the class is run, the command is run on the device in a separate thread and the output is collected in a temporary host file.

This is done so:

  • if device goes permanently offline during a test, the log data is retained.
  • to capture more data than may fit in device's circular log.

Summary

Fields

public static final String BACKGROUND_DEVICE_ACTION

Public constructors

BackgroundDeviceAction(String command, String descriptor, ITestDevice device, IShellOutputReceiver receiver, int startDelay)

Creates a BackgroundDeviceAction

Public methods

void cancel()

Cancels the command.

boolean isCancelled()

If the command is cancelled.

void run()

Repeats the command until canceled.

Protected methods

void waitForDeviceRecovery(String exceptionType)

If device goes offline for any reason, the recovery will be triggered from the main so we just have to block until it recovers or invocation fails for device unavailable.

Fields

BACKGROUND_DEVICE_ACTION

public static final String BACKGROUND_DEVICE_ACTION

Public constructors

BackgroundDeviceAction

public BackgroundDeviceAction (String command, 
                String descriptor, 
                ITestDevice device, 
                IShellOutputReceiver receiver, 
                int startDelay)

Creates a BackgroundDeviceAction

Parameters
command String: the command to run

descriptor String: the description of the command. For logging only.

device ITestDevice: the device to run the command on

receiver IShellOutputReceiver: the receiver for collecting the output of the command

startDelay int: the delay to wait after the device becomes online

Public methods

cancel

public void cancel ()

Cancels the command.

isCancelled

public boolean isCancelled ()

If the command is cancelled.

Returns
boolean

run

public void run ()

Repeats the command until canceled.

Protected methods

waitForDeviceRecovery

protected void waitForDeviceRecovery (String exceptionType)

If device goes offline for any reason, the recovery will be triggered from the main so we just have to block until it recovers or invocation fails for device unavailable.