BackupActionInputKeys


object 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

const String

File name of the SQLite database.

const String

Expected content during verification of preference or file storage.

const String

Name of the column whose content is verified.

const String

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

const String

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

const String

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

const String

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

const String

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

const String

Value of KEY_COL identifying the row to verify.

const String

Location of the file to write or read.

const String

Key within the android.content.SharedPreferences file.

const String

Name of the android.content.SharedPreferences file.

const String

Storage medium the action operates on.

const String

Table name inside the SQLite database.

const String

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

const String

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

const String

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

Constants

DB_NAME

Added in 1.0.0-alpha02
const val DB_NAME: String

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

EXPECTED

Added in 1.0.0-alpha02
const val EXPECTED: String

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
const val EXPECTED_COL: String

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

EXPECTED_VAL

Added in 1.0.0-alpha02
const val EXPECTED_VAL: String

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
const val EXPECT_NULL: String

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
const val IS_BINARY: String

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
const val IS_DEVICE_PROTECTED: String

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
const val KEY_COL: String

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

KEY_VAL

Added in 1.0.0-alpha02
const val KEY_VAL: String

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

PATH

Added in 1.0.0-alpha02
const val PATH: String

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
const val PREF_KEY: String

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

PREF_NAME

Added in 1.0.0-alpha02
const val PREF_NAME: String

Name of the android.content.SharedPreferences file.

Defaults to BackupActionValues.DEFAULT_PREF_NAME when absent.

STORAGE_TYPE

Added in 1.0.0-alpha02
const val STORAGE_TYPE: String

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
const val TABLE: String

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

VALUE

Added in 1.0.0-alpha02
const val VALUE: String

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
const val VALUES: String

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
const val VALUE_TYPE: String

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.