Added in API level 35

E2eeContactKeysManager


class E2eeContactKeysManager
kotlin.Any
   ↳ android.provider.E2eeContactKeysManager

E2eeContactKeysManager provides access to the provider of end-to-end encryption contact keys. It manages two types of keys - E2eeContactKey and E2eeSelfKey.

  • A E2eeContactKey is a public key associated with a contact. It's used to end-to-end encrypt the communications between a user and the contact. This API allows operations on E2eeContactKeys to insert/update, remove, change the verification state, and retrieving keys (either created by or visible to the caller app).
  • A E2eeSelfKey is a key for this device, so the key represents the owner of the device. This API allows operations on E2eeSelfKeys to insert/update, remove, and retrieving self keys (either created by or visible to the caller app).
Keys are uniquely identified by:
  • ownerPackageName - package name of an app that the key belongs to.
  • deviceId - an app-specified identifier for the device, defined by the app. Within that app, the deviceID should be unique among devices belonging to that user.
  • accountId - the app-specified identifier for the account for which the contact key can be used. Using different account IDs allows for multiple key entries representing the same user. For most apps this would be a phone number.
Contact keys also use lookupKey which is an opaque value used to identify a contact in ContactsProvider.

Summary

Nested classes

A parcelable class encapsulating other users' end to end encrypted contact key.

A parcelable class encapsulating self end to end encrypted contact key.

Constants
static Int

Unverified state of a contact end to end encrypted key.

static Int

Failed verification state of a contact end to end encrypted key.

static Int

Verified state of a contact end to end encrypted key.

Public methods
MutableList<E2eeContactKeysManager.E2eeContactKey!>

Retrieves all end-to-end encryption contact key entries that belong to apps visible to the caller.

MutableList<E2eeContactKeysManager.E2eeSelfKey!>

Returns all end-to-end encryption self key entries that belong to apps visible to the caller.

E2eeContactKeysManager.E2eeContactKey?
getE2eeContactKey(lookupKey: String, deviceId: String, accountId: String)

Retrieves an end-to-end encryption contact key entry given the lookup key, device ID, accountId and inferred caller package name.

E2eeContactKeysManager.E2eeSelfKey?
getE2eeSelfKey(deviceId: String, accountId: String)

Returns an end-to-end encryption self key entry given the deviceId and the inferred package name of the caller.

static Int

Maximum size of an end-to-end encryption contact key.

MutableList<E2eeContactKeysManager.E2eeContactKey!>

Retrieves all end-to-end encryption contact key entries for a given lookupKey that belong to the caller app.

MutableList<E2eeContactKeysManager.E2eeSelfKey!>

Returns all end-to-end encryption self key entries that are owned by the caller app.

Boolean
removeE2eeContactKey(lookupKey: String, deviceId: String, accountId: String)

Removes an end-to-end encryption contact key entry that belongs to the caller app.

Boolean
removeE2eeSelfKey(deviceId: String, accountId: String)

Removes an end-to-end encryption self key entry given the deviceId and the inferred package name of the caller.

Boolean
updateE2eeContactKeyLocalVerificationState(lookupKey: String, deviceId: String, accountId: String, localVerificationState: Int)

Updates an end-to-end encryption contact key entry's local verification state that belongs to the caller app.

Boolean
updateE2eeContactKeyRemoteVerificationState(lookupKey: String, deviceId: String, accountId: String, remoteVerificationState: Int)

Updates an end-to-end encryption contact key entry's remote verification state that belongs to the caller app.

Boolean
updateE2eeSelfKeyRemoteVerificationState(deviceId: String, accountId: String, remoteVerificationState: Int)

Updates an end-to-end encryption self key entry's remote verification state.

Unit
updateOrInsertE2eeContactKey(lookupKey: String, deviceId: String, accountId: String, keyValue: ByteArray)

Inserts a new entry into the end-to-end encryption contact keys table or updates one if it already exists.

Boolean
updateOrInsertE2eeSelfKey(deviceId: String, accountId: String, keyValue: ByteArray)

Inserts a new entry into the end-to-end encryption self keys table or updates one if it already exists.

Constants

VERIFICATION_STATE_UNVERIFIED

Added in API level 35
static val VERIFICATION_STATE_UNVERIFIED: Int

Unverified state of a contact end to end encrypted key.

Value: 0

