AssertStorageAction


public final class AssertStorageAction implements BackupDeviceAction


Asserts the correctness of restored test data.

Parses the configuration from BackupDeviceActionArgs and verifies android.content.SharedPreferences, Preferences DataStores, SQLite databases, or raw file contents in credential-encrypted or device-protected storage. See androidx.test.backup.BackupActionInputKeys for the keys each storage type consumes. With androidx.test.backup.BackupActionInputKeys.EXPECT_NULL, it verifies that the data is absent.

A mismatch is reported as BackupDeviceActionResult.failure carrying the expected and the actual value, not as a thrown exception. Long values are shortened to the part where they differ.

Summary

Public constructors

Public methods

@NonNull BackupDeviceActionResult

Runs the action payload.

Public constructors

AssertStorageAction

Added in 1.0.0-alpha04
public AssertStorageAction()

Public methods

execute

public @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