diff options
| author | 2024-02-20 22:24:49 +0000 | |
|---|---|---|
| committer | 2024-02-21 02:06:26 +0000 | |
| commit | 987ce859d90ebf487a7901e3149c310d94afe4c4 (patch) | |
| tree | d4333f2b7761143128dca4fcecf9591bac514b27 | |
| parent | 12e867a96d0d1b4efb580b8c43e51f2b7afff557 (diff) | |
Remove the passkey education screen.
Test: local verification
Bug: 326109674
Change-Id: Iaccc756bee7a7ad63ff00d393258ef0e936e5998
7 files changed, 7 insertions, 276 deletions
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt b/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt index 30973879de10..6100623cbb3c 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt @@ -50,7 +50,6 @@ import com.android.credentialmanager.createflow.isFlowAutoSelectable class CredentialManagerRepo( private val context: Context, intent: Intent, - userConfigRepo: UserConfigRepo, isNewActivity: Boolean, ) { val requestInfo: RequestInfo? @@ -124,7 +123,6 @@ class CredentialManagerRepo( initialUiState = when (requestInfo?.type) { RequestInfo.TYPE_CREATE -> { - val isPasskeyFirstUse = userConfigRepo.getIsPasskeyFirstUse() val providerEnableListUiState = getCreateProviderEnableListInitialUiState() val providerDisableListUiState = getCreateProviderDisableListInitialUiState() val requestDisplayInfoUiState = @@ -137,8 +135,6 @@ class CredentialManagerRepo( defaultProviderIdsSetByUser = requestDisplayInfoUiState.userSetDefaultProviderIds, requestDisplayInfo = requestDisplayInfoUiState, - isOnPasskeyIntroStateAlready = false, - isPasskeyFirstUse = isPasskeyFirstUse, )!! val isFlowAutoSelectable = isFlowAutoSelectable(createCredentialUiState) UiState( diff --git a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt index 4771237d449f..ec0da0986e45 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt @@ -61,9 +61,7 @@ class CredentialSelectorActivity : ComponentActivity() { if (isCancellationRequest && !shouldShowCancellationUi) { return } - val userConfigRepo = UserConfigRepo(this) - val credManRepo = CredentialManagerRepo( - this, intent, userConfigRepo, isNewActivity = true) + val credManRepo = CredentialManagerRepo(this, intent, isNewActivity = true) val backPressedCallback = object : OnBackPressedCallback( true // default to enabled @@ -78,10 +76,7 @@ class CredentialSelectorActivity : ComponentActivity() { setContent { PlatformTheme { - CredentialManagerBottomSheet( - credManRepo, - userConfigRepo - ) + CredentialManagerBottomSheet(credManRepo) } } } catch (e: Exception) { @@ -103,9 +98,7 @@ class CredentialSelectorActivity : ComponentActivity() { return } } else { - val userConfigRepo = UserConfigRepo(this) - val credManRepo = CredentialManagerRepo( - this, intent, userConfigRepo, isNewActivity = false) + val credManRepo = CredentialManagerRepo(this, intent, isNewActivity = false) viewModel.onNewCredentialManagerRepo(credManRepo) } } catch (e: Exception) { @@ -147,10 +140,9 @@ class CredentialSelectorActivity : ComponentActivity() { @Composable private fun CredentialManagerBottomSheet( credManRepo: CredentialManagerRepo, - userConfigRepo: UserConfigRepo, ) { val viewModel: CredentialSelectorViewModel = viewModel { - CredentialSelectorViewModel(credManRepo, userConfigRepo) + CredentialSelectorViewModel(credManRepo) } val launcher = rememberLauncherForActivityResult( StartBalIntentSenderForResultContract() diff --git a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt index f4da1e6c4770..1f2fa200e43d 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt @@ -34,7 +34,6 @@ import com.android.credentialmanager.common.DialogState import com.android.credentialmanager.common.ProviderActivityResult import com.android.credentialmanager.common.ProviderActivityState import com.android.credentialmanager.createflow.ActiveEntry -import com.android.credentialmanager.createflow.isFlowAutoSelectable import com.android.credentialmanager.createflow.CreateCredentialUiState import com.android.credentialmanager.createflow.CreateScreenState import com.android.credentialmanager.getflow.GetCredentialUiState @@ -63,7 +62,6 @@ data class CancelUiRequestState( class CredentialSelectorViewModel( private var credManRepo: CredentialManagerRepo, - private val userConfigRepo: UserConfigRepo, ) : ViewModel() { var uiState by mutableStateOf(credManRepo.initState()) private set @@ -266,42 +264,6 @@ class CredentialSelectorViewModel( /**************************************************************************/ /***** Create Flow Callbacks *****/ /**************************************************************************/ - fun createFlowOnConfirmIntro() { - userConfigRepo.setIsPasskeyFirstUse(false) - val prevUiState = uiState.createCredentialUiState - if (prevUiState == null) { - Log.d(Constants.LOG_TAG, "Encountered unexpected null create ui state") - onInternalError() - return - } - val newScreenState = CreateFlowUtils.toCreateScreenState( - createOptionSize = prevUiState.sortedCreateOptionsPairs.size, - isOnPasskeyIntroStateAlready = true, - requestDisplayInfo = prevUiState.requestDisplayInfo, - remoteEntry = prevUiState.remoteEntry, - isPasskeyFirstUse = true, - ) - if (newScreenState == null) { - Log.d(Constants.LOG_TAG, "Unexpected: couldn't resolve new screen state") - onInternalError() - return - } - val newCreateCredentialUiState = prevUiState.copy( - currentScreenState = newScreenState, - ) - val isFlowAutoSelectable = isFlowAutoSelectable(newCreateCredentialUiState) - uiState = uiState.copy( - createCredentialUiState = newCreateCredentialUiState, - isAutoSelectFlow = isFlowAutoSelectable, - providerActivityState = - if (isFlowAutoSelectable) ProviderActivityState.READY_TO_LAUNCH - else ProviderActivityState.NOT_APPLICABLE, - selectedEntry = - if (isFlowAutoSelectable) newCreateCredentialUiState.activeEntry?.activeEntryInfo - else null, - ) - } - fun createFlowOnMoreOptionsSelectedOnCreationSelection() { uiState = uiState.copy( createCredentialUiState = uiState.createCredentialUiState?.copy( @@ -318,14 +280,6 @@ class CredentialSelectorViewModel( ) } - fun createFlowOnBackPasskeyIntroButtonSelected() { - uiState = uiState.copy( - createCredentialUiState = uiState.createCredentialUiState?.copy( - currentScreenState = CreateScreenState.PASSKEY_INTRO, - ) - ) - } - fun createFlowOnEntrySelectedFromMoreOptionScreen(activeEntry: ActiveEntry) { uiState = uiState.copy( createCredentialUiState = uiState.createCredentialUiState?.copy( @@ -348,14 +302,6 @@ class CredentialSelectorViewModel( uiState = uiState.copy(dialogState = DialogState.CANCELED_FOR_SETTINGS) } - fun createFlowOnLearnMore() { - uiState = uiState.copy( - createCredentialUiState = uiState.createCredentialUiState?.copy( - currentScreenState = CreateScreenState.MORE_ABOUT_PASSKEYS_INTRO, - ) - ) - } - fun createFlowOnUseOnceSelected() { uiState = uiState.copy( createCredentialUiState = uiState.createCredentialUiState?.copy( diff --git a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt index 997c45e84180..5830b9fc1028 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt @@ -342,8 +342,6 @@ class CreateFlowUtils { defaultProviderIdPreferredByApp: String?, defaultProviderIdsSetByUser: Set<String>, requestDisplayInfo: RequestDisplayInfo, - isOnPasskeyIntroStateAlready: Boolean, - isPasskeyFirstUse: Boolean, ): CreateCredentialUiState? { var remoteEntry: RemoteInfo? = null var remoteEntryProvider: EnabledProviderInfo? = null @@ -392,11 +390,8 @@ class CreateFlowUtils { val defaultProvider = defaultProviderPreferredByApp ?: defaultProviderSetByUser val initialScreenState = toCreateScreenState( createOptionSize = createOptionsPairs.size, - isOnPasskeyIntroStateAlready = isOnPasskeyIntroStateAlready, - requestDisplayInfo = requestDisplayInfo, remoteEntry = remoteEntry, - isPasskeyFirstUse = isPasskeyFirstUse - ) ?: return null + ) val sortedCreateOptionsPairs = createOptionsPairs.sortedWith( compareByDescending { it.first.lastUsedTime } ) @@ -419,15 +414,9 @@ class CreateFlowUtils { fun toCreateScreenState( createOptionSize: Int, - isOnPasskeyIntroStateAlready: Boolean, - requestDisplayInfo: RequestDisplayInfo, remoteEntry: RemoteInfo?, - isPasskeyFirstUse: Boolean, - ): CreateScreenState? { - return if (isPasskeyFirstUse && requestDisplayInfo.type == CredentialType.PASSKEY && - !isOnPasskeyIntroStateAlready) { - CreateScreenState.PASSKEY_INTRO - } else if (createOptionSize == 0 && remoteEntry != null) { + ): CreateScreenState { + return if (createOptionSize == 0 && remoteEntry != null) { CreateScreenState.EXTERNAL_ONLY_SELECTION } else { CreateScreenState.CREATION_OPTION_SELECTION diff --git a/packages/CredentialManager/src/com/android/credentialmanager/UserConfigRepo.kt b/packages/CredentialManager/src/com/android/credentialmanager/UserConfigRepo.kt deleted file mode 100644 index bfcca4970a71..000000000000 --- a/packages/CredentialManager/src/com/android/credentialmanager/UserConfigRepo.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.credentialmanager - -import android.content.Context -import android.content.SharedPreferences - -class UserConfigRepo(context: Context) { - val sharedPreferences: SharedPreferences = context.getSharedPreferences( - context.packageName, Context.MODE_PRIVATE) - - fun setIsPasskeyFirstUse( - isFirstUse: Boolean - ) { - sharedPreferences.edit().apply { - putBoolean(IS_PASSKEY_FIRST_USE, isFirstUse) - apply() - } - } - - fun getIsPasskeyFirstUse(): Boolean { - return sharedPreferences.getBoolean(IS_PASSKEY_FIRST_USE, true) - } - - companion object { - // This first use value only applies to passkeys, not related with if generally - // credential manager is first use or not - const val IS_PASSKEY_FIRST_USE = "is_passkey_first_use" - } -} diff --git a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt index f261d1fa062d..d24adb567bc4 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt @@ -20,8 +20,6 @@ import android.text.TextUtils import androidx.activity.compose.ManagedActivityResultLauncher import androidx.activity.result.ActivityResult import androidx.activity.result.IntentSenderRequest -import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -36,12 +34,9 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.outlined.QrCodeScanner import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -63,10 +58,8 @@ import com.android.credentialmanager.common.ui.Entry import com.android.credentialmanager.common.ui.HeadlineIcon import com.android.credentialmanager.common.ui.LargeLabelTextOnSurfaceVariant import com.android.credentialmanager.common.ui.ModalBottomSheet -import com.android.credentialmanager.common.ui.MoreAboutPasskeySectionHeader import com.android.credentialmanager.common.ui.MoreOptionTopAppBar import com.android.credentialmanager.common.ui.SheetContainerCard -import com.android.credentialmanager.common.ui.PasskeyBenefitRow import com.android.credentialmanager.common.ui.HeadlineText import com.android.credentialmanager.logging.CreateCredentialEvent import com.android.credentialmanager.model.creation.CreateOptionInfo @@ -87,11 +80,6 @@ fun CreateCredentialScreen( when (viewModel.uiState.providerActivityState) { ProviderActivityState.NOT_APPLICABLE -> { when (createCredentialUiState.currentScreenState) { - CreateScreenState.PASSKEY_INTRO -> PasskeyIntroCard( - onConfirm = viewModel::createFlowOnConfirmIntro, - onLearnMore = viewModel::createFlowOnLearnMore, - onLog = { viewModel.logUiEvent(it) }, - ) CreateScreenState.CREATION_OPTION_SELECTION -> CreationSelectionCard( requestDisplayInfo = createCredentialUiState.requestDisplayInfo, enabledProviderList = createCredentialUiState.enabledProviders, @@ -144,11 +132,6 @@ fun CreateCredentialScreen( onConfirm = viewModel::createFlowOnConfirmEntrySelected, onLog = { viewModel.logUiEvent(it) }, ) - CreateScreenState.MORE_ABOUT_PASSKEYS_INTRO -> MoreAboutPasskeysIntroCard( - onBackPasskeyIntroButtonSelected = - viewModel::createFlowOnBackPasskeyIntroButtonSelected, - onLog = { viewModel.logUiEvent(it) }, - ) } } ProviderActivityState.READY_TO_LAUNCH -> { @@ -188,78 +171,6 @@ fun CreateCredentialScreen( } @Composable -fun PasskeyIntroCard( - onConfirm: () -> Unit, - onLearnMore: () -> Unit, - onLog: @Composable (UiEventEnum) -> Unit, -) { - SheetContainerCard { - item { - val onboardingImageResource = remember { - mutableStateOf(R.drawable.ic_passkeys_onboarding) - } - if (isSystemInDarkTheme()) { - onboardingImageResource.value = R.drawable.ic_passkeys_onboarding_dark - } else { - onboardingImageResource.value = R.drawable.ic_passkeys_onboarding - } - Row( - modifier = Modifier.wrapContentHeight().fillMaxWidth(), - horizontalArrangement = Arrangement.Center, - ) { - Image( - painter = painterResource(onboardingImageResource.value), - contentDescription = null, - modifier = Modifier.size(316.dp, 168.dp) - ) - } - } - item { Divider(thickness = 16.dp, color = Color.Transparent) } - item { HeadlineText(text = stringResource(R.string.passkey_creation_intro_title)) } - item { Divider(thickness = 16.dp, color = Color.Transparent) } - item { - PasskeyBenefitRow( - leadingIconPainter = painterResource(R.drawable.ic_passkeys_onboarding_password), - text = stringResource(R.string.passkey_creation_intro_body_password), - ) - } - item { Divider(thickness = 16.dp, color = Color.Transparent) } - item { - PasskeyBenefitRow( - leadingIconPainter = painterResource(R.drawable.ic_passkeys_onboarding_fingerprint), - text = stringResource(R.string.passkey_creation_intro_body_fingerprint), - ) - } - item { Divider(thickness = 16.dp, color = Color.Transparent) } - item { - PasskeyBenefitRow( - leadingIconPainter = painterResource(R.drawable.ic_passkeys_onboarding_device), - text = stringResource(R.string.passkey_creation_intro_body_device), - ) - } - item { Divider(thickness = 24.dp, color = Color.Transparent) } - - item { - CtaButtonRow( - leftButton = { - ActionButton( - stringResource(R.string.string_learn_more), - onClick = onLearnMore - ) - }, - rightButton = { - ConfirmButton( - stringResource(R.string.string_continue), - onClick = onConfirm - ) - }, - ) - } - } - onLog(CreateCredentialEvent.CREDMAN_CREATE_CRED_PASSKEY_INTRO) -} - -@Composable fun MoreOptionsSelectionCard( requestDisplayInfo: RequestDisplayInfo, enabledProviderList: List<EnabledProviderInfo>, @@ -522,59 +433,6 @@ fun ExternalOnlySelectionCard( } @Composable -fun MoreAboutPasskeysIntroCard( - onBackPasskeyIntroButtonSelected: () -> Unit, - onLog: @Composable (UiEventEnum) -> Unit, -) { - SheetContainerCard( - topAppBar = { - MoreOptionTopAppBar( - text = stringResource(R.string.more_about_passkeys_title), - onNavigationIconClicked = onBackPasskeyIntroButtonSelected, - bottomPadding = 0.dp, - ) - }, - ) { - item { - MoreAboutPasskeySectionHeader( - text = stringResource(R.string.passwordless_technology_title) - ) - Row(modifier = Modifier.fillMaxWidth().wrapContentHeight()) { - BodyMediumText(text = stringResource(R.string.passwordless_technology_detail)) - } - } - item { - Divider(thickness = 8.dp, color = Color.Transparent) - MoreAboutPasskeySectionHeader( - text = stringResource(R.string.public_key_cryptography_title) - ) - Row(modifier = Modifier.fillMaxWidth().wrapContentHeight()) { - BodyMediumText(text = stringResource(R.string.public_key_cryptography_detail)) - } - } - item { - Divider(thickness = 8.dp, color = Color.Transparent) - MoreAboutPasskeySectionHeader( - text = stringResource(R.string.improved_account_security_title) - ) - Row(modifier = Modifier.fillMaxWidth().wrapContentHeight()) { - BodyMediumText(text = stringResource(R.string.improved_account_security_detail)) - } - } - item { - Divider(thickness = 8.dp, color = Color.Transparent) - MoreAboutPasskeySectionHeader( - text = stringResource(R.string.seamless_transition_title) - ) - Row(modifier = Modifier.fillMaxWidth().wrapContentHeight()) { - BodyMediumText(text = stringResource(R.string.seamless_transition_detail)) - } - } - } - onLog(CreateCredentialEvent.CREDMAN_CREATE_CRED_MORE_ABOUT_PASSKEYS_INTRO) -} - -@Composable fun PrimaryCreateOptionRow( requestDisplayInfo: RequestDisplayInfo, entryInfo: EntryInfo, diff --git a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt index 8b0ba87fa9be..617a981fc4ba 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt @@ -37,10 +37,6 @@ internal fun isFlowAutoSelectable( uiState: CreateCredentialUiState ): Boolean { return uiState.requestDisplayInfo.isAutoSelectRequest && - // Even if the flow is auto selectable, still allow passkey intro screen to show once if - // applicable. - uiState.currentScreenState != CreateScreenState.PASSKEY_INTRO && - uiState.currentScreenState != CreateScreenState.MORE_ABOUT_PASSKEYS_INTRO && uiState.sortedCreateOptionsPairs.size == 1 && uiState.activeEntry?.activeEntryInfo?.let { it is CreateOptionInfo && it.allowAutoSelect @@ -98,8 +94,6 @@ data class ActiveEntry ( /** The name of the current screen. */ enum class CreateScreenState { - PASSKEY_INTRO, - MORE_ABOUT_PASSKEYS_INTRO, CREATION_OPTION_SELECTION, MORE_OPTIONS_SELECTION, DEFAULT_PROVIDER_CONFIRMATION, |