Loading packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +1 −1 Original line number Diff line number Diff line Loading @@ -262,7 +262,7 @@ public class LogModule { @SysUISingleton @MediaCarouselControllerLog public static LogBuffer provideMediaCarouselControllerBuffer(LogBufferFactory factory) { return factory.create("MediaCarouselCtlrLog", 100); return factory.create("MediaCarouselCtlrLog", 150); } /** Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt +13 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.util.Utils import com.android.systemui.util.animation.UniqueObjectHostView import com.android.systemui.util.animation.requiresRemeasuring import com.android.systemui.util.boundsOnScreen import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.settings.GlobalSettings import com.android.systemui.util.settings.SecureSettings Loading Loading @@ -339,6 +340,9 @@ constructor( .isInTransition(Edge.create(to = DOZING)) .stateIn(applicationScope, SharingStarted.Eagerly, true) private var mediaFrameHeight: Int = 0 private var mediaFrameWidth: Int = 0 init { // TODO(b/397989775): avoid unnecessary setup with media_controls_in_compose enabled dumpManager.registerNormalDumpable(TAG, this) Loading Loading @@ -381,6 +385,15 @@ constructor( setUpListeners() } mediaFrame.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> if (mediaFrameHeight != mediaFrame.height || mediaFrameWidth != mediaFrame.width) { mediaFrameHeight = mediaFrame.height mediaFrameWidth = mediaFrame.width debugLogger.logMediaBounds( reason = "layout change", rect = mediaFrame.boundsOnScreen, location = desiredLocation, ) } // The pageIndicator is not laid out yet when we get the current state update, // Lets make sure we have the right dimensions updatePageIndicatorLocation() Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerLogger.kt +15 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.media.controls.ui.controller import android.graphics.Rect import com.android.systemui.dagger.SysUISingleton import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.LogLevel Loading Loading @@ -80,6 +81,20 @@ constructor(@MediaCarouselControllerLog private val buffer: LogBuffer) { { "media host visibility changed location=$int1, visible:$bool1, was:$bool2" }, ) } fun logMediaBounds(reason: String, rect: Rect, location: Int) { buffer.log( TAG, LogLevel.DEBUG, { str1 = reason int1 = rect.width() int2 = rect.height() long1 = location.toLong() }, { "media frame($str1), width: $int1 height: $int2, location:$long1" }, ) } } private const val TAG = "MediaCarouselCtlrLog" packages/SystemUI/src/com/android/systemui/util/animation/UniqueObjectHostView.kt +20 −17 Original line number Diff line number Diff line Loading @@ -26,16 +26,12 @@ import com.android.systemui.res.R /** * A special view that is designed to host a single "unique object". The unique object is * dynamically added and removed from this view and may transition to other UniqueObjectHostViews * available in the system. * This is useful to share a singular instance of a view that can transition between completely * independent parts of the view hierarchy. * If the view currently hosts the unique object, it's measuring it normally, * but if it's not attached, it will obtain the size by requesting a measure, as if it were * always attached. * available in the system. This is useful to share a singular instance of a view that can * transition between completely independent parts of the view hierarchy. If the view currently * hosts the unique object, it's measuring it normally, but if it's not attached, it will obtain the * size by requesting a measure, as if it were always attached. */ class UniqueObjectHostView( context: Context ) : FrameLayout(context) { class UniqueObjectHostView(context: Context) : FrameLayout(context) { lateinit var measurementManager: MeasurementManager @SuppressLint("DrawAllocation") Loading @@ -55,7 +51,14 @@ class UniqueObjectHostView( if (isCurrentHost()) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) getChildAt(0)?.requiresRemeasuring = false getChildAt(0)?.let { mediaFrame -> // Media host dimensions are correct. Its child cannot show larger dimensions. // We also need to ensure that dimensions are not less than expected. if (cachedWidth > mediaFrame.width || cachedHeight > mediaFrame.height) { mediaFrame.layoutParams = LayoutParams(cachedWidth, cachedHeight) } mediaFrame.requiresRemeasuring = false } } // The goal here is that the view will always have a consistent measuring, regardless // if it's attached or not. Loading Loading @@ -87,10 +90,12 @@ class UniqueObjectHostView( val top = paddingTop val paddingHorizontal = paddingStart + paddingEnd val paddingVertical = paddingTop + paddingBottom child.layout(left, child.layout( left, top, left + measuredWidth - paddingHorizontal, top + measuredHeight - paddingVertical) top + measuredHeight - paddingVertical, ) } private fun isCurrentHost() = childCount != 0 Loading @@ -100,9 +105,7 @@ class UniqueObjectHostView( } } /** * Does this view require remeasuring currently outside of the regular measure flow? */ /** Does this view require remeasuring currently outside of the regular measure flow? */ var View.requiresRemeasuring: Boolean get() { val required = getTag(R.id.requires_remeasuring) Loading Loading
packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +1 −1 Original line number Diff line number Diff line Loading @@ -262,7 +262,7 @@ public class LogModule { @SysUISingleton @MediaCarouselControllerLog public static LogBuffer provideMediaCarouselControllerBuffer(LogBufferFactory factory) { return factory.create("MediaCarouselCtlrLog", 100); return factory.create("MediaCarouselCtlrLog", 150); } /** Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt +13 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.util.Utils import com.android.systemui.util.animation.UniqueObjectHostView import com.android.systemui.util.animation.requiresRemeasuring import com.android.systemui.util.boundsOnScreen import com.android.systemui.util.concurrency.DelayableExecutor import com.android.systemui.util.settings.GlobalSettings import com.android.systemui.util.settings.SecureSettings Loading Loading @@ -339,6 +340,9 @@ constructor( .isInTransition(Edge.create(to = DOZING)) .stateIn(applicationScope, SharingStarted.Eagerly, true) private var mediaFrameHeight: Int = 0 private var mediaFrameWidth: Int = 0 init { // TODO(b/397989775): avoid unnecessary setup with media_controls_in_compose enabled dumpManager.registerNormalDumpable(TAG, this) Loading Loading @@ -381,6 +385,15 @@ constructor( setUpListeners() } mediaFrame.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> if (mediaFrameHeight != mediaFrame.height || mediaFrameWidth != mediaFrame.width) { mediaFrameHeight = mediaFrame.height mediaFrameWidth = mediaFrame.width debugLogger.logMediaBounds( reason = "layout change", rect = mediaFrame.boundsOnScreen, location = desiredLocation, ) } // The pageIndicator is not laid out yet when we get the current state update, // Lets make sure we have the right dimensions updatePageIndicatorLocation() Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerLogger.kt +15 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.media.controls.ui.controller import android.graphics.Rect import com.android.systemui.dagger.SysUISingleton import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.LogLevel Loading Loading @@ -80,6 +81,20 @@ constructor(@MediaCarouselControllerLog private val buffer: LogBuffer) { { "media host visibility changed location=$int1, visible:$bool1, was:$bool2" }, ) } fun logMediaBounds(reason: String, rect: Rect, location: Int) { buffer.log( TAG, LogLevel.DEBUG, { str1 = reason int1 = rect.width() int2 = rect.height() long1 = location.toLong() }, { "media frame($str1), width: $int1 height: $int2, location:$long1" }, ) } } private const val TAG = "MediaCarouselCtlrLog"
packages/SystemUI/src/com/android/systemui/util/animation/UniqueObjectHostView.kt +20 −17 Original line number Diff line number Diff line Loading @@ -26,16 +26,12 @@ import com.android.systemui.res.R /** * A special view that is designed to host a single "unique object". The unique object is * dynamically added and removed from this view and may transition to other UniqueObjectHostViews * available in the system. * This is useful to share a singular instance of a view that can transition between completely * independent parts of the view hierarchy. * If the view currently hosts the unique object, it's measuring it normally, * but if it's not attached, it will obtain the size by requesting a measure, as if it were * always attached. * available in the system. This is useful to share a singular instance of a view that can * transition between completely independent parts of the view hierarchy. If the view currently * hosts the unique object, it's measuring it normally, but if it's not attached, it will obtain the * size by requesting a measure, as if it were always attached. */ class UniqueObjectHostView( context: Context ) : FrameLayout(context) { class UniqueObjectHostView(context: Context) : FrameLayout(context) { lateinit var measurementManager: MeasurementManager @SuppressLint("DrawAllocation") Loading @@ -55,7 +51,14 @@ class UniqueObjectHostView( if (isCurrentHost()) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) getChildAt(0)?.requiresRemeasuring = false getChildAt(0)?.let { mediaFrame -> // Media host dimensions are correct. Its child cannot show larger dimensions. // We also need to ensure that dimensions are not less than expected. if (cachedWidth > mediaFrame.width || cachedHeight > mediaFrame.height) { mediaFrame.layoutParams = LayoutParams(cachedWidth, cachedHeight) } mediaFrame.requiresRemeasuring = false } } // The goal here is that the view will always have a consistent measuring, regardless // if it's attached or not. Loading Loading @@ -87,10 +90,12 @@ class UniqueObjectHostView( val top = paddingTop val paddingHorizontal = paddingStart + paddingEnd val paddingVertical = paddingTop + paddingBottom child.layout(left, child.layout( left, top, left + measuredWidth - paddingHorizontal, top + measuredHeight - paddingVertical) top + measuredHeight - paddingVertical, ) } private fun isCurrentHost() = childCount != 0 Loading @@ -100,9 +105,7 @@ class UniqueObjectHostView( } } /** * Does this view require remeasuring currently outside of the regular measure flow? */ /** Does this view require remeasuring currently outside of the regular measure flow? */ var View.requiresRemeasuring: Boolean get() { val required = getTag(R.id.requires_remeasuring) Loading