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

Commit 3a059797 authored by Helen Qin's avatar Helen Qin
Browse files

Fix the CredMan UI module to adopt the new credentials apis.

Bug: 271283162
Test: local deployment
Change-Id: I4d29a35c05fc96b5890c68cda911c6deb02491bf
parent a6b032d1
Loading
Loading
Loading
Loading
+2 −15
Original line number Original line Diff line number Diff line
@@ -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
@@ -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
                }
                }
@@ -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)
+14 −4
Original line number Original line Diff line number Diff line
@@ -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
@@ -82,7 +85,9 @@ class GetTestUtils {
            return Entry(
            return Entry(
                key,
                key,
                subkey,
                subkey,
                RemoteCredentialEntry(pendingIntent).slice
                RemoteCredentialEntry(pendingIntent, BeginGetPublicKeyCredentialOption(
                    Bundle(), "id", "requestjson"
                )).slice
            )
            )
        }
        }


@@ -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())
        }
        }
@@ -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())
        }
        }
    }
    }