diff options
author | 2024-02-29 08:20:25 +0000 | |
---|---|---|
committer | 2024-02-29 09:48:08 +0000 | |
commit | d07055dd35a516e2db494f53426868bf9c413ecf (patch) | |
tree | c3367b65b86a35368ab2b55800ba0d73c19d9c99 | |
parent | cd94108a7e4a94ea74f97cf230f984f9e2221ac4 (diff) |
Deduplicate & group entries based on a designated dedup id
(entryGroupId)
Before, we deduplication entries based on password / passkey usernames
and unknown typed credential title. However, it is possible that the unknown
typed credential will want to customize the value used for
deduplication, a value that will be different from the entry title it
want to display. This change allows that.
Bug: 306722792
Test: Screenshots attached to bug
Change-Id: I854e7afca7e999493437736d29e9ab866dfafd7a
4 files changed, 9 insertions, 2 deletions
diff --git a/packages/CredentialManager/shared/src/com/android/credentialmanager/ktx/CredentialKtx.kt b/packages/CredentialManager/shared/src/com/android/credentialmanager/ktx/CredentialKtx.kt index 39d3f42e8bf4..d8116111b0f2 100644 --- a/packages/CredentialManager/shared/src/com/android/credentialmanager/ktx/CredentialKtx.kt +++ b/packages/CredentialManager/shared/src/com/android/credentialmanager/ktx/CredentialKtx.kt @@ -132,6 +132,7 @@ private fun getCredentialOptionInfoList( lastUsedTimeMillis = credentialEntry.lastUsedTime, isAutoSelectable = credentialEntry.isAutoSelectAllowed && credentialEntry.isAutoSelectAllowedFromOption, + entryGroupId = credentialEntry.entryGroupId.toString(), ) ) } @@ -155,6 +156,7 @@ private fun getCredentialOptionInfoList( lastUsedTimeMillis = credentialEntry.lastUsedTime, isAutoSelectable = credentialEntry.isAutoSelectAllowed && credentialEntry.isAutoSelectAllowedFromOption, + entryGroupId = credentialEntry.entryGroupId.toString(), ) ) } @@ -177,6 +179,7 @@ private fun getCredentialOptionInfoList( lastUsedTimeMillis = credentialEntry.lastUsedTime, isAutoSelectable = credentialEntry.isAutoSelectAllowed && credentialEntry.isAutoSelectAllowedFromOption, + entryGroupId = credentialEntry.entryGroupId.toString(), ) ) } diff --git a/packages/CredentialManager/shared/src/com/android/credentialmanager/model/get/CredentialEntryInfo.kt b/packages/CredentialManager/shared/src/com/android/credentialmanager/model/get/CredentialEntryInfo.kt index 9725881e1c97..a5d4730967a3 100644 --- a/packages/CredentialManager/shared/src/com/android/credentialmanager/model/get/CredentialEntryInfo.kt +++ b/packages/CredentialManager/shared/src/com/android/credentialmanager/model/get/CredentialEntryInfo.kt @@ -40,6 +40,8 @@ class CredentialEntryInfo( val shouldTintIcon: Boolean, val lastUsedTimeMillis: Instant?, val isAutoSelectable: Boolean, + val entryGroupId: String, // Used for deduplication, and displayed as the grouping title + // "For <value-of-entryGroupId>" on the more-option screen. ) : EntryInfo( providerId, entryKey, diff --git a/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetModel.kt b/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetModel.kt index 458a99a8cd2f..e7f11a15a06c 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetModel.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetModel.kt @@ -16,6 +16,7 @@ package com.android.credentialmanager.getflow +import android.credentials.flags.Flags.selectorUiImprovementsEnabled import android.graphics.drawable.Drawable import com.android.credentialmanager.model.get.ProviderInfo import com.android.credentialmanager.model.EntryInfo @@ -133,7 +134,7 @@ fun toProviderDisplayInfo( providerInfo.credentialEntryList.forEach { userNameToCredentialEntryMap.compute( - it.userName + if (selectorUiImprovementsEnabled()) it.entryGroupId else it.userName ) { _, v -> if (v == null) { mutableListOf(it) diff --git a/packages/CredentialManager/tests/robotests/screenshot/src/com/android/credentialmanager/GetCredScreenshotTest.kt b/packages/CredentialManager/tests/robotests/screenshot/src/com/android/credentialmanager/GetCredScreenshotTest.kt index e609d0c5c008..d9ba36e1cdfc 100644 --- a/packages/CredentialManager/tests/robotests/screenshot/src/com/android/credentialmanager/GetCredScreenshotTest.kt +++ b/packages/CredentialManager/tests/robotests/screenshot/src/com/android/credentialmanager/GetCredScreenshotTest.kt @@ -146,7 +146,8 @@ class GetCredScreenshotTest(emulationSpec: DeviceEmulationSpec) { icon = null, shouldTintIcon = true, lastUsedTimeMillis = null, - isAutoSelectable = false + isAutoSelectable = false, + entryGroupId = "username", ) ), authenticationEntryList = emptyList(), |