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

Commit 164f81c5 authored by Qinmei Du's avatar Qinmei Du Committed by Android (Google) Code Review
Browse files

Merge "Change the appName from manifest rather than appPackageName from requestInfo"

parents 90e1fa8a 601eb6bd
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ class CredentialManagerRepo(
    val providerEnabledList = GetFlowUtils.toProviderList(
    // TODO: handle runtime cast error
      providerEnabledList as List<GetCredentialProviderData>, context)
    val requestDisplayInfo = GetFlowUtils.toRequestDisplayInfo(requestInfo)
    val requestDisplayInfo = GetFlowUtils.toRequestDisplayInfo(requestInfo, context)
    return GetCredentialUiState(
      providerEnabledList,
      requestDisplayInfo,
@@ -427,7 +427,7 @@ class CredentialManagerRepo(
        /*candidateQueryData=*/ Bundle(),
        /*requireSystemProvider=*/ false
      ),
      "tribank"
      "com.google.android.youtube"
    )
  }

@@ -442,7 +442,7 @@ class CredentialManagerRepo(
        /*candidateQueryData=*/ Bundle(),
        /*requireSystemProvider=*/ false
      ),
      "tribank"
      "com.google.android.youtube"
    )
  }

@@ -456,7 +456,7 @@ class CredentialManagerRepo(
        /*candidateQueryData=*/ Bundle(),
        /*requireSystemProvider=*/ false
      ),
      "tribank"
      "com.google.android.youtube"
    )
  }

@@ -471,7 +471,7 @@ class CredentialManagerRepo(
            TYPE_PUBLIC_KEY_CREDENTIAL, Bundle(), Bundle(), /*requireSystemProvider=*/ false)
        )
        .build(),
      "tribank.us"
      "com.google.android.youtube"
    )
  }
}
+18 −8
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.credentials.ui.CreateCredentialProviderData
import android.credentials.ui.DisabledProviderData
import android.credentials.ui.RequestInfo
import android.graphics.drawable.Drawable
import android.text.TextUtils
import com.android.credentialmanager.createflow.CreateOptionInfo
import com.android.credentialmanager.createflow.RemoteInfo
import com.android.credentialmanager.createflow.RequestDisplayInfo
@@ -58,7 +59,6 @@ class GetFlowUtils {
    ): List<ProviderInfo> {
      val packageManager = context.packageManager
      return providerDataList.map {
        // TODO: get from the actual service info
        val componentName = ComponentName.unflattenFromString(it.providerFlattenedComponentName)
        var packageName = componentName?.packageName
        if (componentName == null) {
@@ -70,8 +70,7 @@ class GetFlowUtils {
                .getPackageInfo(packageName!!,
                        PackageManager.PackageInfoFlags.of(0))
        val providerDisplayName = pkgInfo.applicationInfo.loadLabel(packageManager).toString()
        // TODO: get the provider icon from the service
        //  and decide what to do when failed to load a provider icon
        // TODO: decide what to do when failed to load a provider icon
        val providerIcon = pkgInfo.applicationInfo.loadIcon(packageManager)!!
        ProviderInfo(
                id = it.providerFlattenedComponentName,
@@ -94,9 +93,15 @@ class GetFlowUtils {

    fun toRequestDisplayInfo(
            requestInfo: RequestInfo,
            context: Context,
    ): com.android.credentialmanager.getflow.RequestDisplayInfo {
        val packageName = requestInfo.appPackageName
        val pkgInfo = context.packageManager.getPackageInfo(packageName,
                PackageManager.PackageInfoFlags.of(0))
        val appLabel = pkgInfo.applicationInfo.loadSafeLabel(context.packageManager, 0f,
            TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM)
        return com.android.credentialmanager.getflow.RequestDisplayInfo(
              appDomainName = requestInfo.appPackageName
              appName = appLabel.toString()
      )
    }

@@ -251,6 +256,11 @@ class CreateFlowUtils {
            requestInfo: RequestInfo,
            context: Context,
    ): RequestDisplayInfo {
      val packageName = requestInfo.appPackageName
      val pkgInfo = context.packageManager.getPackageInfo(packageName,
            PackageManager.PackageInfoFlags.of(0))
      val appLabel = pkgInfo.applicationInfo.loadSafeLabel(context.packageManager, 0f,
            TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM)
      val createCredentialRequest = requestInfo.createCredentialRequest
      val createCredentialRequestJetpack = createCredentialRequest?.let {
        CreateCredentialRequest.createFrom(
@@ -263,7 +273,7 @@ class CreateFlowUtils {
                  createCredentialRequestJetpack.id,
                  createCredentialRequestJetpack.password,
                  createCredentialRequestJetpack.type,
                  requestInfo.appPackageName,
                  appLabel.toString(),
                  context.getDrawable(R.drawable.ic_password)!!
          )
        }
@@ -281,7 +291,7 @@ class CreateFlowUtils {
                  name,
                  displayName,
                  createCredentialRequestJetpack.type,
                  requestInfo.appPackageName,
                  appLabel.toString(),
                  context.getDrawable(R.drawable.ic_passkey)!!)
        }
        // TODO: correctly parsing for other sign-ins
@@ -290,7 +300,7 @@ class CreateFlowUtils {
                  "beckett-bakert@gmail.com",
                  "Elisa Beckett",
                  "other-sign-ins",
                  requestInfo.appPackageName,
                  appLabel.toString(),
                  context.getDrawable(R.drawable.ic_other_sign_in)!!)
        }
      }
+4 −4
Original line number Diff line number Diff line
@@ -550,15 +550,15 @@ fun CreationSelectionCard(
                text = when (requestDisplayInfo.type) {
                    TYPE_PUBLIC_KEY_CREDENTIAL -> stringResource(
                        R.string.choose_create_option_passkey_title,
                        requestDisplayInfo.appDomainName
                        requestDisplayInfo.appName
                    )
                    TYPE_PASSWORD_CREDENTIAL -> stringResource(
                        R.string.choose_create_option_password_title,
                        requestDisplayInfo.appDomainName
                        requestDisplayInfo.appName
                    )
                    else -> stringResource(
                        R.string.choose_create_option_sign_in_title,
                        requestDisplayInfo.appDomainName
                        requestDisplayInfo.appName
                    )
                },
                style = MaterialTheme.typography.titleMedium,
@@ -615,7 +615,7 @@ fun CreationSelectionCard(
                TextSecondary(
                    text = stringResource(
                        R.string.choose_create_option_description,
                        requestDisplayInfo.appDomainName,
                        requestDisplayInfo.appName,
                        when (requestDisplayInfo.type) {
                            TYPE_PUBLIC_KEY_CREDENTIAL -> stringResource(R.string.passkey)
                            TYPE_PASSWORD_CREDENTIAL -> stringResource(R.string.password)
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ data class RequestDisplayInfo(
  val title: String,
  val subtitle: String?,
  val type: String,
  val appDomainName: String,
  val appName: String,
  val typeIcon: Drawable,
)

+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ fun PrimarySelectionCard(
                    ) {
                        R.string.get_dialog_title_use_sign_in_for
                    } else R.string.get_dialog_title_choose_sign_in_for,
                    requestDisplayInfo.appDomainName
                    requestDisplayInfo.appName
                ),
            )

Loading