Merge "CredManUI: Use origin to replace the calling app package name." into udc-dev
This commit is contained in:
@@ -72,6 +72,12 @@ class CredentialManagerRepo(
|
|||||||
RequestInfo::class.java
|
RequestInfo::class.java
|
||||||
) ?: testCreatePasswordRequestInfo()
|
) ?: testCreatePasswordRequestInfo()
|
||||||
|
|
||||||
|
val originName: String? = when (requestInfo.type) {
|
||||||
|
RequestInfo.TYPE_CREATE -> requestInfo.createCredentialRequest?.origin
|
||||||
|
RequestInfo.TYPE_GET -> requestInfo.getCredentialRequest?.origin
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
providerEnabledList = when (requestInfo.type) {
|
providerEnabledList = when (requestInfo.type) {
|
||||||
RequestInfo.TYPE_CREATE ->
|
RequestInfo.TYPE_CREATE ->
|
||||||
intent.extras?.getParcelableArrayList(
|
intent.extras?.getParcelableArrayList(
|
||||||
@@ -105,14 +111,15 @@ class CredentialManagerRepo(
|
|||||||
val isPasskeyFirstUse = userConfigRepo.getIsPasskeyFirstUse()
|
val isPasskeyFirstUse = userConfigRepo.getIsPasskeyFirstUse()
|
||||||
val providerEnableListUiState = getCreateProviderEnableListInitialUiState()
|
val providerEnableListUiState = getCreateProviderEnableListInitialUiState()
|
||||||
val providerDisableListUiState = getCreateProviderDisableListInitialUiState()
|
val providerDisableListUiState = getCreateProviderDisableListInitialUiState()
|
||||||
val requestDisplayInfoUiState = getCreateRequestDisplayInfoInitialUiState()!!
|
val requestDisplayInfoUiState =
|
||||||
|
getCreateRequestDisplayInfoInitialUiState(originName)!!
|
||||||
UiState(
|
UiState(
|
||||||
createCredentialUiState = CreateFlowUtils.toCreateCredentialUiState(
|
createCredentialUiState = CreateFlowUtils.toCreateCredentialUiState(
|
||||||
providerEnableListUiState,
|
providerEnableListUiState,
|
||||||
providerDisableListUiState,
|
providerDisableListUiState,
|
||||||
defaultProviderId,
|
defaultProviderId,
|
||||||
requestDisplayInfoUiState,
|
requestDisplayInfoUiState,
|
||||||
/** isOnPasskeyIntroStateAlready = */
|
/** isOnPasskeyIntroStateAlready */
|
||||||
false,
|
false,
|
||||||
isPasskeyFirstUse
|
isPasskeyFirstUse
|
||||||
)!!,
|
)!!,
|
||||||
@@ -121,7 +128,7 @@ class CredentialManagerRepo(
|
|||||||
}
|
}
|
||||||
RequestInfo.TYPE_GET -> UiState(
|
RequestInfo.TYPE_GET -> UiState(
|
||||||
createCredentialUiState = null,
|
createCredentialUiState = null,
|
||||||
getCredentialUiState = getCredentialInitialUiState()!!,
|
getCredentialUiState = getCredentialInitialUiState(originName)!!,
|
||||||
)
|
)
|
||||||
else -> throw IllegalStateException("Unrecognized request type: ${requestInfo.type}")
|
else -> throw IllegalStateException("Unrecognized request type: ${requestInfo.type}")
|
||||||
}
|
}
|
||||||
@@ -172,11 +179,11 @@ class CredentialManagerRepo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IMPORTANT: new invocation should be mindful that this method can throw.
|
// IMPORTANT: new invocation should be mindful that this method can throw.
|
||||||
private fun getCredentialInitialUiState(): GetCredentialUiState? {
|
private fun getCredentialInitialUiState(originName: String?): GetCredentialUiState? {
|
||||||
val providerEnabledList = GetFlowUtils.toProviderList(
|
val providerEnabledList = GetFlowUtils.toProviderList(
|
||||||
providerEnabledList as List<GetCredentialProviderData>, context
|
providerEnabledList as List<GetCredentialProviderData>, context
|
||||||
)
|
)
|
||||||
val requestDisplayInfo = GetFlowUtils.toRequestDisplayInfo(requestInfo, context)
|
val requestDisplayInfo = GetFlowUtils.toRequestDisplayInfo(requestInfo, context, originName)
|
||||||
return GetCredentialUiState(
|
return GetCredentialUiState(
|
||||||
providerEnabledList,
|
providerEnabledList,
|
||||||
requestDisplayInfo ?: return null,
|
requestDisplayInfo ?: return null,
|
||||||
@@ -198,8 +205,10 @@ class CredentialManagerRepo(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCreateRequestDisplayInfoInitialUiState(): RequestDisplayInfo? {
|
private fun getCreateRequestDisplayInfoInitialUiState(
|
||||||
return CreateFlowUtils.toRequestDisplayInfo(requestInfo, context)
|
originName: String?
|
||||||
|
): RequestDisplayInfo? {
|
||||||
|
return CreateFlowUtils.toRequestDisplayInfo(requestInfo, context, originName)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -170,9 +170,11 @@ class GetFlowUtils {
|
|||||||
fun toRequestDisplayInfo(
|
fun toRequestDisplayInfo(
|
||||||
requestInfo: RequestInfo,
|
requestInfo: RequestInfo,
|
||||||
context: Context,
|
context: Context,
|
||||||
|
originName: String?,
|
||||||
): com.android.credentialmanager.getflow.RequestDisplayInfo? {
|
): com.android.credentialmanager.getflow.RequestDisplayInfo? {
|
||||||
return com.android.credentialmanager.getflow.RequestDisplayInfo(
|
return com.android.credentialmanager.getflow.RequestDisplayInfo(
|
||||||
appName = getAppLabel(context.packageManager, requestInfo.appPackageName)
|
appName = originName
|
||||||
|
?: getAppLabel(context.packageManager, requestInfo.appPackageName)
|
||||||
?: return null
|
?: return null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -395,8 +397,10 @@ class CreateFlowUtils {
|
|||||||
fun toRequestDisplayInfo(
|
fun toRequestDisplayInfo(
|
||||||
requestInfo: RequestInfo,
|
requestInfo: RequestInfo,
|
||||||
context: Context,
|
context: Context,
|
||||||
|
originName: String?,
|
||||||
): RequestDisplayInfo? {
|
): RequestDisplayInfo? {
|
||||||
val appLabel = getAppLabel(context.packageManager, requestInfo.appPackageName)
|
val appLabel = originName
|
||||||
|
?: getAppLabel(context.packageManager, requestInfo.appPackageName)
|
||||||
?: return null
|
?: return null
|
||||||
val createCredentialRequest = requestInfo.createCredentialRequest ?: return null
|
val createCredentialRequest = requestInfo.createCredentialRequest ?: return null
|
||||||
val createCredentialRequestJetpack = CreateCredentialRequest.createFrom(
|
val createCredentialRequestJetpack = CreateCredentialRequest.createFrom(
|
||||||
|
|||||||
Reference in New Issue
Block a user