summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt13
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt9
2 files changed, 10 insertions, 12 deletions
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
index ca891294576b..64addf237f9b 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
@@ -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> {
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt b/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt
index c1ea1d8d1746..b8b7ac33bd9f 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt
@@ -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)