VERIFICATION_STATE_VERIFICATION_FAILED

Added in API level 35
static val VERIFICATION_STATE_VERIFICATION_FAILED: Int

Failed verification state of a contact end to end encrypted key.

Value: 1

VERIFICATION_STATE_VERIFIED

Added in API level 35
static val VERIFICATION_STATE_VERIFIED: Int

Verified state of a contact end to end encrypted key.

Value: 2

Public methods

getAllE2eeContactKeys

Added in API level 35
fun getAllE2eeContactKeys(lookupKey: String): MutableList<E2eeContactKeysManager.E2eeContactKey!>

Retrieves all end-to-end encryption contact key entries that belong to apps visible to the caller. The keys will be stripped of deviceId, timeUpdated and keyValue data.
Requires android.Manifest.permission#READ_CONTACTS

Parameters
lookupKey String: the value that references the contact This value cannot be null.
Return
MutableList<E2eeContactKeysManager.E2eeContactKey!> a list of E2eeContactKey objects containing the contact key information, or an empty list if no keys are found. This value cannot be null.

getAllE2eeSelfKeys

Added in API level 35
fun getAllE2eeSelfKeys(): MutableList<E2eeContactKeysManager.E2eeSelfKey!>

Returns all end-to-end encryption self key entries that belong to apps visible to the caller. The keys will be stripped of deviceId, timeUpdated and keyValue data.
Requires android.Manifest.permission#READ_CONTACTS

Return
MutableList<E2eeContactKeysManager.E2eeSelfKey!> a list of E2eeSelfKey objects containing the end-to-end encryption self key information, or an empty list if no self keys are found. This value cannot be null.

getE2eeContactKey

Added in API level 35
fun getE2eeContactKey(
    lookupKey: String,
    deviceId: String,
    accountId: String
): E2eeContactKeysManager.E2eeContactKey?

Retrieves an end-to-end encryption contact key entry given the lookup key, device ID, accountId and inferred caller package name.
Requires android.Manifest.permission#READ_CONTACTS

Parameters
lookupKey String: the value that references the contact This value cannot be null.
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
Return
E2eeContactKeysManager.E2eeContactKey? a E2eeContactKey object containing the contact key information, or null if no contact key is found.

getE2eeSelfKey

Added in API level 35
fun getE2eeSelfKey(
    deviceId: String,
    accountId: String
): E2eeContactKeysManager.E2eeSelfKey?

Returns an end-to-end encryption self key entry given the deviceId and the inferred package name of the caller.
Requires android.Manifest.permission#READ_CONTACTS

Parameters
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
Return
E2eeContactKeysManager.E2eeSelfKey? a E2eeSelfKey object containing the end-to-end encryption self key information, or null if no self key is found.

getMaxKeySizeBytes

Added in API level 35
static fun getMaxKeySizeBytes(): Int

Maximum size of an end-to-end encryption contact key.

getOwnerE2eeContactKeys

Added in API level 35
fun getOwnerE2eeContactKeys(lookupKey: String): MutableList<E2eeContactKeysManager.E2eeContactKey!>

Retrieves all end-to-end encryption contact key entries for a given lookupKey that belong to the caller app.
Requires android.Manifest.permission#READ_CONTACTS

Parameters
lookupKey String: the value that references the contact This value cannot be null.
Return
MutableList<E2eeContactKeysManager.E2eeContactKey!> a list of E2eeContactKey objects containing the end-to-end encryption contact key information, or an empty list if no keys are found. This value cannot be null.

getOwnerE2eeSelfKeys

Added in API level 35
fun getOwnerE2eeSelfKeys(): MutableList<E2eeContactKeysManager.E2eeSelfKey!>

Returns all end-to-end encryption self key entries that are owned by the caller app.
Requires android.Manifest.permission#READ_CONTACTS

Return
MutableList<E2eeContactKeysManager.E2eeSelfKey!> a list of E2eeSelfKey objects containing the end-to-end encryption self key information, or an empty list if no self keys are found. This value cannot be null.

removeE2eeContactKey

Added in API level 35
fun removeE2eeContactKey(
    lookupKey: String,
    deviceId: String,
    accountId: String
): Boolean

Removes an end-to-end encryption contact key entry that belongs to the caller app.
Requires android.Manifest.permission#WRITE_CONTACTS

