E2eeContactKeysManager


public final class E2eeContactKeysManager
extends Object

java.lang.Object
   ↳ 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

class E2eeContactKeysManager.E2eeContactKey

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

class E2eeContactKeysManager.E2eeSelfKey

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

Constants

int VERIFICATION_STATE_UNVERIFIED

Unverified state of a contact end to end encrypted key.

int VERIFICATION_STATE_VERIFICATION_FAILED

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

int VERIFICATION_STATE_VERIFIED

Verified state of a contact end to end encrypted key.

Public methods

List<E2eeContactKeysManager.E2eeContactKey> getAllE2eeContactKeys(String lookupKey)

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

List<E2eeContactKeysManager.E2eeSelfKey> getAllE2eeSelfKeys()

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

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

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

E2eeContactKeysManager.E2eeSelfKey getE2eeSelfKey(String deviceId, String accountId)

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

static int getMaxKeySizeBytes()

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

List<E2eeContactKeysManager.E2eeContactKey> getOwnerE2eeContactKeys(String lookupKey)

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

List<E2eeContactKeysManager.E2eeSelfKey> getOwnerE2eeSelfKeys()

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

boolean removeE2eeContactKey(String lookupKey, String deviceId, String accountId)

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

boolean removeE2eeSelfKey(String deviceId, String accountId)

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

boolean updateE2eeContactKeyLocalVerificationState(String lookupKey, String deviceId, String accountId, int localVerificationState)

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

boolean updateE2eeContactKeyRemoteVerificationState(String lookupKey, String deviceId, String accountId, int remoteVerificationState)

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

boolean updateE2eeSelfKeyRemoteVerificationState(String deviceId, String accountId, int remoteVerificationState)

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

void updateOrInsertE2eeContactKey(String lookupKey, String deviceId, String accountId, byte[] keyValue)

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

boolean updateOrInsertE2eeSelfKey(String deviceId, String accountId, byte[] keyValue)

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

Inherited methods

Constants

VERIFICATION_STATE_UNVERIFIED

public static final int VERIFICATION_STATE_UNVERIFIED

Unverified state of a contact end to end encrypted key.

Constant Value: 0 (0x00000000)

VERIFICATION_STATE_VERIFICATION_FAILED

public static final int VERIFICATION_STATE_VERIFICATION_FAILED

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

Constant Value: 1 (0x00000001)

VERIFICATION_STATE_VERIFIED

public static final int VERIFICATION_STATE_VERIFIED

Verified state of a contact end to end encrypted key.

Constant Value: 2 (0x00000002)

Public methods

getAllE2eeContactKeys

public List<E2eeContactKeysManager.E2eeContactKey> getAllE2eeContactKeys (String lookupKey)

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 Manifest.permission.READ_CONTACTS

Parameters
lookupKey String: the value that references the contact This value cannot be null.

Returns
List<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

public List<E2eeContactKeysManager.E2eeSelfKey> getAllE2eeSelfKeys ()

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 Manifest.permission.READ_CONTACTS

Returns
List<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

public E2eeContactKeysManager.E2eeContactKey getE2eeContactKey (String lookupKey, 
                String deviceId, 
                String accountId)

Retrieves an end-to-end encryption contact key entry given the lookup key, device ID, accountId and inferred caller package name.
Requires 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.

Returns
E2eeContactKeysManager.E2eeContactKey a E2eeContactKey object containing the contact key information, or null if no contact key is found.

getE2eeSelfKey

public E2eeContactKeysManager.E2eeSelfKey getE2eeSelfKey (String deviceId, 
                String accountId)

Returns an end-to-end encryption self key entry given the deviceId and the inferred package name of the caller.
Requires 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.

Returns
E2eeContactKeysManager.E2eeSelfKey a E2eeSelfKey object containing the end-to-end encryption self key information, or null if no self key is found.

getMaxKeySizeBytes

public static int getMaxKeySizeBytes ()

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

Returns
int

getOwnerE2eeContactKeys

public List<E2eeContactKeysManager.E2eeContactKey> getOwnerE2eeContactKeys (String lookupKey)

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

Parameters
lookupKey String: the value that references the contact This value cannot be null.

Returns
List<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

public List<E2eeContactKeysManager.E2eeSelfKey> getOwnerE2eeSelfKeys ()

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

Returns
List<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

public boolean removeE2eeContactKey (String lookupKey, 
                String deviceId, 
                String accountId)

Removes an end-to-end encryption contact key entry that belongs to the caller app.
Requires 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.

Returns
boolean true if the entry was removed, false otherwise.

removeE2eeSelfKey

public boolean removeE2eeSelfKey (String deviceId, 
                String accountId)

Removes an end-to-end encryption self key entry given the deviceId and the inferred package name of the caller.
Requires 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.

Returns
boolean true if the entry was removed, false otherwise.

updateE2eeContactKeyLocalVerificationState

public boolean updateE2eeContactKeyLocalVerificationState (String lookupKey, 
                String deviceId, 
                String accountId, 
                int localVerificationState)

Updates an end-to-end encryption contact key entry's local verification state that belongs to the caller app.
Requires 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 VERIFICATION_STATE_UNVERIFIED, VERIFICATION_STATE_VERIFICATION_FAILED, or VERIFICATION_STATE_VERIFIED

Returns
boolean true if the entry was updated, false otherwise.

updateE2eeContactKeyRemoteVerificationState

public boolean updateE2eeContactKeyRemoteVerificationState (String lookupKey, 
                String deviceId, 
                String accountId, 
                int remoteVerificationState)

Updates an end-to-end encryption contact key entry's remote verification state that belongs to the caller app.
Requires 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 VERIFICATION_STATE_UNVERIFIED, VERIFICATION_STATE_VERIFICATION_FAILED, or VERIFICATION_STATE_VERIFIED

Returns
boolean true if the entry was updated, false otherwise.

updateE2eeSelfKeyRemoteVerificationState

public boolean updateE2eeSelfKeyRemoteVerificationState (String deviceId, 
                String accountId, 
                int remoteVerificationState)

Updates an end-to-end encryption self key entry's remote verification state.
Requires 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 VERIFICATION_STATE_UNVERIFIED, VERIFICATION_STATE_VERIFICATION_FAILED, or VERIFICATION_STATE_VERIFIED

Returns
boolean true if the entry was updated, false otherwise.

updateOrInsertE2eeContactKey

public void updateOrInsertE2eeContactKey (String lookupKey, 
                String deviceId, 
                String accountId, 
                byte[] keyValue)

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 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 byte: the raw bytes for the key (max size is getMaxKeySizeBytes() bytes) This value cannot be null.

updateOrInsertE2eeSelfKey

public boolean updateOrInsertE2eeSelfKey (String deviceId, 
                String accountId, 
                byte[] keyValue)

Inserts a new entry into the end-to-end encryption self keys table or updates one if it already exists.
Requires 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 byte: the raw bytes for the key (max size is getMaxKeySizeBytes() bytes) This value cannot be null.

Returns
boolean true if the entry was added or updated, false otherwise.