Log credman activity lifecycle events using go/aster.

Bug: 272077114
Test: Local-Deployment
Change-Id: I34eb7e7337512d51364bcb60a7b56bf00f82b027
This commit is contained in:
Harsh Lal
2023-03-07 21:09:42 +00:00
parent 3bd6db2d18
commit e1008f6243
3 changed files with 51 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ import com.android.credentialmanager.createflow.CreateCredentialUiState
import com.android.credentialmanager.createflow.CreateScreenState
import com.android.credentialmanager.getflow.GetCredentialUiState
import com.android.credentialmanager.getflow.GetScreenState
import com.android.credentialmanager.logging.LifecycleEvent
import com.android.credentialmanager.logging.UIMetrics
import com.android.internal.logging.UiEventLogger.UiEventEnum
@@ -61,6 +62,11 @@ class CredentialSelectorViewModel(
var uiMetrics: UIMetrics = UIMetrics()
init{
uiMetrics.logNormal(LifecycleEvent.CREDMAN_ACTIVITY_INIT,
credManRepo.requestInfo.appPackageName)
}
/**************************************************************************/
/***** Shared Callbacks *****/
/**************************************************************************/
@@ -84,6 +90,8 @@ class CredentialSelectorViewModel(
if (this.credManRepo.requestInfo.token != credManRepo.requestInfo.token) {
this.uiMetrics.resetInstanceId()
this.uiMetrics.logNormal(LifecycleEvent.CREDMAN_ACTIVITY_NEW_REQUEST,
credManRepo.requestInfo.appPackageName)
}
}
@@ -156,6 +164,8 @@ class CredentialSelectorViewModel(
private fun onInternalError() {
Log.w(Constants.LOG_TAG, "UI closed due to illegal internal state")
this.uiMetrics.logNormal(LifecycleEvent.CREDMAN_ACTIVITY_INTERNAL_ERROR,
credManRepo.requestInfo.appPackageName)
credManRepo.onParsingFailureCancel()
uiState = uiState.copy(dialogState = DialogState.COMPLETE)
}

View File

@@ -0,0 +1,37 @@
/*
* 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.UiEventLogger.UiEventEnum.RESERVE_NEW_UI_EVENT_ID
import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
enum class LifecycleEvent(private val id: Int) : UiEventLogger.UiEventEnum {
@UiEvent(doc = "A new activity is initialized for processing the request.")
CREDMAN_ACTIVITY_INIT(1343),
@UiEvent(doc = "An existing activity received a new request to process.")
CREDMAN_ACTIVITY_NEW_REQUEST(1344),
@UiEvent(doc = "The UI closed due to illegal internal state.")
CREDMAN_ACTIVITY_INTERNAL_ERROR(1345);
override fun getId(): Int {
return this.id
}
}

View File

@@ -56,4 +56,8 @@ class UIMetrics() {
mUiEventLogger.logWithInstanceId(event, /*uid=*/0, packageName, instanceId)
}
}
fun logNormal(event: UiEventLogger.UiEventEnum, packageName: String) {
mUiEventLogger.logWithInstanceId(event, /*uid=*/0, packageName, mInstanceId)
}
}