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

Commit 60ab53a0 authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Add logging for media click intent and location

Log events when
- User taps on media control
- Carousel changes location (qs, qqs, lockscreen, dream overlay)

Test: atest MediaControlPanelTest MediaCarouselControllerTest
Change-Id: Ie564622cbf08af4375ec9262566b08b05a4a8d24
parent da5263eb
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -690,6 +690,11 @@ class MediaCarouselController @Inject constructor(
        startDelay: Long = 0
    ) {
        desiredHostState?.let {
            if (this.desiredLocation != desiredLocation) {
                // Only log an event when location changes
                logger.logCarouselPosition(desiredLocation)
            }

            // This is a hosting view, let's remeasure our players
            this.desiredLocation = desiredLocation
            this.desiredHostState = it
+1 −1
Original line number Diff line number Diff line
@@ -333,7 +333,7 @@ public class MediaControlPanel {
            mMediaViewHolder.getPlayer().setOnClickListener(v -> {
                if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
                if (mMediaViewController.isGutsVisible()) return;

                mLogger.logTapContentView(mUid, mPackageName, mInstanceId);
                logSmartspaceCardReported(SMARTSPACE_CARD_CLICK_EVENT);
                mActivityStarter.postStartActivityDismissingKeyguard(clickIntent,
                        buildLaunchAnimatorController(mMediaViewHolder.getPlayer()));
+5 −2
Original line number Diff line number Diff line
@@ -1146,7 +1146,10 @@ private val EMPTY_RECT = Rect()
@Retention(AnnotationRetention.SOURCE)
private annotation class TransformationType

@IntDef(prefix = ["LOCATION_"], value = [MediaHierarchyManager.LOCATION_QS,
    MediaHierarchyManager.LOCATION_QQS, MediaHierarchyManager.LOCATION_LOCKSCREEN])
@IntDef(prefix = ["LOCATION_"], value = [
    MediaHierarchyManager.LOCATION_QS,
    MediaHierarchyManager.LOCATION_QQS,
    MediaHierarchyManager.LOCATION_LOCKSCREEN,
    MediaHierarchyManager.LOCATION_DREAM_OVERLAY])
@Retention(AnnotationRetention.SOURCE)
annotation class MediaLocation
+33 −1
Original line number Diff line number Diff line
@@ -134,6 +134,23 @@ class MediaUiEventLogger @Inject constructor(private val logger: UiEventLogger)
    fun logOpenOutputSwitcher(uid: Int, packageName: String, instanceId: InstanceId) {
        logger.logWithInstanceId(MediaUiEvent.OPEN_OUTPUT_SWITCHER, uid, packageName, instanceId)
    }

    fun logTapContentView(uid: Int, packageName: String, instanceId: InstanceId) {
        logger.logWithInstanceId(MediaUiEvent.MEDIA_TAP_CONTENT_VIEW, uid, packageName, instanceId)
    }

    fun logCarouselPosition(@MediaLocation location: Int) {
        val event = when (location) {
            MediaHierarchyManager.LOCATION_QQS -> MediaUiEvent.MEDIA_CAROUSEL_LOCATION_QQS
            MediaHierarchyManager.LOCATION_QS -> MediaUiEvent.MEDIA_CAROUSEL_LOCATION_QS
            MediaHierarchyManager.LOCATION_LOCKSCREEN ->
                MediaUiEvent.MEDIA_CAROUSEL_LOCATION_LOCKSCREEN
            MediaHierarchyManager.LOCATION_DREAM_OVERLAY ->
                MediaUiEvent.MEDIA_CAROUSEL_LOCATION_DREAM
            else -> throw IllegalArgumentException("Unknown media carousel location $location")
        }
        logger.log(event)
    }
}

enum class MediaUiEvent(val metricId: Int) : UiEventLogger.UiEventEnum {
@@ -201,7 +218,22 @@ enum class MediaUiEvent(val metricId: Int) : UiEventLogger.UiEventEnum {
    ACTION_SEEK(1027),

    @UiEvent(doc = "The user opened the output switcher from a media control")
    OPEN_OUTPUT_SWITCHER(1028);
    OPEN_OUTPUT_SWITCHER(1028),

    @UiEvent(doc = "The user tapped on a media control view")
    MEDIA_TAP_CONTENT_VIEW(1036),

    @UiEvent(doc = "The media carousel moved to QQS")
    MEDIA_CAROUSEL_LOCATION_QQS(1037),

    @UiEvent(doc = "THe media carousel moved to QS")
    MEDIA_CAROUSEL_LOCATION_QS(1038),

    @UiEvent(doc = "The media carousel moved to the lockscreen")
    MEDIA_CAROUSEL_LOCATION_LOCKSCREEN(1039),

    @UiEvent(doc = "The media carousel moved to the dream state")
    MEDIA_CAROUSEL_LOCATION_DREAM(1040);

    override fun getId() = metricId
}
 No newline at end of file
+37 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ class MediaCarouselControllerTest : SysuiTestCase() {
    @Mock lateinit var panel: MediaControlPanel
    @Mock lateinit var visualStabilityProvider: VisualStabilityProvider
    @Mock lateinit var mediaHostStatesManager: MediaHostStatesManager
    @Mock lateinit var mediaHostState: MediaHostState
    @Mock lateinit var activityStarter: ActivityStarter
    @Mock @Main private lateinit var executor: DelayableExecutor
    @Mock lateinit var mediaDataManager: MediaDataManager
@@ -188,4 +189,40 @@ class MediaCarouselControllerTest : SysuiTestCase() {

        verify(logger).logCarouselSettings()
    }

    @Test
    fun testLocationChangeQs_logged() {
        mediaCarouselController.onDesiredLocationChanged(
            MediaHierarchyManager.LOCATION_QS,
            mediaHostState,
            animate = false)
        verify(logger).logCarouselPosition(MediaHierarchyManager.LOCATION_QS)
    }

    @Test
    fun testLocationChangeQqs_logged() {
        mediaCarouselController.onDesiredLocationChanged(
            MediaHierarchyManager.LOCATION_QQS,
            mediaHostState,
            animate = false)
        verify(logger).logCarouselPosition(MediaHierarchyManager.LOCATION_QQS)
    }

    @Test
    fun testLocationChangeLockscreen_logged() {
        mediaCarouselController.onDesiredLocationChanged(
            MediaHierarchyManager.LOCATION_LOCKSCREEN,
            mediaHostState,
            animate = false)
        verify(logger).logCarouselPosition(MediaHierarchyManager.LOCATION_LOCKSCREEN)
    }

    @Test
    fun testLocationChangeDream_logged() {
        mediaCarouselController.onDesiredLocationChanged(
            MediaHierarchyManager.LOCATION_DREAM_OVERLAY,
            mediaHostState,
            animate = false)
        verify(logger).logCarouselPosition(MediaHierarchyManager.LOCATION_DREAM_OVERLAY)
    }
}
 No newline at end of file
Loading