ContactKeyClient


interface ContactKeyClient : HasApiKey


Contact Key API 的用戶端。

摘要

公開函式

Flow<List<E2eeAccountContactKeyParcelable>>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getAccountContactKeysFlow(accountIds: List<String>)

傳回帳戶聯絡人金鑰更新的流程。

Task<E2eeContactKeyListParcelable>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getAllE2eeContactKeys(lookupKey: String)

擷取屬於呼叫者可見應用程式的所有端對端加密聯絡人金鑰項目。

Task<E2eeSelfKeyListParcelable>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getAllE2eeSelfKeys()

傳回呼叫者可見應用程式的所有端對端加密自我金鑰項目。

Task<ImmutableList<E2eeAccountContactKeyParcelable>>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getAllOwnerE2eeAccountContactKeys()

擷取屬於來電者應用程式的所有端對端加密帳戶聯絡人金鑰,無論是否與聯絡人相關聯。

Task<E2eeContactKeyListParcelable>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getAllOwnerE2eeContactKeys()

擷取所有聯絡人的所有端對端加密聯絡人金鑰,這些金鑰屬於呼叫端應用程式。

Task<ImmutableList<E2eeAccountContactKeyParcelable>>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getE2eeAccountKeysForAccount(accountId: String)

擷取屬於呼叫端應用程式和呼叫端帳戶的所有端對端加密聯絡人金鑰項目 (適用於所有聯絡人)。

Task<E2eeContactKeyParcelable?>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getE2eeContactKey(lookupKey: String, deviceId: String, accountId: String)

根據 lookupKeydeviceIdaccountId 和推斷的呼叫端套件名稱,擷取端對端加密聯絡人金鑰項目。

Task<E2eeSelfKeyParcelable?>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getE2eeSelfKey(deviceId: String, accountId: String)

根據 deviceIdaccountId 和呼叫端的推斷套件名稱,傳回端對端加密自我金鑰項目。

Task<Int>

傳回鍵的大小上限 (以位元組為單位)。

Task<PendingIntent>
getOnboardingIntent(
    nextActivity: OnboardingNextActivity,
    lookupKey: String?,
    packageName: String?
)

傳回顯示 Onboarding 活動的 Intent,並標示這部裝置已顯示 Onboarding。

Task<E2eeContactKeyListParcelable>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getOwnerE2eeContactKeys(lookupKey: String)

擷取屬於呼叫端應用程式的指定 lookupKey 所有端對端加密聯絡人金鑰項目。

Task<E2eeSelfKeyListParcelable>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
getOwnerE2eeSelfKeys()

傳回呼叫端應用程式擁有的所有端對端加密自我金鑰項目。

Task<PendingIntent>
getScanQrCodeIntent(lookupKey: String, skipOnboarding: Boolean)

傳回「掃描 QR code」活動的意圖。

Task<PendingIntent>
getScanQrCodeIntentForAccount(packageName: String, accountId: String)

傳回特定帳戶「掃描 QR code」活動的意圖。

Task<PendingIntent>
getShowQrCodeIntent(packageName: String?, skipOnboarding: Boolean)

傳回「顯示 QR code」活動的 Intent。

Task<Boolean>

無論 API 是否可用,都會傳回成功完成的 Task。

Task<Void>
@RequiresPermission(value = "android.permission.READ_CONTACTS")
registerAccountContactKeysListener(
    accountIds: List<String>,
    listener: OnAccountContactKeysUpdatedListener
)

註冊帳戶聯絡人金鑰更新的監聽器。

Task<Void>
@RequiresPermission(value = "android.permission.WRITE_CONTACTS")
removeE2eeAccountContactKey(deviceId: String, accountId: String)

移除屬於來電者應用程式的端對端加密帳戶聯絡人金鑰項目。

Task<Void>
@RequiresPermission(value = "android.permission.WRITE_CONTACTS")
removeE2eeContactKey(
    lookupKey: String,
    deviceId: String,
    accountId: String
)

移除屬於來電應用程式的端對端加密通訊錄金鑰項目。

Task<Void>
@RequiresPermission(value = "android.permission.WRITE_CONTACTS")
removeE2eeSelfKey(deviceId: String, accountId: String)

