BackupDeviceAction


public interface BackupDeviceAction

Known direct subclasses
AssertStorageAction

Asserts the correctness of restored test data.

PopulateStorageAction

Populates test data inside the application sandbox before a backup.


Runs an action inside the application sandbox on the target device.

Implementations must provide a public no-arg constructor to enable dynamic instantiation.

An action reads its configuration from BackupDeviceActionArgs, whose documented keys are listed in BackupActionInputKeys, and reports its outcome through BackupDeviceActionResult, whose documented keys are listed in BackupActionOutputKeys. Build the outcome with BackupDeviceActionResult.success or BackupDeviceActionResult.failure so that the host can tell the two apart.

Summary

Constants

default static final int

The phase of an action that seeds data in the app's storage before a backup.

default static final int

The phase of an action that checks restored data in the app's storage after a restore.

Public methods

abstract @NonNull BackupDeviceActionResult

Runs the action payload.

abstract int

The phase of a backup and restore test in which this action runs: PHASE_POPULATE for an action that seeds data before a backup, or PHASE_VERIFY for an action that checks restored data after a restore.

Constants

PHASE_POPULATE

Added in 1.0.0-alpha03
default static final int PHASE_POPULATE = 1

The phase of an action that seeds data in the app's storage before a backup.

PHASE_VERIFY

Added in 1.0.0-alpha03
default static final int PHASE_VERIFY = 2

The phase of an action that checks restored data in the app's storage after a restore.

Public methods

execute

Added in 1.0.0-alpha03
abstract @NonNull BackupDeviceActionResult execute(@NonNull Context context, @NonNull BackupDeviceActionArgs args)

Runs the action payload.

Implementations should report a recoverable problem, such as a missing argument or a failed assertion, by returning BackupDeviceActionResult.failure rather than by throwing. The host treats a thrown exception as a crash of the action and reports it with a stack trace.

Parameters
@NonNull Context context

application context on the target device

@NonNull BackupDeviceActionArgs args

input arguments passed from the host orchestrator, keyed by BackupActionInputKeys

Returns
@NonNull BackupDeviceActionResult

result returned to the host, keyed by BackupActionOutputKeys

getPhase

Added in 1.0.0-alpha03
abstract int getPhase()

The phase of a backup and restore test in which this action runs: PHASE_POPULATE for an action that seeds data before a backup, or PHASE_VERIFY for an action that checks restored data after a restore.

The phase only describes the action. This library doesn't read it, so it doesn't change when or how the action runs.