Loading packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt +2 −15 Original line number Original line Diff line number Diff line Loading @@ -52,9 +52,7 @@ import androidx.credentials.CreateCustomCredentialRequest import androidx.credentials.CreatePasswordRequest import androidx.credentials.CreatePasswordRequest import androidx.credentials.CredentialOption import androidx.credentials.CredentialOption import androidx.credentials.CreatePublicKeyCredentialRequest import androidx.credentials.CreatePublicKeyCredentialRequest import androidx.credentials.CreatePublicKeyCredentialRequestPrivileged import androidx.credentials.GetPublicKeyCredentialOption import androidx.credentials.GetPublicKeyCredentialOption import androidx.credentials.GetPublicKeyCredentialOptionPrivileged import androidx.credentials.PublicKeyCredential.Companion.TYPE_PUBLIC_KEY_CREDENTIAL import androidx.credentials.PublicKeyCredential.Companion.TYPE_PUBLIC_KEY_CREDENTIAL import androidx.credentials.provider.Action import androidx.credentials.provider.Action import androidx.credentials.provider.AuthenticationAction import androidx.credentials.provider.AuthenticationAction Loading Loading @@ -186,8 +184,6 @@ class GetFlowUtils { ) ) if (credentialOptionJetpack is GetPublicKeyCredentialOption) { if (credentialOptionJetpack is GetPublicKeyCredentialOption) { credentialOptionJetpack.preferImmediatelyAvailableCredentials credentialOptionJetpack.preferImmediatelyAvailableCredentials } else if (credentialOptionJetpack is GetPublicKeyCredentialOptionPrivileged) { credentialOptionJetpack.preferImmediatelyAvailableCredentials } else { } else { false false } } Loading Loading @@ -448,23 +444,14 @@ class CreateFlowUtils { createCredentialRequestJetpack.preferImmediatelyAvailableCredentials, createCredentialRequestJetpack.preferImmediatelyAvailableCredentials, ) ) } } is CreatePublicKeyCredentialRequestPrivileged -> { newRequestDisplayInfoFromPasskeyJson( requestJson = createCredentialRequestJetpack.requestJson, appLabel = appLabel, context = context, preferImmediatelyAvailableCredentials = createCredentialRequestJetpack.preferImmediatelyAvailableCredentials, ) } is CreateCustomCredentialRequest -> { is CreateCustomCredentialRequest -> { // TODO: directly use the display info once made public // TODO: directly use the display info once made public val displayInfo = CreateCredentialRequest.DisplayInfo val displayInfo = CreateCredentialRequest.DisplayInfo .parseFromCredentialDataBundle(createCredentialRequest.credentialData) .parseFromCredentialDataBundle(createCredentialRequest.credentialData) ?: return null ?: return null RequestDisplayInfo( RequestDisplayInfo( title = displayInfo.userId, title = displayInfo.userId.toString(), subtitle = displayInfo.userDisplayName, subtitle = displayInfo.userDisplayName?.toString(), type = CredentialType.UNKNOWN, type = CredentialType.UNKNOWN, appName = appLabel, appName = appLabel, typeIcon = displayInfo.credentialTypeIcon?.loadDrawable(context) typeIcon = displayInfo.credentialTypeIcon?.loadDrawable(context) Loading packages/CredentialManager/src/com/android/credentialmanager/TestUtils.kt +14 −4 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,10 @@ import android.credentials.Credential.TYPE_PASSWORD_CREDENTIAL import android.credentials.ui.AuthenticationEntry import android.credentials.ui.AuthenticationEntry import android.credentials.ui.Entry import android.credentials.ui.Entry import android.net.Uri import android.net.Uri import android.os.Bundle import android.provider.Settings import android.provider.Settings import androidx.credentials.provider.BeginGetPasswordOption import androidx.credentials.provider.BeginGetPublicKeyCredentialOption import androidx.credentials.provider.CreateEntry import androidx.credentials.provider.CreateEntry import androidx.credentials.provider.PasswordCredentialEntry import androidx.credentials.provider.PasswordCredentialEntry import androidx.credentials.provider.PublicKeyCredentialEntry import androidx.credentials.provider.PublicKeyCredentialEntry Loading Loading @@ -82,7 +85,9 @@ class GetTestUtils { return Entry( return Entry( key, key, subkey, subkey, RemoteCredentialEntry(pendingIntent).slice RemoteCredentialEntry(pendingIntent, BeginGetPublicKeyCredentialOption( Bundle(), "id", "requestjson" )).slice ) ) } } Loading Loading @@ -137,7 +142,8 @@ class GetTestUtils { intent, (PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT intent, (PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT) or PendingIntent.FLAG_ONE_SHOT) ) ) val passwordEntry = PasswordCredentialEntry.Builder(context, userName, pendingIntent) val passwordEntry = PasswordCredentialEntry.Builder( context, userName, pendingIntent, BeginGetPasswordOption(Bundle(), "id")) .setDisplayName(userDisplayName).setLastUsedTime(lastUsedTime).build() .setDisplayName(userDisplayName).setLastUsedTime(lastUsedTime).build() return Entry(key, subkey, passwordEntry.slice, Intent()) return Entry(key, subkey, passwordEntry.slice, Intent()) } } Loading @@ -158,8 +164,12 @@ class GetTestUtils { intent, (PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT intent, (PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT) or PendingIntent.FLAG_ONE_SHOT) ) ) val passkeyEntry = PublicKeyCredentialEntry.Builder(context, userName, pendingIntent) val passkeyEntry = PublicKeyCredentialEntry.Builder( .setDisplayName(userDisplayName).setLastUsedTime(lastUsedTime).build() context, userName, pendingIntent, BeginGetPublicKeyCredentialOption(Bundle(), "id", "requestjson") ).setDisplayName(userDisplayName).setLastUsedTime(lastUsedTime).build() return Entry(key, subkey, passkeyEntry.slice, Intent()) return Entry(key, subkey, passkeyEntry.slice, Intent()) } } } } Loading Loading
packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt +2 −15 Original line number Original line Diff line number Diff line Loading @@ -52,9 +52,7 @@ import androidx.credentials.CreateCustomCredentialRequest import androidx.credentials.CreatePasswordRequest import androidx.credentials.CreatePasswordRequest import androidx.credentials.CredentialOption import androidx.credentials.CredentialOption import androidx.credentials.CreatePublicKeyCredentialRequest import androidx.credentials.CreatePublicKeyCredentialRequest import androidx.credentials.CreatePublicKeyCredentialRequestPrivileged import androidx.credentials.GetPublicKeyCredentialOption import androidx.credentials.GetPublicKeyCredentialOption import androidx.credentials.GetPublicKeyCredentialOptionPrivileged import androidx.credentials.PublicKeyCredential.Companion.TYPE_PUBLIC_KEY_CREDENTIAL import androidx.credentials.PublicKeyCredential.Companion.TYPE_PUBLIC_KEY_CREDENTIAL import androidx.credentials.provider.Action import androidx.credentials.provider.Action import androidx.credentials.provider.AuthenticationAction import androidx.credentials.provider.AuthenticationAction Loading Loading @@ -186,8 +184,6 @@ class GetFlowUtils { ) ) if (credentialOptionJetpack is GetPublicKeyCredentialOption) { if (credentialOptionJetpack is GetPublicKeyCredentialOption) { credentialOptionJetpack.preferImmediatelyAvailableCredentials credentialOptionJetpack.preferImmediatelyAvailableCredentials } else if (credentialOptionJetpack is GetPublicKeyCredentialOptionPrivileged) { credentialOptionJetpack.preferImmediatelyAvailableCredentials } else { } else { false false } } Loading Loading @@ -448,23 +444,14 @@ class CreateFlowUtils { createCredentialRequestJetpack.preferImmediatelyAvailableCredentials, createCredentialRequestJetpack.preferImmediatelyAvailableCredentials, ) ) } } is CreatePublicKeyCredentialRequestPrivileged -> { newRequestDisplayInfoFromPasskeyJson( requestJson = createCredentialRequestJetpack.requestJson, appLabel = appLabel, context = context, preferImmediatelyAvailableCredentials = createCredentialRequestJetpack.preferImmediatelyAvailableCredentials, ) } is CreateCustomCredentialRequest -> { is CreateCustomCredentialRequest -> { // TODO: directly use the display info once made public // TODO: directly use the display info once made public val displayInfo = CreateCredentialRequest.DisplayInfo val displayInfo = CreateCredentialRequest.DisplayInfo .parseFromCredentialDataBundle(createCredentialRequest.credentialData) .parseFromCredentialDataBundle(createCredentialRequest.credentialData) ?: return null ?: return null RequestDisplayInfo( RequestDisplayInfo( title = displayInfo.userId, title = displayInfo.userId.toString(), subtitle = displayInfo.userDisplayName, subtitle = displayInfo.userDisplayName?.toString(), type = CredentialType.UNKNOWN, type = CredentialType.UNKNOWN, appName = appLabel, appName = appLabel, typeIcon = displayInfo.credentialTypeIcon?.loadDrawable(context) typeIcon = displayInfo.credentialTypeIcon?.loadDrawable(context) Loading
packages/CredentialManager/src/com/android/credentialmanager/TestUtils.kt +14 −4 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,10 @@ import android.credentials.Credential.TYPE_PASSWORD_CREDENTIAL import android.credentials.ui.AuthenticationEntry import android.credentials.ui.AuthenticationEntry import android.credentials.ui.Entry import android.credentials.ui.Entry import android.net.Uri import android.net.Uri import android.os.Bundle import android.provider.Settings import android.provider.Settings import androidx.credentials.provider.BeginGetPasswordOption import androidx.credentials.provider.BeginGetPublicKeyCredentialOption import androidx.credentials.provider.CreateEntry import androidx.credentials.provider.CreateEntry import androidx.credentials.provider.PasswordCredentialEntry import androidx.credentials.provider.PasswordCredentialEntry import androidx.credentials.provider.PublicKeyCredentialEntry import androidx.credentials.provider.PublicKeyCredentialEntry Loading Loading @@ -82,7 +85,9 @@ class GetTestUtils { return Entry( return Entry( key, key, subkey, subkey, RemoteCredentialEntry(pendingIntent).slice RemoteCredentialEntry(pendingIntent, BeginGetPublicKeyCredentialOption( Bundle(), "id", "requestjson" )).slice ) ) } } Loading Loading @@ -137,7 +142,8 @@ class GetTestUtils { intent, (PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT intent, (PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT) or PendingIntent.FLAG_ONE_SHOT) ) ) val passwordEntry = PasswordCredentialEntry.Builder(context, userName, pendingIntent) val passwordEntry = PasswordCredentialEntry.Builder( context, userName, pendingIntent, BeginGetPasswordOption(Bundle(), "id")) .setDisplayName(userDisplayName).setLastUsedTime(lastUsedTime).build() .setDisplayName(userDisplayName).setLastUsedTime(lastUsedTime).build() return Entry(key, subkey, passwordEntry.slice, Intent()) return Entry(key, subkey, passwordEntry.slice, Intent()) } } Loading @@ -158,8 +164,12 @@ class GetTestUtils { intent, (PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT intent, (PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_ONE_SHOT) or PendingIntent.FLAG_ONE_SHOT) ) ) val passkeyEntry = PublicKeyCredentialEntry.Builder(context, userName, pendingIntent) val passkeyEntry = PublicKeyCredentialEntry.Builder( .setDisplayName(userDisplayName).setLastUsedTime(lastUsedTime).build() context, userName, pendingIntent, BeginGetPublicKeyCredentialOption(Bundle(), "id", "requestjson") ).setDisplayName(userDisplayName).setLastUsedTime(lastUsedTime).build() return Entry(key, subkey, passkeyEntry.slice, Intent()) return Entry(key, subkey, passkeyEntry.slice, Intent()) } } } } Loading