根據 deviceId 和呼叫端的推斷套件名稱,移除端對端加密自我金鑰項目。

Task<Boolean>

取消註冊帳戶聯絡人金鑰更新的接聽程式。

Task<Void>
@RequiresPermission(allOf = ["android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"])
updateAllE2eeAccountKeys(accountKeyInfos: List<E2eeAccountKeyInfo>)

插入一批帳戶聯絡人金鑰。

Task<Void>
@RequiresPermission(allOf = ["android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"])
updateOrInsertE2eeContactKey(
    lookupKey: String,
    deviceId: String,
    accountId: String,
    keyValue: ByteArray
)

在端對端加密聯絡人金鑰資料表中插入新項目,或更新現有項目。

Task<Void>
@RequiresPermission(allOf = ["android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"])
updateOrInsertE2eeContactKey(
    lookupKeys: List<String>,
    deviceId: String,
    accountId: String,
    keyValue: ByteArray
)

在端對端加密聯絡人金鑰資料表中插入新項目,或更新現有項目。

Task<Void>
@RequiresPermission(value = "android.permission.WRITE_CONTACTS")
updateOrInsertE2eeSelfKey(
    deviceId: String,
    accountId: String,
    keyValue: ByteArray
)

在端對端加密自訂金鑰資料表中插入新項目,或更新現有項目。

公開函式

getAccountContactKeysFlow

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getAccountContactKeysFlow(accountIds: List<String>): Flow<List<E2eeAccountContactKeyParcelable>>

傳回帳戶聯絡人金鑰更新的流程。

當任何帳戶 ID 的任何金鑰更新、新增或移除時,系統就會發出流程。系統會發出所提供 accountId 的所有金鑰清單,而不只是更新的金鑰。

參數
accountIds: List<String>

要監聽更新的帳戶 ID 清單。

傳回
Flow<List<E2eeAccountContactKeyParcelable>>

每當任何金鑰更新、新增或移除時,都會針對提供的 accountId 發出 E2eeAccountContactKeyParcelable 清單的流程。

擲回
com.google.android.libraries.sdkcoroutines.flow.CallbackChannelFullException

如果回呼事件的處理速度過慢。

getAllE2eeContactKeys

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getAllE2eeContactKeys(lookupKey: String): Task<E2eeContactKeyListParcelable>

擷取屬於呼叫者可見應用程式的所有端對端加密聯絡人金鑰項目。金鑰會移除 deviceIdtimeUpdatedkeyValue 資料。

參數
lookupKey: String

參照聯絡人的值

傳回
Task<E2eeContactKeyListParcelable>

包含端對端加密聯絡人金鑰資訊的清單,或如果找不到任何金鑰,則為空白清單。E2eeContactKeyListParcelable

getAllE2eeSelfKeys

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getAllE2eeSelfKeys(): Task<E2eeSelfKeyListParcelable>

傳回呼叫者可見應用程式的所有端對端加密自我金鑰項目。金鑰會移除 deviceIdtimeUpdatedkeyValue 資料。

傳回
Task<E2eeSelfKeyListParcelable>

E2eeSelfKeyListParcelable,其中包含端對端加密自我金鑰資訊清單,如果找不到任何自我金鑰,則為空白清單。

getAllOwnerE2eeAccountContactKeys

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getAllOwnerE2eeAccountContactKeys(): Task<ImmutableList<E2eeAccountContactKeyParcelable>>

擷取屬於來電者應用程式的所有端對端加密帳戶聯絡人金鑰,無論是否與聯絡人相關聯。

傳回
Task<ImmutableList<E2eeAccountContactKeyParcelable>>

包含端對端加密聯絡人金鑰資訊的 E2eeAccountContactKeyParcelable 物件清單,如果找不到任何金鑰,則為空白清單。

getAllOwnerE2eeContactKeys

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getAllOwnerE2eeContactKeys(): Task<E2eeContactKeyListParcelable>

擷取所有聯絡人的所有端對端加密聯絡人金鑰,這些金鑰屬於呼叫端應用程式。

