diff --git a/packages/CredentialManager/res/drawable/ic_other_sign_in.xml b/packages/CredentialManager/res/drawable/ic_other_sign_in.xml
new file mode 100644
index 0000000000000..81501972d3bac
--- /dev/null
+++ b/packages/CredentialManager/res/drawable/ic_other_sign_in.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/CredentialManager/res/drawable/ic_password.xml b/packages/CredentialManager/res/drawable/ic_password.xml
new file mode 100644
index 0000000000000..bf3056a115c17
--- /dev/null
+++ b/packages/CredentialManager/res/drawable/ic_password.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt b/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt
index 94bd0573e0230..244a11fddedec 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt
@@ -44,12 +44,10 @@ import com.android.credentialmanager.createflow.ActiveEntry
import com.android.credentialmanager.createflow.CreateCredentialUiState
import com.android.credentialmanager.createflow.CreateScreenState
import com.android.credentialmanager.createflow.EnabledProviderInfo
-import com.android.credentialmanager.createflow.RequestDisplayInfo
import com.android.credentialmanager.getflow.GetCredentialUiState
import com.android.credentialmanager.getflow.GetScreenState
-import com.android.credentialmanager.jetpack.developer.CreateCredentialRequest.Companion.createFrom
-import com.android.credentialmanager.jetpack.developer.CreatePasswordRequest
import com.android.credentialmanager.jetpack.developer.CreatePasswordRequest.Companion.toBundle
+import com.android.credentialmanager.jetpack.developer.CreatePublicKeyCredentialRequest
import com.android.credentialmanager.jetpack.developer.PublicKeyCredential.Companion.TYPE_PUBLIC_KEY_CREDENTIAL
// Consider repo per screen, similar to view model?
@@ -67,7 +65,7 @@ class CredentialManagerRepo(
requestInfo = intent.extras?.getParcelable(
RequestInfo.EXTRA_REQUEST_INFO,
RequestInfo::class.java
- ) ?: testCreateRequestInfo()
+ ) ?: testCreatePasskeyRequestInfo()
providerEnabledList = when (requestInfo.type) {
RequestInfo.TYPE_CREATE ->
@@ -137,9 +135,10 @@ class CredentialManagerRepo(
}
fun createCredentialInitialUiState(): CreateCredentialUiState {
+ val requestDisplayInfo = CreateFlowUtils.toRequestDisplayInfo(requestInfo, context)
val providerEnabledList = CreateFlowUtils.toEnabledProviderList(
// Handle runtime cast error
- providerEnabledList as List, context)
+ providerEnabledList as List, requestDisplayInfo, context)
val providerDisabledList = CreateFlowUtils.toDisabledProviderList(
// Handle runtime cast error
providerDisabledList as List, context)
@@ -148,21 +147,6 @@ class CredentialManagerRepo(
providerEnabledList.forEach{providerInfo -> providerInfo.createOptions =
providerInfo.createOptions.sortedWith(compareBy { it.lastUsedTimeMillis }).reversed()
if (providerInfo.isDefault) {hasDefault = true; defaultProvider = providerInfo} }
- // TODO: covert from real requestInfo for create passkey
- var requestDisplayInfo = RequestDisplayInfo(
- "beckett-bakert@gmail.com",
- "Elisa Beckett",
- TYPE_PUBLIC_KEY_CREDENTIAL,
- "tribank")
- val createCredentialRequest = requestInfo.createCredentialRequest
- val createCredentialRequestJetpack = createCredentialRequest?.let { createFrom(it) }
- if (createCredentialRequestJetpack is CreatePasswordRequest) {
- requestDisplayInfo = RequestDisplayInfo(
- createCredentialRequestJetpack.id,
- createCredentialRequestJetpack.password,
- TYPE_PASSWORD_CREDENTIAL,
- "tribank")
- }
return CreateCredentialUiState(
enabledProviders = providerEnabledList,
disabledProviders = providerDisabledList,
@@ -440,8 +424,9 @@ class CredentialManagerRepo(
)
}
- private fun testCreateRequestInfo(): RequestInfo {
- val data = toBundle("beckett-bakert@gmail.com", "password123")
+ private fun testCreatePasskeyRequestInfo(): RequestInfo {
+ val request = CreatePublicKeyCredentialRequest("json")
+ val data = request.data
return RequestInfo.newCreateRequestInfo(
Binder(),
CreateCredentialRequest(
@@ -453,6 +438,32 @@ class CredentialManagerRepo(
)
}
+ private fun testCreatePasswordRequestInfo(): RequestInfo {
+ val data = toBundle("beckett-bakert@gmail.com", "password123")
+ return RequestInfo.newCreateRequestInfo(
+ Binder(),
+ CreateCredentialRequest(
+ TYPE_PASSWORD_CREDENTIAL,
+ data
+ ),
+ /*isFirstUsage=*/false,
+ "tribank"
+ )
+ }
+
+ private fun testCreateOtherCredentialRequestInfo(): RequestInfo {
+ val data = Bundle()
+ return RequestInfo.newCreateRequestInfo(
+ Binder(),
+ CreateCredentialRequest(
+ "other-sign-ins",
+ data
+ ),
+ /*isFirstUsage=*/false,
+ "tribank"
+ )
+ }
+
private fun testGetRequestInfo(): RequestInfo {
return RequestInfo.newGetRequestInfo(
Binder(),
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
index 2eb3284985719..c33af8fe9e354 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
@@ -23,14 +23,19 @@ import android.credentials.ui.Entry
import android.credentials.ui.GetCredentialProviderData
import android.credentials.ui.CreateCredentialProviderData
import android.credentials.ui.DisabledProviderData
+import android.credentials.ui.RequestInfo
import android.graphics.drawable.Drawable
import com.android.credentialmanager.createflow.CreateOptionInfo
import com.android.credentialmanager.createflow.RemoteInfo
+import com.android.credentialmanager.createflow.RequestDisplayInfo
import com.android.credentialmanager.getflow.ActionEntryInfo
import com.android.credentialmanager.getflow.AuthenticationEntryInfo
import com.android.credentialmanager.getflow.CredentialEntryInfo
import com.android.credentialmanager.getflow.ProviderInfo
import com.android.credentialmanager.getflow.RemoteEntryInfo
+import com.android.credentialmanager.jetpack.developer.CreateCredentialRequest
+import com.android.credentialmanager.jetpack.developer.CreatePasswordRequest
+import com.android.credentialmanager.jetpack.developer.CreatePublicKeyCredentialRequest
import com.android.credentialmanager.jetpack.provider.ActionUi
import com.android.credentialmanager.jetpack.provider.CredentialEntryUi
import com.android.credentialmanager.jetpack.provider.SaveEntryUi
@@ -172,6 +177,7 @@ class CreateFlowUtils {
fun toEnabledProviderList(
providerDataList: List,
+ requestDisplayInfo: RequestDisplayInfo,
context: Context,
): List {
// TODO: get from the actual service info
@@ -194,7 +200,7 @@ class CreateFlowUtils {
name = it.providerFlattenedComponentName,
displayName = pkgInfo.applicationInfo.loadLabel(packageManager).toString(),
createOptions = toCreationOptionInfoList(
- it.providerFlattenedComponentName, it.saveEntries, context),
+ it.providerFlattenedComponentName, it.saveEntries, requestDisplayInfo, context),
isDefault = it.isDefaultProvider,
remoteEntry = toRemoteInfo(it.providerFlattenedComponentName, it.remoteEntry),
)
@@ -219,9 +225,50 @@ class CreateFlowUtils {
}
}
+ fun toRequestDisplayInfo(
+ requestInfo: RequestInfo,
+ context: Context,
+ ): RequestDisplayInfo {
+ val createCredentialRequest = requestInfo.createCredentialRequest
+ val createCredentialRequestJetpack = createCredentialRequest?.let {
+ CreateCredentialRequest.createFrom(
+ it
+ )
+ }
+ // TODO: covert from real requestInfo
+ when (createCredentialRequestJetpack) {
+ is CreatePasswordRequest -> {
+ return RequestDisplayInfo(
+ createCredentialRequestJetpack.id,
+ createCredentialRequestJetpack.password,
+ createCredentialRequestJetpack.type,
+ "tribank",
+ context.getDrawable(R.drawable.ic_password)!!
+ )
+ }
+ is CreatePublicKeyCredentialRequest -> {
+ return RequestDisplayInfo(
+ "beckett-bakert@gmail.com",
+ "Elisa Beckett",
+ createCredentialRequestJetpack.type,
+ "tribank",
+ context.getDrawable(R.drawable.ic_passkey)!!)
+ }
+ else -> {
+ return RequestDisplayInfo(
+ "beckett-bakert@gmail.com",
+ "Elisa Beckett",
+ "other-sign-ins",
+ "tribank",
+ context.getDrawable(R.drawable.ic_other_sign_in)!!)
+ }
+ }
+ }
+
private fun toCreationOptionInfoList(
providerId: String,
creationEntries: List,
+ requestDisplayInfo: RequestDisplayInfo,
context: Context,
): List {
return creationEntries.map {
@@ -236,7 +283,7 @@ class CreateFlowUtils {
fillInIntent = it.frameworkExtrasIntent,
userProviderDisplayName = saveEntryUi.userProviderAccountName as String,
profileIcon = saveEntryUi.profileIcon?.loadDrawable(context)
- ?: context.getDrawable(R.drawable.ic_profile)!!,
+ ?: requestDisplayInfo.typeIcon,
passwordCount = saveEntryUi.passwordCount ?: 0,
passkeyCount = saveEntryUi.passkeyCount ?: 0,
totalCredentialCount = saveEntryUi.totalCredentialCount ?: 0,
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
index 9f73aefa52b22..f8c89bbf4c468 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
@@ -191,13 +191,12 @@ fun ProviderSelectionCard(
) {
Card() {
Column() {
- // TODO: Change the icon for create passwords and sign-ins
Icon(
- painter = painterResource(R.drawable.ic_passkey),
+ bitmap = requestDisplayInfo.typeIcon.toBitmap().asImageBitmap(),
contentDescription = null,
tint = LocalAndroidColorScheme.current.colorAccentPrimaryVariant,
modifier = Modifier.align(alignment = Alignment.CenterHorizontally)
- .padding(top = 24.dp, bottom = 16.dp)
+ .padding(top = 24.dp, bottom = 16.dp).size(32.dp)
)
Text(
text = stringResource(
@@ -567,12 +566,11 @@ fun PrimaryCreateOptionRow(
Entry(
onClick = {onOptionSelected(createOptionInfo)},
icon = {
- // TODO: Upload the other two types icons and change it according to request types
Icon(
- painter = painterResource(R.drawable.ic_passkey),
+ bitmap = createOptionInfo.profileIcon.toBitmap().asImageBitmap(),
contentDescription = null,
tint = LocalAndroidColorScheme.current.colorAccentPrimaryVariant,
- modifier = Modifier.padding(start = 18.dp)
+ modifier = Modifier.padding(start = 18.dp).size(32.dp)
)
},
label = {
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt
index 6dd6afb81dc4a..52ce06a2289b1 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt
@@ -76,6 +76,7 @@ data class RequestDisplayInfo(
val subtitle: String,
val type: String,
val appDomainName: String,
+ val typeIcon: Drawable,
)
/**
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/jetpack/developer/CreatePublicKeyCredentialBaseRequest.kt b/packages/CredentialManager/src/com/android/credentialmanager/jetpack/developer/CreatePublicKeyCredentialBaseRequest.kt
index 26d61f9eb7a91..37a4f76339886 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/jetpack/developer/CreatePublicKeyCredentialBaseRequest.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/jetpack/developer/CreatePublicKeyCredentialBaseRequest.kt
@@ -47,7 +47,7 @@ abstract class CreatePublicKeyCredentialBaseRequest constructor(
return when (data.getString(BUNDLE_KEY_SUBTYPE)) {
CreatePublicKeyCredentialRequest
.BUNDLE_VALUE_SUBTYPE_CREATE_PUBLIC_KEY_CREDENTIAL_REQUEST ->
- CreatePublicKeyCredentialRequestPrivileged.createFrom(data)
+ CreatePublicKeyCredentialRequest.createFrom(data)
CreatePublicKeyCredentialRequestPrivileged
.BUNDLE_VALUE_SUBTYPE_CREATE_PUBLIC_KEY_CREDENTIAL_REQUEST_PRIVILEGED ->
CreatePublicKeyCredentialRequestPrivileged.createFrom(data)