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

Commit 4eddb3d5 authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "Additional host update check and logging" into main

parents 6c6f0d8d 53432b4c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -90,15 +90,16 @@ constructor(@MediaCarouselControllerLog private val buffer: LogBuffer) {

    fun logCarouselVisible() = buffer.log(TAG, LogLevel.DEBUG, {}, { "showing carousel" })

    fun logMediaHostVisibility(location: Int, visible: Boolean) {
    fun logMediaHostVisibility(location: Int, visible: Boolean, oldState: Boolean) {
        buffer.log(
            TAG,
            LogLevel.DEBUG,
            {
                int1 = location
                bool1 = visible
                bool2 = oldState
            },
            { "media host visibility changed location=$location, visible:$visible" },
            { "media host visibility changed location=$location, visible:$visible, was:$oldState" },
        )
    }
}
+6 −3
Original line number Diff line number Diff line
@@ -1129,10 +1129,11 @@ constructor(
        traceSection("MediaHierarchyManager#updateHostAttachment") {
            if (SceneContainerFlag.isEnabled) {
                // No need to manage transition states - just update the desired location directly
                logger.logMediaHostAttachment(desiredLocation)
                val host = getHost(desiredLocation)
                logger.logMediaHostAttachment(desiredLocation, host?.visible)
                mediaCarouselController.onDesiredLocationChanged(
                    desiredLocation = desiredLocation,
                    desiredHostState = getHost(desiredLocation),
                    desiredHostState = host,
                    animate = false,
                )
                return
@@ -1169,7 +1170,8 @@ constructor(
                    // that and directly set the mediaFrame's bounds within the premeasured host.
                    targetHost.addView(mediaFrame)
                }
                logger.logMediaHostAttachment(currentAttachmentLocation)
                val host = getHost(currentAttachmentLocation)
                logger.logMediaHostAttachment(currentAttachmentLocation, host?.visible)
                if (isCrossFadeAnimatorRunning) {
                    // When cross-fading with an animation, we only notify the media carousel of the
                    // location change, once the view is reattached to the new place and not
@@ -1313,6 +1315,7 @@ constructor(
                isHomeScreenShadeVisibleToUser() ||
                isGlanceableHubVisibleToUser()
        val mediaVisible = qsExpanded || hasActiveMediaOrRecommendation
        logger.logUserVisibilityChange(shadeVisible, mediaVisible)
        mediaCarouselController.mediaCarouselScrollHandler.visibleToUser =
            shadeVisible && mediaVisible
    }
+24 −4
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ class MediaViewLogger @Inject constructor(@MediaViewLog private val buffer: LogB
                int1 = width
                int2 = height
            },
            { "size ($str1): $int1 x $int2" }
            { "size ($str1): $int1 x $int2" },
        )
    }

@@ -49,11 +49,31 @@ class MediaViewLogger @Inject constructor(@MediaViewLog private val buffer: LogB
                int1 = startLocation
                int2 = endLocation
            },
            { "location ($str1): $int1 -> $int2" }
            { "location ($str1): $int1 -> $int2" },
        )
    }

    fun logMediaHostAttachment(host: Int) {
        buffer.log(TAG, LogLevel.DEBUG, { int1 = host }, { "Host (updateHostAttachment): $int1" })
    fun logMediaHostAttachment(host: Int, visible: Boolean?) {
        buffer.log(
            TAG,
            LogLevel.DEBUG,
            {
                int1 = host
                str1 = visible.toString()
            },
            { "Host (updateHostAttachment): $int1 visible $str1" },
        )
    }

    fun logUserVisibilityChange(shadeVisible: Boolean, mediaVisible: Boolean) {
        buffer.log(
            TAG,
            LogLevel.DEBUG,
            {
                bool1 = shadeVisible
                bool2 = mediaVisible
            },
            { "User visibility shade: $shadeVisible media: $mediaVisible" },
        )
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ class MediaHost(
     * the visibility has changed
     */
    fun updateViewVisibility() {
        val oldState = state.visible
        state.visible =
            if (mediaCarouselController.isLockedAndHidden()) {
                false
@@ -217,9 +218,9 @@ class MediaHost(
                mediaDataManager.hasAnyMediaOrRecommendation()
            }
        val newVisibility = if (visible) View.VISIBLE else View.GONE
        if (newVisibility != hostView.visibility) {
        if (oldState != state.visible || newVisibility != hostView.visibility) {
            hostView.visibility = newVisibility
            debugLogger.logMediaHostVisibility(location, visible)
            debugLogger.logMediaHostVisibility(location, visible, oldState)
            visibleChangedListeners.forEach { it.invoke(visible) }
        }
    }