這個方法只會用於擷取至少有一個相關聯聯絡人的金鑰。如要擷取未與任何聯絡人建立關聯的金鑰,請改用 getAllOwnerE2eeAccountContactKeys

傳回
Task<E2eeContactKeyListParcelable>

包含端對端加密聯絡人金鑰資訊的清單,或如果找不到任何金鑰,則為空白清單。E2eeContactKeyListParcelable

getE2eeAccountKeysForAccount

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getE2eeAccountKeysForAccount(accountId: String): Task<ImmutableList<E2eeAccountContactKeyParcelable>>

擷取所有聯絡人中,屬於呼叫端應用程式和呼叫端帳戶的端對端加密聯絡人金鑰項目。包括未與任何聯絡人建立關聯的金鑰。

傳回
Task<ImmutableList<E2eeAccountContactKeyParcelable>>

包含端對端加密聯絡人金鑰資訊的 E2eeAccountContactKeyParcelable 物件清單,如果找不到任何金鑰,則為空白清單。

getE2eeContactKey

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getE2eeContactKey(lookupKey: String, deviceId: String, accountId: String): Task<E2eeContactKeyParcelable?>

根據 lookupKeydeviceIdaccountId 和推斷的呼叫端套件名稱,擷取端對端加密聯絡人金鑰項目。

參數
lookupKey: String

參照聯絡人的值

deviceId: String

應用程式指定的裝置 ID

accountId: String

帳戶的應用程式指定 ID

傳回
Task<E2eeContactKeyParcelable?>

包含聯絡人金鑰資訊的 E2eeContactKeyParcelable,如果找不到聯絡人金鑰,則為空值。

getE2eeSelfKey

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getE2eeSelfKey(deviceId: String, accountId: String): Task<E2eeSelfKeyParcelable?>

根據 deviceIdaccountId 和呼叫端的推斷套件名稱,傳回端對端加密自我金鑰項目。

參數
deviceId: String

應用程式指定的裝置 ID

accountId: String

帳戶的應用程式指定 ID

傳回
Task<E2eeSelfKeyParcelable?>

包含端對端加密自我金鑰資訊的 E2eeSelfKeyParcelable,如果找不到自我金鑰,則為空值。

getMaxKeySizeBytes

fun getMaxKeySizeBytes(): Task<Int>

傳回鍵的大小上限 (以位元組為單位)。

getOnboardingIntent

fun getOnboardingIntent(
    nextActivity: OnboardingNextActivity,
    lookupKey: String?,
    packageName: String?
): Task<PendingIntent>

傳回顯示新手上路活動的 Intent,並標示新手上路畫面已顯示在這部裝置上。這需要 nextActivity,可以是字串 showscan。如果 scan,則必須提供要掃描的聯絡人 lookupKey

參數
nextActivity: OnboardingNextActivity

在 Onboarding 活動後顯示的下一個活動。必須是 showscan

lookupKey: String?

參照聯絡人的值。如果 nextActivityscan,則為必要欄位。

packageName: String?

與需要金鑰的應用程式相關聯的套件名稱 (選用)。

getOwnerE2eeContactKeys

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getOwnerE2eeContactKeys(lookupKey: String): Task<E2eeContactKeyListParcelable>

擷取屬於呼叫端應用程式的指定 lookupKey 所有端對端加密聯絡人金鑰項目。

參數
lookupKey: String

參照聯絡人的值

傳回
Task<E2eeContactKeyListParcelable>

E2eeContactKeyListParcelable,其中包含端對端加密聯絡人金鑰資訊清單;如果找不到任何金鑰,則為空白清單。

getOwnerE2eeSelfKeys

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun getOwnerE2eeSelfKeys(): Task<E2eeSelfKeyListParcelable>

傳回呼叫端應用程式擁有的所有端對端加密自我金鑰項目。

傳回
Task<E2eeSelfKeyListParcelable>

包含端對端加密自我金鑰資訊的 E2eeSelfKeyListParcelable,如果找不到自我金鑰,則為空白清單。

getScanQrCodeIntent

fun getScanQrCodeIntent(lookupKey: String, skipOnboarding: Boolean = false): Task<PendingIntent>

