diff options
| author | 2023-10-03 12:40:42 +0000 | |
|---|---|---|
| committer | 2023-10-03 12:40:42 +0000 | |
| commit | 0c4ffe024760c45b51985edbcbb28220ebfd1ebf (patch) | |
| tree | c1e00f3dd61aa71ed8c0de4eee845844405aecb8 | |
| parent | 84b7fb7574c5a297c3c7715a7717b9f9d99d0908 (diff) | |
| parent | fa842bed5bc3c3d537aac8271c8b4b952001084f (diff) | |
Merge "Prevent dialog launch from crashing in rare cases" into main
| -rw-r--r-- | packages/SystemUI/animation/src/com/android/systemui/animation/ViewDialogLaunchAnimatorController.kt | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ViewDialogLaunchAnimatorController.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ViewDialogLaunchAnimatorController.kt index 46d5a5c0af8c..1290f0097536 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ViewDialogLaunchAnimatorController.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ViewDialogLaunchAnimatorController.kt @@ -16,12 +16,15 @@ package com.android.systemui.animation +import android.util.Log import android.view.GhostView import android.view.View import android.view.ViewGroup import android.view.ViewRootImpl import com.android.internal.jank.InteractionJankMonitor +private const val TAG = "ViewDialogLaunchAnimatorController" + /** A [DialogLaunchAnimator.Controller] that can animate a [View] from/to a dialog. */ class ViewDialogLaunchAnimatorController internal constructor( @@ -42,7 +45,13 @@ internal constructor( // Create a temporary ghost of the source (which will make it invisible) and add it // to the host dialog. - GhostView.addGhost(source, viewGroup) + if (source.parent !is ViewGroup) { + // This should usually not happen, but let's make sure we don't call GhostView.addGhost + // and crash if the view was detached right before we started the animation. + Log.w(TAG, "source was detached right before drawing was moved to overlay") + } else { + GhostView.addGhost(source, viewGroup) + } } override fun stopDrawingInOverlay() { |