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

Commit bf00a319 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add go/aster logging to GetCredentialComponents" into udc-dev am: 63781b4e

parents 42ede23f 63781b4e
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -171,9 +171,6 @@ fun CreateCredentialScreen(
                                onLog = { viewModel.logUiEvent(it) },
                        )
                    }
                    viewModel.uiMetrics.log(
                            CreateCredentialEvent
                                    .CREDMAN_CREATE_CRED_PROVIDER_ACTIVITY_NOT_APPLICABLE)
                }
                ProviderActivityState.READY_TO_LAUNCH -> {
                    // Launch only once per providerActivityState change so that the provider
+25 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ import com.android.credentialmanager.common.ui.CredentialListSectionHeader
import com.android.credentialmanager.common.ui.Snackbar
import com.android.credentialmanager.common.ui.setTransparentSystemBarsColor
import com.android.credentialmanager.common.ui.setBottomSheetSystemBarsColor
import com.android.credentialmanager.logging.GetCredentialEvent
import com.android.internal.logging.UiEventLogger.UiEventEnum

@Composable
fun GetCredentialScreen(
@@ -75,7 +77,9 @@ fun GetCredentialScreen(
        RemoteCredentialSnackBarScreen(
            onClick = viewModel::getFlowOnMoreOptionOnSnackBarSelected,
            onCancel = viewModel::onUserCancel,
            onLog = { viewModel.logUiEvent(it) },
        )
        viewModel.uiMetrics.log(GetCredentialEvent.CREDMAN_GET_CRED_SCREEN_REMOTE_ONLY)
    } else if (getCredentialUiState.currentScreenState
        == GetScreenState.UNLOCKED_AUTH_ENTRIES_ONLY) {
        setTransparentSystemBarsColor(sysUiController)
@@ -84,7 +88,10 @@ fun GetCredentialScreen(
            getCredentialUiState.providerDisplayInfo.authenticationEntryList,
            onCancel = viewModel::silentlyFinishActivity,
            onLastLockedAuthEntryNotFound = viewModel::onLastLockedAuthEntryNotFoundError,
            onLog = { viewModel.logUiEvent(it) },
        )
        viewModel.uiMetrics.log(GetCredentialEvent
                .CREDMAN_GET_CRED_SCREEN_UNLOCKED_AUTH_ENTRIES_ONLY)
    } else {
        setBottomSheetSystemBarsColor(sysUiController)
        ModalBottomSheet(
@@ -104,7 +111,10 @@ fun GetCredentialScreen(
                                onEntrySelected = viewModel::getFlowOnEntrySelected,
                                onConfirm = viewModel::getFlowOnConfirmEntrySelected,
                                onMoreOptionSelected = viewModel::getFlowOnMoreOptionSelected,
                                onLog = { viewModel.logUiEvent(it) },
                            )
                            viewModel.uiMetrics.log(GetCredentialEvent
                                    .CREDMAN_GET_CRED_SCREEN_PRIMARY_SELECTION)
                        } else {
                            AllSignInOptionCard(
                                providerInfoList = getCredentialUiState.providerInfoList,
@@ -114,7 +124,10 @@ fun GetCredentialScreen(
                                viewModel::getFlowOnBackToPrimarySelectionScreen,
                                onCancel = viewModel::onUserCancel,
                                isNoAccount = getCredentialUiState.isNoAccount,
                                onLog = { viewModel.logUiEvent(it) },
                            )
                            viewModel.uiMetrics.log(GetCredentialEvent
                                    .CREDMAN_GET_CRED_SCREEN_ALL_SIGN_IN_OPTIONS)
                        }
                    }
                    ProviderActivityState.READY_TO_LAUNCH -> {
@@ -123,9 +136,13 @@ fun GetCredentialScreen(
                        LaunchedEffect(viewModel.uiState.providerActivityState) {
                            viewModel.launchProviderUi(providerActivityLauncher)
                        }
                        viewModel.uiMetrics.log(GetCredentialEvent
                                .CREDMAN_GET_CRED_PROVIDER_ACTIVITY_READY_TO_LAUNCH)
                    }
                    ProviderActivityState.PENDING -> {
                        // Hide our content when the provider activity is active.
                        viewModel.uiMetrics.log(GetCredentialEvent
                                .CREDMAN_GET_CRED_PROVIDER_ACTIVITY_PENDING)
                    }
                }
            },
@@ -144,6 +161,7 @@ fun PrimarySelectionCard(
    onEntrySelected: (BaseEntry) -> Unit,
    onConfirm: () -> Unit,
    onMoreOptionSelected: () -> Unit,
    onLog: @Composable (UiEventEnum) -> Unit,
) {
    val sortedUserNameToCredentialEntryList =
        providerDisplayInfo.sortedUserNameToCredentialEntryList
@@ -248,6 +266,7 @@ fun PrimarySelectionCard(
            )
        }
    }
    onLog(GetCredentialEvent.CREDMAN_GET_CRED_PRIMARY_SELECTION_CARD)
}

