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

Commit fa842bed authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Prevent dialog launch from crashing in rare cases

This CL ensures that we don't call GhostView.addGhost on a source
that triggered a dialog launch if that source was just removed from its
hierarchy.

The end result of this CL is not perfect given that it makes the dialog
animate from the Rect at (0, 0, 0, 0) but it should be rare enough to
not matter.

Bug: 295858408
Test: Manual. Patched the code to first confirm that this was the source
of the bug then confirmed that the fix worked.

Change-Id: I51ed0f698649d135334d699925b75976352be55a
parent 85dd3026
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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,8 +45,14 @@ internal constructor(

        // Create a temporary ghost of the source (which will make it invisible) and add it
        // to the host dialog.
        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() {
        // Note: here we should remove the ghost from the overlay, but in practice this is