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

Commit 6e44fbbf authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Update crossfade status when animation is canceled

And more media host state logging

Bug: 342175696
Test: build
Flag: EXEMPT bugfix
Change-Id: I584e3040c3debbc220791059b42356a7db291402
parent afeda299
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -314,6 +314,7 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
                + "    " + mockTileString + "\n"
                + "    " + mockTileViewString + "\n"
                + "  media bounds: null\n"
                + "  media visibility: false\n"
                + "  horizontal layout: false\n"
                + "  last orientation: 0\n"
                + "  mShouldUseSplitNotificationShade: false\n";
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ constructor(@MediaCarouselControllerLog private val buffer: LogBuffer) {
                bool1 = visible
                bool2 = oldState
            },
            { "media host visibility changed location=$location, visible:$visible, was:$oldState" },
            { "media host visibility changed location=$int1, visible:$bool1, was:$bool2" },
        )
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ constructor(
                        cancelled = true
                        animationPending = false
                        rootView?.removeCallbacks(startAnimation)
                        isCrossFadeAnimatorRunning = false
                    }

                    override fun onAnimationEnd(animation: Animator) {
@@ -768,6 +769,7 @@ constructor(
                if (!willFade || isCurrentlyInGuidedTransformation() || !animate) {
                    // if we're fading, we want the desired location / measurement only to change
                    // once fully faded. This is happening in the host attachment
                    logger.logMediaLocation("no fade", currentAttachmentLocation, desiredLocation)
                    mediaCarouselController.onDesiredLocationChanged(
                        desiredLocation,
                        host,
@@ -1188,8 +1190,8 @@ constructor(
                    // immediately
                    // when the desired location changes. This callback will update the measurement
                    // of the carousel, only once we've faded out at the old location and then
                    // reattach
                    // to fade it in at the new location.
                    // reattach to fade it in at the new location.
                    logger.logMediaLocation("crossfade", currentAttachmentLocation, newLocation)
                    mediaCarouselController.onDesiredLocationChanged(
                        newLocation,
                        getHost(newLocation),
@@ -1204,6 +1206,7 @@ constructor(
     * should remain in the previous location, while after the switch it should be at the desired
     * location.
     */
    @MediaLocation
    private fun resolveLocationForFading(): Int {
        if (isCrossFadeAnimatorRunning) {
            // When animating between two hosts with a fade, let's keep ourselves in the old
+23 −1
Original line number Diff line number Diff line
@@ -17,19 +17,24 @@
package com.android.systemui.media.controls.ui.controller

import com.android.app.tracing.traceSection
import com.android.systemui.Dumpable
import com.android.systemui.Flags.mediaControlsUmoInflationInBackground
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.media.controls.ui.view.MediaHostState
import com.android.systemui.util.animation.MeasurementOutput
import java.io.PrintWriter
import javax.inject.Inject

private val TAG = "MediaHostStatesManager"

/**
 * A class responsible for managing all media host states of the various host locations and
 * coordinating the heights among different players. This class can be used to get the most up to
 * date state for any location.
 */
@SysUISingleton
class MediaHostStatesManager @Inject constructor() {
class MediaHostStatesManager @Inject constructor(dumpManager: DumpManager) : Dumpable {

    private val callbacks: MutableSet<Callback> = mutableSetOf()
    private val controllers: MutableSet<MediaViewController> = mutableSetOf()
@@ -43,6 +48,10 @@ class MediaHostStatesManager @Inject constructor() {
    /** A map with all media states of all locations. */
    val mediaHostStates: MutableMap<Int, MediaHostState> = mutableMapOf()

    init {
        dumpManager.registerNormalDumpable(TAG, this)
    }

    /**
     * Notify that a media state for a given location has changed. Should only be called from Media
     * hosts themselves.
@@ -125,6 +134,19 @@ class MediaHostStatesManager @Inject constructor() {
        controllers.remove(controller)
    }

    override fun dump(pw: PrintWriter, args: Array<out String>) {
        pw.apply {
            println("Controllers: $controllers")
            println("Callbacks: $callbacks")
            for ((location, size) in carouselSizes) {
                println("Size $location: ${size.measuredWidth} x ${size.measuredHeight}")
            }
            for ((location, state) in mediaHostStates) {
                println("Host $location: visible ${state.visible}")
            }
        }
    }

    interface Callback {
        /**
         * Notify the callbacks that a media state for a host has changed, and that the
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ class MediaViewLogger @Inject constructor(@MediaViewLog private val buffer: LogB
                bool1 = shadeVisible
                bool2 = mediaVisible
            },
            { "User visibility shade: $shadeVisible media: $mediaVisible" },
            { "User visibility shade: $bool1 media: $bool2" },
        )
    }
}
Loading