傳回「掃描 QR code」活動的意圖。

參數
lookupKey: String

參照聯絡人的值

skipOnboarding: Boolean = false

目前未使用。

getScanQrCodeIntentForAccount

fun getScanQrCodeIntentForAccount(packageName: String, accountId: String): Task<PendingIntent>

傳回特定帳戶「掃描 QR code」活動的意圖。

參數
packageName: String

與使用者想驗證的帳戶相關聯的套件名稱

accountId: String

與使用者要驗證的帳戶相關聯的帳戶 ID

getShowQrCodeIntent

fun getShowQrCodeIntent(packageName: String?, skipOnboarding: Boolean = false): Task<PendingIntent>

傳回「顯示 QR code」活動的 Intent。

參數
packageName: String?

與需要金鑰的應用程式相關聯的套件名稱 (選用)

skipOnboarding: Boolean = false

目前未使用。

isEnabled

fun isEnabled(): Task<Boolean>

無論 API 是否可用,都會傳回成功完成的 Task。

如果 API 可用,傳回的工作結果會是 true,否則為 false。

系統會擷取 API 無法使用時通常會擲回的例外狀況,並改為傳回成功傳回 false 的工作。

registerAccountContactKeysListener

@RequiresPermission(value = "android.permission.READ_CONTACTS")
fun registerAccountContactKeysListener(
    accountIds: List<String>,
    listener: OnAccountContactKeysUpdatedListener
): Task<Void>

註冊帳戶聯絡人金鑰更新的監聽器。

只要提供的任何 accountId 的任何金鑰更新、新增或移除,系統就會呼叫監聽器。系統會使用所提供 accountId 的所有金鑰清單呼叫這個函式,而不只是更新的金鑰。

參數
accountIds: List<String>

要註冊接聽程式的帳戶 ID 清單。

listener: OnAccountContactKeysUpdatedListener

要註冊的監聽器。

removeE2eeAccountContactKey

@RequiresPermission(value = "android.permission.WRITE_CONTACTS")
fun removeE2eeAccountContactKey(deviceId: String, accountId: String): Task<Void>

移除屬於來電者應用程式的端對端加密帳戶聯絡人金鑰項目。

參數
deviceId: String

應用程式指定的裝置 ID

accountId: String

帳戶的應用程式指定 ID

removeE2eeContactKey

@RequiresPermission(value = "android.permission.WRITE_CONTACTS")
fun removeE2eeContactKey(
    lookupKey: String,
    deviceId: String,
    accountId: String
): Task<Void>

移除屬於來電應用程式的端對端加密通訊錄金鑰項目。

參數
lookupKey: String

參照聯絡人的值

deviceId: String

應用程式指定的裝置 ID

accountId: String

帳戶的應用程式指定 ID

removeE2eeSelfKey

@RequiresPermission(value = "android.permission.WRITE_CONTACTS")
fun removeE2eeSelfKey(deviceId: String, accountId: String): Task<Void>

根據 deviceId 和呼叫端的推斷套件名稱,移除端對端加密自我金鑰項目。

參數
deviceId: String

應用程式指定的裝置 ID

accountId: String

帳戶的應用程式指定 ID

unregisterAccountContactKeysListener

@CanIgnoreReturnValue
fun unregisterAccountContactKeysListener(
    listener: OnAccountContactKeysUpdatedListener
): Task<Boolean>

取消註冊帳戶聯絡人金鑰更新的接聽程式。

參數
listener: OnAccountContactKeysUpdatedListener

要取消註冊的接聽程式。

updateAllE2eeAccountKeys

@RequiresPermission(allOf = ["android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"])
fun updateAllE2eeAccountKeys(accountKeyInfos: List<E2eeAccountKeyInfo>): Task<Void>

插入一批帳戶聯絡人金鑰。

行為與 updateOrInsertE2eeContactKey 類似,但可一次插入/更新多個鍵。每個鍵都會插入自己的交易,因此即使工作擲回例外狀況,部分鍵仍可能會插入。

用戶端可以選擇重新傳送整個批次,處理暫時性失敗,因為這個 API 不會影響已插入金鑰的狀態。

