summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt10
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/logging/LifecycleEvent.kt37
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/logging/UIMetrics.kt4
3 files changed, 51 insertions, 0 deletions
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt
index e7de8b3f128c..e49e3f165cfc 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt
@@ -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)
}
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/logging/LifecycleEvent.kt b/packages/CredentialManager/src/com/android/credentialmanager/logging/LifecycleEvent.kt
new file mode 100644
index 000000000000..1ede64df89b8
--- /dev/null
+++ b/packages/CredentialManager/src/com/android/credentialmanager/logging/LifecycleEvent.kt
@@ -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
+ }
+} \ No newline at end of file
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/logging/UIMetrics.kt b/packages/CredentialManager/src/com/android/credentialmanager/logging/UIMetrics.kt
index 4351e8406790..035c1e4bc6c6 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/logging/UIMetrics.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/logging/UIMetrics.kt
@@ -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)
+ }
}