BackgroundDeviceAction

public class BackgroundDeviceAction
extends Thread

java.lang.Object
   ↳ java.lang.Thread
     ↳ 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

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.

Public constructors

BackgroundDeviceAction

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

void cancel ()

Cancels the command.

isCancelled

boolean isCancelled ()

If the command is cancelled.

Returns
boolean

run

void run ()

Repeats the command until canceled.

Protected methods

waitForDeviceRecovery

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.