diff options
| author | 2025-03-13 16:42:00 +0000 | |
|---|---|---|
| committer | 2025-03-14 13:02:49 +0000 | |
| commit | faa3679e77e794d3fcfcf73fb586a50fec7808cc (patch) | |
| tree | bdb456f41f0024a5f34e70d2a3df0ee8eeb59723 | |
| parent | 09558664c3d588c5bef8a43369410103ad50fed5 (diff) | |
Don't reparent when the view's root is null.
I'm not 100% sure why this happens sometimes, but I think it's due
to a faulty setup of the view inside the controller. Anyway we
don't want to crash, so we avoid reparenting in this scenario.
Fix: 402192262
Flag: com.android.systemui.move_transition_animation_layer
Test: atest ActivityTransitionAnimatorTest + manual validation
Change-Id: Iaa329d9f830f2c78fca0fc2a21d067fecb8dce05
| -rw-r--r-- | packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt index 7ee6a6e5ebf4..0271d7cbb86c 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityTransitionAnimator.kt @@ -1216,6 +1216,13 @@ constructor( private var animation: TransitionAnimator.Animation? = null /** + * Whether the opening/closing window needs to reparented to the view's window at the + * beginning of the animation. Since we don't always do this, we need to keep track of it in + * order to have the rest of the animation behave correctly. + */ + var reparent = false + + /** * A timeout to cancel the transition animation if the remote animation is not started or * cancelled within [TRANSITION_TIMEOUT] milliseconds after the intent was started. * @@ -1469,6 +1476,12 @@ constructor( transitionAnimator.isExpandingFullyAbove(controller.transitionContainer, endState) val windowState = startingWindowState ?: controller.windowAnimatorState + val viewRoot = controller.transitionContainer.viewRootImpl + val skipReparenting = skipReparentTransaction || viewRoot == null + if (moveTransitionAnimationLayer() && !skipReparenting) { + reparent = true + } + // We animate the opening window and delegate the view expansion to [this.controller]. val delegate = this.controller val controller = @@ -1536,16 +1549,13 @@ constructor( ) } - if (moveTransitionAnimationLayer() && !skipReparentTransaction) { + if (reparent) { // Ensure that the launching window is rendered above the view's window, // so it is not obstructed. // TODO(b/397180418): re-use the start transaction once the // RemoteAnimation wrapper is cleaned up. SurfaceControl.Transaction().use { - it.reparent( - window.leash, - controller.transitionContainer.viewRootImpl.surfaceControl, - ) + it.reparent(window.leash, viewRoot.surfaceControl) it.apply() } } @@ -1603,7 +1613,7 @@ constructor( null } val fadeWindowBackgroundLayer = - if (moveTransitionAnimationLayer()) { + if (reparent) { false } else { !controller.isBelowAnimatingWindow @@ -1727,7 +1737,7 @@ constructor( // fade in progressively. Otherwise, it should be fully opaque and will be progressively // revealed as the window background color layer above the window fades out. val alpha = - if (moveTransitionAnimationLayer() || controller.isBelowAnimatingWindow) { + if (reparent || controller.isBelowAnimatingWindow) { if (controller.isLaunching) { interpolators.contentAfterFadeInInterpolator.getInterpolation( windowProgress |