Loading packages/SystemUI/aconfig/systemui.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -1312,6 +1312,16 @@ flag { } } flag { name:"media_frame_dimensions_fix" namespace: "systemui" description: "measure and layout media frame when the desired location of media carousel changes" bug: "417204970" metadata { purpose: PURPOSE_BUGFIX } } flag { namespace: "systemui" name: "enable_view_capture_tracing" Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt +30 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback import com.android.systemui.Dumpable import com.android.systemui.Flags import com.android.systemui.Flags.enableSuggestedDeviceUi import com.android.systemui.Flags.mediaFrameDimensionsFix import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background Loading Loading @@ -1261,13 +1262,40 @@ constructor( // Let's remeasure the carousel val widthSpec = desiredHostState?.measurementInput?.widthMeasureSpec ?: 0 val heightSpec = desiredHostState?.measurementInput?.heightMeasureSpec ?: 0 mediaCarousel.measure(widthSpec, heightSpec) mediaCarousel.layout(0, 0, width, mediaCarousel.measuredHeight) mediaCarousel.measureAndLayout( widthSpec, heightSpec, width, mediaCarousel.measuredHeight, ) if (mediaFrameDimensionsFix()) { debugLogger.logMediaCarouselDimensions( reason = "update carousel size", mediaCarousel.boundsOnScreen, desiredLocation, ) mediaFrame.measureAndLayout( widthSpec, heightSpec, width, mediaCarousel.measuredHeight, ) } // Update the padding after layout; view widths are used in RTL to calculate scrollX mediaCarouselScrollHandler.playerWidthPlusPadding = playerWidthPlusPadding } } private fun ViewGroup.measureAndLayout( widthSpec: Int, heightSpec: Int, width: Int, height: Int, ) { measure(widthSpec, heightSpec) layout(0, 0, width, height) } fun onCarouselVisibleToUser() { if ( !enableSuggestedDeviceUi() || Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerLogger.kt +14 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,20 @@ constructor(@MediaCarouselControllerLog private val buffer: LogBuffer) { { "media frame($str1), width: $int1 height: $int2, location:$long1" }, ) } fun logMediaCarouselDimensions(reason: String, rect: Rect, location: Int) { buffer.log( TAG, LogLevel.DEBUG, { str1 = reason int1 = rect.width() int2 = rect.height() long1 = location.toLong() }, { "media carousel($str1), width: $int1 height: $int2, location:$long1" }, ) } } private const val TAG = "MediaCarouselCtlrLog" packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt +19 −16 Original line number Diff line number Diff line Loading @@ -1446,13 +1446,15 @@ private fun ContentScope.MediaObject( }, update = { view -> view.update() if (!Flags.mediaFrameDimensionsFix()) { // Update layout params if host view bounds are higher than its child. val height = mediaHost.hostView.height val width = mediaHost.hostView.width var measure = false mediaHost.hostView.children.forEach { child -> if ( child is FrameLayout && (height > child.height || width > child.width) child is FrameLayout && (height > child.height || width > child.width) ) { measure = true child.layoutParams = FrameLayout.LayoutParams(width, height) Loading @@ -1464,6 +1466,7 @@ private fun ContentScope.MediaObject( ) mediaLogger.logMediaSize("update size in compose", width, height) } } }, onReset = {}, ) Loading packages/SystemUI/src/com/android/systemui/util/animation/UniqueObjectHostView.kt +7 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.Context import android.view.View import android.view.ViewGroup import android.widget.FrameLayout import com.android.systemui.Flags import com.android.systemui.res.R /** Loading Loading @@ -52,11 +53,13 @@ class UniqueObjectHostView(context: Context) : FrameLayout(context) { if (isCurrentHost()) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) getChildAt(0)?.let { mediaFrame -> if (!Flags.mediaFrameDimensionsFix()) { // 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 } } Loading Loading
packages/SystemUI/aconfig/systemui.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -1312,6 +1312,16 @@ flag { } } flag { name:"media_frame_dimensions_fix" namespace: "systemui" description: "measure and layout media frame when the desired location of media carousel changes" bug: "417204970" metadata { purpose: PURPOSE_BUGFIX } } flag { namespace: "systemui" name: "enable_view_capture_tracing" Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselController.kt +30 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback import com.android.systemui.Dumpable import com.android.systemui.Flags import com.android.systemui.Flags.enableSuggestedDeviceUi import com.android.systemui.Flags.mediaFrameDimensionsFix import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background Loading Loading @@ -1261,13 +1262,40 @@ constructor( // Let's remeasure the carousel val widthSpec = desiredHostState?.measurementInput?.widthMeasureSpec ?: 0 val heightSpec = desiredHostState?.measurementInput?.heightMeasureSpec ?: 0 mediaCarousel.measure(widthSpec, heightSpec) mediaCarousel.layout(0, 0, width, mediaCarousel.measuredHeight) mediaCarousel.measureAndLayout( widthSpec, heightSpec, width, mediaCarousel.measuredHeight, ) if (mediaFrameDimensionsFix()) { debugLogger.logMediaCarouselDimensions( reason = "update carousel size", mediaCarousel.boundsOnScreen, desiredLocation, ) mediaFrame.measureAndLayout( widthSpec, heightSpec, width, mediaCarousel.measuredHeight, ) } // Update the padding after layout; view widths are used in RTL to calculate scrollX mediaCarouselScrollHandler.playerWidthPlusPadding = playerWidthPlusPadding } } private fun ViewGroup.measureAndLayout( widthSpec: Int, heightSpec: Int, width: Int, height: Int, ) { measure(widthSpec, heightSpec) layout(0, 0, width, height) } fun onCarouselVisibleToUser() { if ( !enableSuggestedDeviceUi() || Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/MediaCarouselControllerLogger.kt +14 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,20 @@ constructor(@MediaCarouselControllerLog private val buffer: LogBuffer) { { "media frame($str1), width: $int1 height: $int2, location:$long1" }, ) } fun logMediaCarouselDimensions(reason: String, rect: Rect, location: Int) { buffer.log( TAG, LogLevel.DEBUG, { str1 = reason int1 = rect.width() int2 = rect.height() long1 = location.toLong() }, { "media carousel($str1), width: $int1 height: $int2, location:$long1" }, ) } } private const val TAG = "MediaCarouselCtlrLog"
packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt +19 −16 Original line number Diff line number Diff line Loading @@ -1446,13 +1446,15 @@ private fun ContentScope.MediaObject( }, update = { view -> view.update() if (!Flags.mediaFrameDimensionsFix()) { // Update layout params if host view bounds are higher than its child. val height = mediaHost.hostView.height val width = mediaHost.hostView.width var measure = false mediaHost.hostView.children.forEach { child -> if ( child is FrameLayout && (height > child.height || width > child.width) child is FrameLayout && (height > child.height || width > child.width) ) { measure = true child.layoutParams = FrameLayout.LayoutParams(width, height) Loading @@ -1464,6 +1466,7 @@ private fun ContentScope.MediaObject( ) mediaLogger.logMediaSize("update size in compose", width, height) } } }, onReset = {}, ) Loading
packages/SystemUI/src/com/android/systemui/util/animation/UniqueObjectHostView.kt +7 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.Context import android.view.View import android.view.ViewGroup import android.widget.FrameLayout import com.android.systemui.Flags import com.android.systemui.res.R /** Loading Loading @@ -52,11 +53,13 @@ class UniqueObjectHostView(context: Context) : FrameLayout(context) { if (isCurrentHost()) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) getChildAt(0)?.let { mediaFrame -> if (!Flags.mediaFrameDimensionsFix()) { // 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 } } Loading