如果為每個鍵提供 lookupKey,但未提供聯絡人基本資訊 (displayName、phoneNumber、emailAddress),這個 API 也會嘗試從聯絡人供應商擷取聯絡人的姓名、電話號碼和電子郵件地址。擷取金鑰時,聯絡人管理應用程式應使用這項資訊,確保金鑰只用於預期聯絡人。

Android 金鑰驗證應用程式會將這項資訊儲存在裝置上,且只會向擁有 READ_CONTACTS 權限的 API 呼叫端公開。

如果未提供金鑰的 lookupKey,這個 API 會儲存未繫結至任何聯絡人的金鑰。

參數
accountKeyInfos: List<E2eeAccountKeyInfo>

E2eeAccountKeyInfo 物件清單,內含端對端加密聯絡人金鑰資訊。

updateOrInsertE2eeContactKey

@RequiresPermission(allOf = ["android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"])
fun updateOrInsertE2eeContactKey(
    lookupKey: String,
    deviceId: String,
    accountId: String,
    keyValue: ByteArray
): Task<Void>

在端對端加密聯絡人金鑰資料表中插入新項目,或更新現有項目。插入/更新的端對端加密聯絡人金鑰屬於呼叫端應用程式。

這個 API 也會連同金鑰,一併儲存聯絡人提供者的聯絡人姓名、電話號碼和電子郵件地址。擷取金鑰時,聯絡人管理應用程式應使用這項資訊,確保金鑰只用於預期聯絡人。

Android 金鑰驗證應用程式會將這項資訊儲存在裝置上,且只會向擁有 READ_CONTACTS 權限的 API 呼叫端公開。

參數
lookupKey: String

參照聯絡人的值

deviceId: String

應用程式指定的裝置 ID

accountId: String

帳戶的應用程式指定 ID

keyValue: ByteArray

金鑰的原始位元組 (大小上限為 getMaxKeySizeBytes 個位元組)

updateOrInsertE2eeContactKey

@RequiresPermission(allOf = ["android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS"])
fun updateOrInsertE2eeContactKey(
    lookupKeys: List<String>,
    deviceId: String,
    accountId: String,
    keyValue: ByteArray
): Task<Void>

在端對端加密聯絡人金鑰資料表中插入新項目,或更新現有項目。插入/更新的端對端加密聯絡人金鑰屬於呼叫端應用程式。

對於提供的每個查閱鍵,這個 API 也會連同鍵,一併儲存聯絡人提供者的聯絡人姓名、電話號碼和電子郵件地址。擷取金鑰時,聯絡人管理應用程式應使用這項資訊,確保金鑰只用於預期聯絡人。

Android 金鑰驗證應用程式會將這項資訊儲存在裝置上,且只會向擁有 READ_CONTACTS 權限的 API 呼叫端公開。

如果查閱鍵清單為空白,這個 API 會儲存未與任何聯絡人建立關聯的金鑰。

使用一或多個查閱鍵呼叫這個 API 時,系統會更新鍵中繼資料,將其與提供的聯絡人建立關聯,但不會移除未在清單中提供的聯絡人現有任何關聯。如要移除聯絡人和金鑰之間的關聯,請使用適當的查閱鍵呼叫 removeE2eeContactKey

參數
lookupKeys: List<String>

可能為空白的 CP2 查閱鍵清單,參照與該鍵相關聯的聯絡人

deviceId: String

應用程式指定的裝置 ID

accountId: String

帳戶的應用程式指定 ID

keyValue: ByteArray

金鑰的原始位元組 (大小上限為 getMaxKeySizeBytes 個位元組)

updateOrInsertE2eeSelfKey

@RequiresPermission(value = "android.permission.WRITE_CONTACTS")
fun updateOrInsertE2eeSelfKey(
    deviceId: String,
    accountId: String,
    keyValue: ByteArray
): Task<Void>

在端對端加密自訂金鑰資料表中插入新項目,或更新現有項目。

參數
deviceId: String

應用程式指定的裝置 ID

accountId: String

帳戶的應用程式指定 ID

keyValue: ByteArray

金鑰的原始位元組 (大小上限為 getMaxKeySizeBytes 個位元組)