{% include "/android/_dackka-meta-tags.html" %}

BlockstoreClient

{% setvar page_path %}com/google/android/gms/auth/blockstore/BlockstoreClient.html{% endsetvar %} {% setvar doc_root_path %}/android/reference{% endsetvar %} {% setvar can_switch %}1{% endsetvar %} {% include "android/_java_switcher2.md" %}

@DoNotMock(value = "Use canonical fakes instead. go/cheezhead-testing-methodology")
public interface BlockstoreClient extends HasApiKey


The interface for clients to access Block Store.

Summary

Constants

default static final String
DEFAULT_BYTES_DATA_KEY = "com.google.android.gms.auth.blockstore.DEFAULT_BYTES_DATA_KEY"

The default key with which the bytes are associated when storeBytes is called without explicitly setting a key.

default static final int

Maximum number of distinct data entries, differentiated by the data keys, that can be stored using BlockstoreClient#storeBytes.

default static final int
MAX_SIZE = 4096

Maximum allowed size of byte blobs that can be stored using BlockstoreClient#storeBytes.

Public methods

abstract Task<Boolean>
deleteBytes(DeleteBytesRequest deleteBytesRequest)

Returns a Task which asynchronously deletes the bytes matching the filter(s) specified in deleteBytesRequest, with a Boolean result representing whether any bytes were actually deleted.

abstract Task<Boolean>

Returns a Task which asynchronously determines whether Block Store data backed up to the cloud will be end-to-end encrypted.

abstract Task<byte[]>

This method is deprecated.

Use retrieveBytes instead.

abstract Task<RetrieveBytesResponse>
retrieveBytes(RetrieveBytesRequest retrieveBytesRequest)

Returns a Task which asynchronously retrieves the previously-stored bytes, if any, matching the filter(s) specified in retrieveBytesRequest.

abstract Task<Integer>
@DataCollectionPurpose(dataTypes = [SemanticType.ST_PERSONAL_DATA], collectionPurposes = [CollectionPurpose.CP_APP_FUNCTIONALITY], required = false)
storeBytes(StoreBytesData storeBytesData)

Returns a Task which asynchronously stores the provided byte[] bytes and associates it with the provided String key.

Inherited methods

From com.google.android.gms.common.api.HasApiKey
abstract ApiKey<O>

Constants

DEFAULT_BYTES_DATA_KEY

default static final String DEFAULT_BYTES_DATA_KEY = "com.google.android.gms.auth.blockstore.DEFAULT_BYTES_DATA_KEY"

The default key with which the bytes are associated when storeBytes is called without explicitly setting a key.

MAX_ENTRY_COUNT

default static final int MAX_ENTRY_COUNT = 16

Maximum number of distinct data entries, differentiated by the data keys, that can be stored using BlockstoreClient#storeBytes.

The data key is the value provided when storing the data via storeBytes, as StoreBytesData.key.

MAX_SIZE

default static final int MAX_SIZE = 4096

Maximum allowed size of byte blobs that can be stored using BlockstoreClient#storeBytes.

Public methods

deleteBytes

abstract Task<BooleandeleteBytes(DeleteBytesRequest deleteBytesRequest)

Returns a Task which asynchronously deletes the bytes matching the filter(s) specified in deleteBytesRequest, with a Boolean result representing whether any bytes were actually deleted.

If no bytes were found to delete, the task succeeds with a false return value.

Throws
java.lang.NullPointerException

if deleteBytesRequest is null.

isEndToEndEncryptionAvailable

abstract Task<BooleanisEndToEndEncryptionAvailable()

Returns a Task which asynchronously determines whether Block Store data backed up to the cloud will be end-to-end encrypted.

End-to-end encryption is available for Pie and above devices with a lockscreen PIN/pattern.

The Boolean return value is whether Block Store data backed up to the cloud will be end-to-end encrypted.

retrieveBytes

abstract Task<byte[]> retrieveBytes()

Returns a Task which asynchronously retrieves the previously-stored bytes that was stored without an explicitly specified StoreBytesData.key, if any. The maximum size of the byte[] is the MAX_SIZE.

The byte[] may have been written on the same device or may have been transferred during the device setup.

Use this API to seamlessly sign-in users to your app on a new device.

If no data is found, returns an empty byte array. Note that the data may be cleared by Google Play services on certain user actions (for example, if a user clears their app storage).

retrieveBytes

abstract Task<RetrieveBytesResponseretrieveBytes(RetrieveBytesRequest retrieveBytesRequest)

Returns a Task which asynchronously retrieves the previously-stored bytes, if any, matching the filter(s) specified in retrieveBytesRequest.

The returned RetrieveBytesResponse contains a map from data keys to BlockstoreData. The data may have been written on the same device or may have been transferred during the device setup.

Use this API to seamlessly sign-in users to your app on a new device.

If no data is found, returns an empty data map. Note that the data may be cleared by Google Play services on certain user actions (for example, if a user clears their app storage).

The bytes stored without an explicitly specified StoreBytesData.key can be requested with, and is returned associated with, the default key DEFAULT_BYTES_DATA_KEY.

Throws
java.lang.NullPointerException

if retrieveBytesRequest is null.

storeBytes

@DataCollectionPurpose(dataTypes = [SemanticType.ST_PERSONAL_DATA], collectionPurposes = [CollectionPurpose.CP_APP_FUNCTIONALITY], required = false)
abstract Task<IntegerstoreBytes(StoreBytesData storeBytesData)

Returns a Task which asynchronously stores the provided byte[] bytes and associates it with the provided String key.

If the key is not explicitly set, then the bytes will be associated with the default key DEFAULT_BYTES_DATA_KEY.

The data is stored locally. It is transferred to a new device during the device-to-device restore if a google account is also transferred.

If in shouldBackupToCloud is set to true, the data will also be backed up to the cloud in the next periodic sync. Cloud backup data is transferred to a new device during the cloud restore using Google's Backup &Restore services.

The maximum size of String key and byte[] bytes combined is MAX_SIZE; otherwise, the API fails with MAX_SIZE_EXCEEDED error code.

The maximum number of data entries allowed is MAX_ENTRY_COUNT; otherwise, the API fails with TOO_MANY_ENTRIES error code.

The Integer return value is the size of byte[] bytes successfully stored.

Use this API to store small data blobs that can enable seamless sign in for your apps. The API may be called periodically (for example, a few times per day) to refresh the data blob. Successive calls with the same key to this API will overwrite the existing bytes.