BackupActionInputKeys


public static class BackupActionInputKeys


Keys accepted in BackupDeviceActionArgs.payload by the actions bundled with this library.

Those actions are androidx.test.backup.actions.PopulateStorageAction and androidx.test.backup.actions.AssertStorageAction.

Every value in the payload is a String; non-string data is encoded as described on the individual key. Keys that an action does not recognize are ignored, so a single payload may be reused for both the populate and the verify phase of a flow.

Which keys apply depends on STORAGE_TYPE:

IS_DEVICE_PROTECTED applies to every storage type.

Custom BackupDeviceAction implementations are free to define their own keys; this object only describes the vocabulary understood by the bundled actions. Result keys live in a separate namespace, BackupActionOutputKeys.

Summary

Constants

static final @NonNull String

File name of the SQLite database.

static final @NonNull String

Expected content during verification of preference or file storage.

static final @NonNull String

Name of the column whose content is verified.

static final @NonNull String

Expected content of EXPECTED_COL, as the string form of the column value.

static final @NonNull String

Whether verification should assert that the preference is absent instead of comparing it.

static final @NonNull String

Whether VALUE and EXPECTED carry Base64-encoded binary data rather than text.

static final @NonNull String

Whether to operate on device-protected (direct boot aware) storage.

static final @NonNull String

Name of the column used to locate the row to verify.

static final @NonNull String

Value of KEY_COL identifying the row to verify.

static final @NonNull String

Location of the file to write or read.

static final @NonNull String

Key within the android.content.SharedPreferences file.

static final @NonNull String

Name of the android.content.SharedPreferences file.

static final @NonNull String

Storage medium the action operates on.

static final @NonNull String

Table name inside the SQLite database.

static final @NonNull String

Value to write, and the fallback expected value during verification when EXPECTED is absent.

static final @NonNull String

Column values to insert, as an application/x-www-form-urlencoded string.

static final @NonNull String

Primitive type used to store and read back a preference VALUE.

Public fields

static @NonNull BackupActionInputKeys

Constants

DB_NAME

Added in 1.0.0-alpha02
public static final @NonNull String DB_NAME

File name of the SQLite database. Required for database storage.

EXPECTED

Added in 1.0.0-alpha02
public static final @NonNull String EXPECTED

Expected content during verification of preference or file storage.

Falls back to VALUE when absent, which lets the same payload seed and verify a domain. Database verification uses EXPECTED_COL and EXPECTED_VAL instead.

EXPECTED_COL

Added in 1.0.0-alpha02
public static final @NonNull String EXPECTED_COL

Name of the column whose content is verified. Ignored when VALUES is present.

EXPECTED_VAL

Added in 1.0.0-alpha02
public static final @NonNull String EXPECTED_VAL

Expected content of EXPECTED_COL, as the string form of the column value.

SQLite has no boolean type, so booleans are compared as "true" or "false". Ignored when VALUES is present.

EXPECT_NULL

Added in 1.0.0-alpha02
public static final @NonNull String EXPECT_NULL

Whether verification should assert that the preference is absent instead of comparing it.

Parsed with String.toBoolean. When enabled, EXPECTED and VALUE are not consulted.

IS_BINARY

Added in 1.0.0-alpha02
public static final @NonNull String IS_BINARY

Whether VALUE and EXPECTED carry Base64-encoded binary data rather than text.

Parsed with String.toBoolean. When enabled, the payload is decoded with android.util.Base64.DEFAULT and the file is compared byte for byte.

IS_DEVICE_PROTECTED

Added in 1.0.0-alpha02
public static final @NonNull String IS_DEVICE_PROTECTED

Whether to operate on device-protected (direct boot aware) storage.

Parsed with String.toBoolean, so "true" in any casing enables it and every other value, including an absent key, leaves it disabled. When enabled, the action runs against android.content.Context.createDeviceProtectedStorageContext instead of the default credential-encrypted context.

KEY_COL

Added in 1.0.0-alpha02
public static final @NonNull String KEY_COL

Name of the column used to locate the row to verify. Required for database verification.

KEY_VAL

Added in 1.0.0-alpha02
public static final @NonNull String KEY_VAL

Value of KEY_COL identifying the row to verify. Required for database verification.

PATH

Added in 1.0.0-alpha02
public static final @NonNull String PATH

Location of the file to write or read.

Absolute paths are used verbatim. Relative paths are resolved against android.content.Context.getFilesDir of the context selected by IS_DEVICE_PROTECTED.

PREF_KEY

Added in 1.0.0-alpha02
public static final @NonNull String PREF_KEY

Key within the android.content.SharedPreferences file. Required for preference storage.

PREF_NAME

Added in 1.0.0-alpha02
public static final @NonNull String PREF_NAME

Name of the android.content.SharedPreferences file.

Defaults to BackupActionValues.DEFAULT_PREF_NAME when absent.

STORAGE_TYPE

Added in 1.0.0-alpha02
public static final @NonNull String STORAGE_TYPE

Storage medium the action operates on.

Must be one of BackupActionValues.STORAGE_TYPE_PREFS, BackupActionValues.STORAGE_TYPE_DATABASE or BackupActionValues.STORAGE_TYPE_FILES, matched case-insensitively. Defaults to BackupActionValues.STORAGE_TYPE_PREFS when absent. Any other value fails the action.

TABLE

Added in 1.0.0-alpha02
public static final @NonNull String TABLE

Table name inside the SQLite database. Required for database storage.

VALUE

Added in 1.0.0-alpha02
public static final @NonNull String VALUE

Value to write, and the fallback expected value during verification when EXPECTED is absent.

For preference storage the string is converted according to VALUE_TYPE. For file storage it is the file body, Base64-encoded when IS_BINARY is set.

VALUES

Added in 1.0.0-alpha02
public static final @NonNull String VALUES

Column values to insert, as an application/x-www-form-urlencoded string.

Pairs are separated by & and each pair is name=value, with both the name and the value percent-encoded in UTF-8 exactly as java.net.URLEncoder produces. Encoding is what makes column values containing &, =, % or + round-trip correctly; a literal + decodes back to a space, so it must be encoded as %2B.

For example, the columns name = "a&b" and city = "Rio" are expressed as "name=a%26b&city=Rio". Malformed pairs fail the action rather than being skipped.

During verification this key replaces the EXPECTED_COL / EXPECTED_VAL pair. Every pair it carries is checked against the row, so a restore that corrupts any column of the row fails, and all mismatches are reported together. A malformed value fails the action rather than falling back to EXPECTED_COL and EXPECTED_VAL.

VALUE_TYPE

Added in 1.0.0-alpha02
public static final @NonNull String VALUE_TYPE

Primitive type used to store and read back a preference VALUE.

Must be one of BackupActionValues.VALUE_TYPE_INT, BackupActionValues.VALUE_TYPE_LONG, BackupActionValues.VALUE_TYPE_FLOAT, BackupActionValues.VALUE_TYPE_BOOLEAN or BackupActionValues.VALUE_TYPE_STRING, matched case-insensitively. Defaults to BackupActionValues.VALUE_TYPE_STRING when absent. Any other value fails the action.

Public fields

INSTANCE

Added in 1.0.0-alpha02
public static @NonNull BackupActionInputKeys INSTANCE