{% setvar book_path %}/android/reference/kotlin/_book.yaml{% endsetvar %} {% 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/_kotlin_switcher2.md" %}

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


The interface for clients to access Block Store.

Summary

Constants

const 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.

const Int

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

const Int
MAX_SIZE = 4096

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

Public functions

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.

Task<Boolean!>!

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

Task<ByteArray<Byte>!>!

This function is deprecated.

Use retrieveBytes instead.

Task<RetrieveBytesResponse!>!
retrieveBytes(retrieveBytesRequest: RetrieveBytesRequest!)

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

Task<Int!>!
@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 functions

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

Constants

DEFAULT_BYTES_DATA_KEY

const val DEFAULT_BYTES_DATA_KEY = "com.google.android.gms.auth.blockstore.DEFAULT_BYTES_DATA_KEY": String!

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

MAX_ENTRY_COUNT

const val MAX_ENTRY_COUNT = 16: Int

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

const val MAX_SIZE = 4096: Int

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

Public functions

deleteBytes

fun deleteBytes(deleteBytesRequest: DeleteBytesRequest!): Task<Boolean!>!

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

fun isEndToEndEncryptionAvailable(): Task<Boolean!>!

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

fun retrieveBytes(): Task<ByteArray<Byte>!>!

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

fun retrieveBytes(retrieveBytesRequest: RetrieveBytesRequest!): Task<RetrieveBytesResponse!>!

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)
fun storeBytes(storeBytesData: StoreBytesData!): Task<Int!>!

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.