summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorTest.kt25
-rw-r--r--packages/SystemUI/src/com/android/systemui/education/ContextualEducationMetricsLogger.kt49
-rw-r--r--packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractor.kt6
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt7
4 files changed, 83 insertions, 4 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorTest.kt
index e7d2ef10b4ee..21679f960198 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorTest.kt
@@ -187,7 +187,7 @@ class KeyboardTouchpadEduInteractorTest(private val gestureType: GestureType) :
signalCount = 1,
usageSessionStartTime = secondSignalReceivedTime,
userId = 0,
- gestureType = gestureType
+ gestureType = gestureType,
)
)
}
@@ -402,6 +402,29 @@ class KeyboardTouchpadEduInteractorTest(private val gestureType: GestureType) :
eduClock.offset(initialDelayElapsedDuration)
}
+ fun logMetricsForToastEducation() =
+ testScope.runTest {
+ triggerMaxEducationSignals(gestureType)
+ runCurrent()
+
+ verify(kosmos.mockEduMetricsLogger)
+ .logContextualEducationTriggered(gestureType, EducationUiType.Toast)
+ }
+
+ @Test
+ fun logMetricsForNotificationEducation() =
+ testScope.runTest {
+ triggerMaxEducationSignals(gestureType)
+ runCurrent()
+
+ eduClock.offset(minDurationForNextEdu)
+ triggerMaxEducationSignals(gestureType)
+ runCurrent()
+
+ verify(kosmos.mockEduMetricsLogger)
+ .logContextualEducationTriggered(gestureType, EducationUiType.Notification)
+ }
+
@After
fun clear() {
testScope.launch { tutorialSchedulerRepository.clearDataStore() }
diff --git a/packages/SystemUI/src/com/android/systemui/education/ContextualEducationMetricsLogger.kt b/packages/SystemUI/src/com/android/systemui/education/ContextualEducationMetricsLogger.kt
new file mode 100644
index 000000000000..9af259a9b642
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/education/ContextualEducationMetricsLogger.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2024 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.systemui.education
+
+import com.android.systemui.contextualeducation.GestureType
+import com.android.systemui.education.shared.model.EducationUiType
+import com.android.systemui.shared.system.SysUiStatsLog
+import javax.inject.Inject
+
+class ContextualEducationMetricsLogger @Inject constructor() {
+ fun logContextualEducationTriggered(gestureType: GestureType, uiType: EducationUiType) {
+ val statsGestureType =
+ when (gestureType) {
+ GestureType.BACK -> SysUiStatsLog.CONTEXTUAL_EDUCATION_TRIGGERED__GESTURE_TYPE__BACK
+ GestureType.HOME -> SysUiStatsLog.CONTEXTUAL_EDUCATION_TRIGGERED__GESTURE_TYPE__HOME
+ GestureType.OVERVIEW ->
+ SysUiStatsLog.CONTEXTUAL_EDUCATION_TRIGGERED__GESTURE_TYPE__OVERVIEW
+ GestureType.ALL_APPS ->
+ SysUiStatsLog.CONTEXTUAL_EDUCATION_TRIGGERED__GESTURE_TYPE__ALL_APPS
+ }
+
+ val statsEducationType =
+ when (uiType) {
+ EducationUiType.Toast ->
+ SysUiStatsLog.CONTEXTUAL_EDUCATION_TRIGGERED__EDUCATION_TYPE__TOAST
+ EducationUiType.Notification ->
+ SysUiStatsLog.CONTEXTUAL_EDUCATION_TRIGGERED__EDUCATION_TYPE__NOTIFICATION
+ }
+ SysUiStatsLog.write(
+ SysUiStatsLog.CONTEXTUAL_EDUCATION_TRIGGERED,
+ statsGestureType,
+ statsEducationType,
+ )
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractor.kt b/packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractor.kt
index c17f3fb6dfe4..00da5b1e01ce 100644
--- a/packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractor.kt
@@ -23,6 +23,7 @@ import com.android.systemui.contextualeducation.GestureType
import com.android.systemui.contextualeducation.GestureType.ALL_APPS
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.education.ContextualEducationMetricsLogger
import com.android.systemui.education.dagger.ContextualEducationModule.EduClock
import com.android.systemui.education.data.model.GestureEduModel
import com.android.systemui.education.shared.model.EducationInfo
@@ -62,6 +63,7 @@ constructor(
private val userInputDeviceRepository: UserInputDeviceRepository,
private val tutorialRepository: TutorialSchedulerRepository,
private val overviewProxyService: OverviewProxyService,
+ private val metricsLogger: ContextualEducationMetricsLogger,
@EduClock private val clock: Clock,
) : CoreStartable {
@@ -129,9 +131,11 @@ constructor(
if (isUsageSessionExpired(it)) {
contextualEducationInteractor.startNewUsageSession(it.gestureType)
} else if (isEducationNeeded(it)) {
+ val educationType = getEduType(it)
_educationTriggered.value =
- EducationInfo(it.gestureType, getEduType(it), it.userId)
+ EducationInfo(it.gestureType, educationType, it.userId)
contextualEducationInteractor.updateOnEduTriggered(it.gestureType)
+ metricsLogger.logContextualEducationTriggered(it.gestureType, educationType)
}
}
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt
index 3fd2503096b5..93e7f2e588b0 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt
@@ -17,6 +17,7 @@
package com.android.systemui.education.domain.interactor
import android.hardware.input.InputManager
+import com.android.systemui.education.ContextualEducationMetricsLogger
import com.android.systemui.education.data.repository.fakeEduClock
import com.android.systemui.inputdevice.data.repository.UserInputDeviceRepository
import com.android.systemui.inputdevice.tutorial.tutorialSchedulerRepository
@@ -41,11 +42,13 @@ var Kosmos.keyboardTouchpadEduInteractor by
touchpadRepository,
userRepository,
),
- tutorialSchedulerRepository,
- mockOverviewProxyService,
+ tutorialRepository = tutorialSchedulerRepository,
+ overviewProxyService = mockOverviewProxyService,
+ metricsLogger = mockEduMetricsLogger,
clock = fakeEduClock,
)
}
+var Kosmos.mockEduMetricsLogger by Kosmos.Fixture { mock<ContextualEducationMetricsLogger>() }
var Kosmos.mockOverviewProxyService by Kosmos.Fixture { mock<OverviewProxyService>() }
var Kosmos.mockEduInputManager by Kosmos.Fixture { mock<InputManager>() }