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

Commit d58b65cd authored by Evan Rosky's avatar Evan Rosky
Browse files

Don't crash during layout of non-attached but focused view

Verifies that there is a viewrootimpl before calling its
methods.

Bug: 77193567
Test: N/A
Change-Id: I301c3aede3d0f7e1d2abf6fe5bb3d852f697577b
parent f3015eb0
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -20700,7 +20700,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            if (canTakeFocus()) {
            if (canTakeFocus()) {
                // We have a robust focus, so parents should no longer be wanting focus.
                // We have a robust focus, so parents should no longer be wanting focus.
                clearParentsWantFocus();
                clearParentsWantFocus();
            } else if (!getViewRootImpl().isInLayout()) {
            } else if (getViewRootImpl() == null || !getViewRootImpl().isInLayout()) {
                // This is a weird case. Most-likely the user, rather than ViewRootImpl, called
                // This is a weird case. Most-likely the user, rather than ViewRootImpl, called
                // layout. In this case, there's no guarantee that parent layouts will be evaluated
                // layout. In this case, there's no guarantee that parent layouts will be evaluated
                // and thus the safest action is to clear focus here.
                // and thus the safest action is to clear focus here.