Parameters
lookupKey String: the value that references the contact This value cannot be null.
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
Return
Boolean true if the entry was removed, false otherwise.

removeE2eeSelfKey

Added in API level 35
fun removeE2eeSelfKey(
    deviceId: String,
    accountId: String
): Boolean

Removes an end-to-end encryption self key entry given the deviceId and the inferred package name of the caller.
Requires android.Manifest.permission#WRITE_CONTACTS

Parameters
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
Return
Boolean true if the entry was removed, false otherwise.

updateE2eeContactKeyLocalVerificationState

Added in API level 35
fun updateE2eeContactKeyLocalVerificationState(
    lookupKey: String,
    deviceId: String,
    accountId: String,
    localVerificationState: Int
): Boolean

Updates an end-to-end encryption contact key entry's local verification state that belongs to the caller app.
Requires android.Manifest.permission#WRITE_CONTACTS

Parameters
lookupKey String: the value that references the contact This value cannot be null.
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
localVerificationState Int: the new local verification state Value is android.provider.E2eeContactKeysManager#VERIFICATION_STATE_UNVERIFIED, android.provider.E2eeContactKeysManager#VERIFICATION_STATE_VERIFICATION_FAILED, or android.provider.E2eeContactKeysManager#VERIFICATION_STATE_VERIFIED
Return
Boolean true if the entry was updated, false otherwise.

updateE2eeContactKeyRemoteVerificationState

Added in API level 35
fun updateE2eeContactKeyRemoteVerificationState(
    lookupKey: String,
    deviceId: String,
    accountId: String,
    remoteVerificationState: Int
): Boolean

Updates an end-to-end encryption contact key entry's remote verification state that belongs to the caller app.
Requires android.Manifest.permission#WRITE_CONTACTS

Parameters
lookupKey String: the value that references the contact This value cannot be null.
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
remoteVerificationState Int: the new remote verification state Value is android.provider.E2eeContactKeysManager#VERIFICATION_STATE_UNVERIFIED, android.provider.E2eeContactKeysManager#VERIFICATION_STATE_VERIFICATION_FAILED, or android.provider.E2eeContactKeysManager#VERIFICATION_STATE_VERIFIED
Return
Boolean true if the entry was updated, false otherwise.

updateE2eeSelfKeyRemoteVerificationState

Added in API level 35
fun updateE2eeSelfKeyRemoteVerificationState(
    deviceId: String,
    accountId: String,
    remoteVerificationState: Int
): Boolean

Updates an end-to-end encryption self key entry's remote verification state.
Requires android.Manifest.permission#WRITE_CONTACTS

Parameters
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
remoteVerificationState Int: the new remote verification state Value is android.provider.E2eeContactKeysManager#VERIFICATION_STATE_UNVERIFIED, android.provider.E2eeContactKeysManager#VERIFICATION_STATE_VERIFICATION_FAILED, or android.provider.E2eeContactKeysManager#VERIFICATION_STATE_VERIFIED
Return
Boolean true if the entry was updated, false otherwise.

updateOrInsertE2eeContactKey

Added in API level 35
fun updateOrInsertE2eeContactKey(
    lookupKey: String,
    deviceId: String,
    accountId: String,
    keyValue: ByteArray
): Unit

Inserts a new entry into the end-to-end encryption contact keys table or updates one if it already exists. The inserted/updated end-to-end encryption contact key is owned by the caller app.
Requires android.Manifest.permission#WRITE_CONTACTS

Parameters
lookupKey String: value that references the contact This value cannot be null.
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
keyValue ByteArray: the raw bytes for the key (max size is getMaxKeySizeBytes bytes) This value cannot be null.

updateOrInsertE2eeSelfKey

Added in API level 35
fun updateOrInsertE2eeSelfKey(
    deviceId: String,
    accountId: String,
    keyValue: ByteArray
): Boolean

Inserts a new entry into the end-to-end encryption self keys table or updates one if it already exists.
Requires android.Manifest.permission#WRITE_CONTACTS

Parameters
deviceId String: an app-specified identifier for the device This value cannot be null.
accountId String: an app-specified identifier for the account This value cannot be null.
keyValue ByteArray: the raw bytes for the key (max size is getMaxKeySizeBytes bytes) This value cannot be null.
Return
Boolean true if the entry was added or updated, false otherwise.