Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d222f7d authored by Helen Qin's avatar Helen Qin Committed by Android (Google) Code Review
Browse files

Merge "[CredManUi] Dedup passkeys on username, not display name" into udc-dev

parents 9a43389c 8d25f70b
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -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> {
+7 −2
Original line number Diff line number Diff line
@@ -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)