[CredManUi] Dedup passkeys on username, not display name

Bug: 277603453
Test: manual (see bug for screenshots)
Change-Id: Ib6b454070f99230261d99bd1922e258938607b27
This commit is contained in:
Helen Qin
2023-04-10 22:06:54 +00:00
parent c0ff8e9672
commit 8d25f70bd6
2 changed files with 10 additions and 12 deletions

View File

@@ -252,13 +252,6 @@ class GetFlowUtils {
))
}
is PublicKeyCredentialEntry -> {
val passkeyUsername = credentialEntry.username.toString()
val passkeyDisplayName = credentialEntry.displayName?.toString() ?: ""
val (username, displayName) = userAndDisplayNameForPasskey(
passkeyUsername = passkeyUsername,
passkeyDisplayName = passkeyDisplayName,
)
result.add(CredentialEntryInfo(
providerId = providerId,
providerDisplayName = providerLabel,
@@ -268,8 +261,8 @@ class GetFlowUtils {
fillInIntent = it.frameworkExtrasIntent,
credentialType = CredentialType.PASSKEY,
credentialTypeDisplayName = credentialEntry.typeDisplayName.toString(),
userName = username,
displayName = displayName,
userName = credentialEntry.username.toString(),
displayName = credentialEntry.displayName?.toString(),
icon = credentialEntry.icon.loadDrawable(context),
shouldTintIcon = credentialEntry.isDefaultIcon,
lastUsedTimeMillis = credentialEntry.lastUsedTime,
@@ -707,7 +700,7 @@ class CreateFlowUtils {
* 2) username on top if display-name is not available.
* 3) don't show username on second line if username == display-name
*/
private fun userAndDisplayNameForPasskey(
fun userAndDisplayNameForPasskey(
passkeyUsername: String,
passkeyDisplayName: String,
): Pair<String, String> {

View File

@@ -66,6 +66,7 @@ import com.android.credentialmanager.common.ui.HeadlineIcon
import com.android.credentialmanager.common.ui.LargeLabelTextOnSurfaceVariant
import com.android.credentialmanager.common.ui.Snackbar
import com.android.credentialmanager.logging.GetCredentialEvent
import com.android.credentialmanager.userAndDisplayNameForPasskey
import com.android.internal.logging.UiEventLogger.UiEventEnum
@Composable
@@ -457,6 +458,10 @@ fun CredentialEntryRow(
enforceOneLine: Boolean = false,
onTextLayout: (TextLayoutResult) -> Unit = {},
) {
val (username, displayName) = if (credentialEntryInfo.credentialType == CredentialType.PASSKEY)
userAndDisplayNameForPasskey(
credentialEntryInfo.userName, credentialEntryInfo.displayName ?: "")
else Pair(credentialEntryInfo.userName, credentialEntryInfo.displayName)
Entry(
onClick = { onEntrySelected(credentialEntryInfo) },
iconImageBitmap = credentialEntryInfo.icon?.toBitmap()?.asImageBitmap(),
@@ -465,13 +470,13 @@ fun CredentialEntryRow(
iconPainter =
if (credentialEntryInfo.icon == null) painterResource(R.drawable.ic_other_sign_in_24)
else null,
entryHeadlineText = credentialEntryInfo.userName,
entryHeadlineText = username,
entrySecondLineText = if (
credentialEntryInfo.credentialType == CredentialType.PASSWORD) {
"••••••••••••"
} else {
val itemsToDisplay = listOf(
credentialEntryInfo.displayName,
displayName,
credentialEntryInfo.credentialTypeDisplayName,
credentialEntryInfo.providerDisplayName
).filterNot(TextUtils::isEmpty)