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.

To use the instrumentation that runs the action, such as its UiAutomation, get it from androidx.test.platform.app.InstrumentationRegistry.

Summary

Public methods

abstract @NonNull BackupDeviceActionResult

Runs the action payload.

Public methods

execute

Added in 1.0.0-alpha04
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