/** Draws the secondary credential selection page, where all sign-in options are listed. */
@@ -259,6 +278,7 @@ fun AllSignInOptionCard(
    onBackButtonClicked: () -> Unit,
    onCancel: () -> Unit,
    isNoAccount: Boolean,
    onLog: @Composable (UiEventEnum) -> Unit,
) {
    val sortedUserNameToCredentialEntryList =
        providerDisplayInfo.sortedUserNameToCredentialEntryList
@@ -303,6 +323,7 @@ fun AllSignInOptionCard(
            )
        }
    }
    onLog(GetCredentialEvent.CREDMAN_GET_CRED_ALL_SIGN_IN_OPTION_CARD)
}

// TODO: create separate rows for primary and secondary pages.
@@ -466,6 +487,7 @@ fun ActionEntryRow(
fun RemoteCredentialSnackBarScreen(
    onClick: (Boolean) -> Unit,
    onCancel: () -> Unit,
    onLog: @Composable (UiEventEnum) -> Unit,
) {
    Snackbar(
        action = {
@@ -482,6 +504,7 @@ fun RemoteCredentialSnackBarScreen(
        onDismiss = onCancel,
        contentText = stringResource(R.string.get_dialog_use_saved_passkey_for),
    )
    onLog(GetCredentialEvent.CREDMAN_GET_CRED_REMOTE_CRED_SNACKBAR_SCREEN)
}

@Composable
@@ -489,6 +512,7 @@ fun EmptyAuthEntrySnackBarScreen(
    authenticationEntryList: List<AuthenticationEntryInfo>,
    onCancel: () -> Unit,
    onLastLockedAuthEntryNotFound: () -> Unit,
    onLog: @Composable (UiEventEnum) -> Unit,
) {
    val lastLocked = authenticationEntryList.firstOrNull({ it.isLastUnlocked })
    if (lastLocked == null) {
@@ -500,4 +524,5 @@ fun EmptyAuthEntrySnackBarScreen(
        onDismiss = onCancel,
        contentText = stringResource(R.string.no_sign_in_info_in, lastLocked.providerDisplayName),
    )
    onLog(GetCredentialEvent.CREDMAN_GET_CRED_SCREEN_EMPTY_AUTH_SNACKBAR_SCREEN)
}
 No newline at end of file
+62 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.logging

import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger

enum class GetCredentialEvent(private val id: Int) : UiEventLogger.UiEventEnum {

    @UiEvent(doc = "The The snackbar only page when there's no account but only a remoteEntry " +
            "visible on the screen.")
    CREDMAN_GET_CRED_SCREEN_REMOTE_ONLY(1332),

    @UiEvent(doc = "The snackbar when there are only auth entries and all of them are empty.")
    CREDMAN_GET_CRED_SCREEN_UNLOCKED_AUTH_ENTRIES_ONLY(1333),

    @UiEvent(doc = "The primary credential selection page is displayed on screen.")
    CREDMAN_GET_CRED_SCREEN_PRIMARY_SELECTION(1334),

    @UiEvent(doc = "The secondary credential selection page, where all sign-in options are " +
            "listed is displayed on the screen.")
    CREDMAN_GET_CRED_SCREEN_ALL_SIGN_IN_OPTIONS(1335),

    @UiEvent(doc = "The provider activity is not active nor is any ready for launch on the screen.")
    CREDMAN_GET_CRED_PROVIDER_ACTIVITY_NOT_APPLICABLE(1336),

    @UiEvent(doc = "The provider activity is ready to be launched on the screen.")
    CREDMAN_GET_CRED_PROVIDER_ACTIVITY_READY_TO_LAUNCH(1337),

    @UiEvent(doc = "The provider activity is launched and we are waiting for its result. " +
            "Contents Hidden.")
    CREDMAN_GET_CRED_PROVIDER_ACTIVITY_PENDING(1338),

    @UiEvent(doc = "The remote credential snackbar screen is visible.")
    CREDMAN_GET_CRED_REMOTE_CRED_SNACKBAR_SCREEN(1339),

    @UiEvent(doc = "The empty auth snackbar screen is visible.")
    CREDMAN_GET_CRED_SCREEN_EMPTY_AUTH_SNACKBAR_SCREEN(1340),

    @UiEvent(doc = "The primary selection card is visible on screen.")
    CREDMAN_GET_CRED_PRIMARY_SELECTION_CARD(1341),

    @UiEvent(doc = "The all sign in option card is visible on screen.")
    CREDMAN_GET_CRED_ALL_SIGN_IN_OPTION_CARD(1342);

    override fun getId(): Int {
        return this.id
    }
}
 No newline at end of file