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

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

Restored focusableViewAvailable logic on visibility change

Since visibility effects children, it's state change should
report focusableViewAvailable even though it, itself, may
not be focusable.

Bug: 76027633
Test: CTS View_FocusHandlingTest
Change-Id: I83f949ec33bcac02e75e21727a120d3018d9382a
parent 4e561f83
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -13914,11 +13914,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        mAttachInfo.mUnbufferedDispatchRequested = true;
    }
    private boolean hasSize() {
        return (mBottom > mTop) && (mRight > mLeft);
    }
    private boolean canTakeFocus() {
        return ((mViewFlags & VISIBILITY_MASK) == VISIBLE)
                && ((mViewFlags & FOCUSABLE) == FOCUSABLE)
                && ((mViewFlags & ENABLED_MASK) == ENABLED)
                && (sCanFocusZeroSized || !isLayoutValid() || (mBottom > mTop) && (mRight > mLeft));
                && (sCanFocusZeroSized || !isLayoutValid() || hasSize());
    }
    /**
@@ -13979,7 +13983,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                            || focusableChangedByAuto == 0
                            || viewRootImpl == null
                            || viewRootImpl.mThread == Thread.currentThread()) {
                        shouldNotifyFocusableAvailable = true;
                        shouldNotifyFocusableAvailable = canTakeFocus();
                    }
                }
            }
@@ -13998,11 +14002,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                needGlobalAttributesUpdate(true);
                // a view becoming visible is worth notifying the parent
                // about in case nothing has focus.  even if this specific view
                // isn't focusable, it may contain something that is, so let
                // the root view try to give this focus if nothing else does.
                shouldNotifyFocusableAvailable = true;
                // a view becoming visible is worth notifying the parent about in case nothing has
                // focus. Even if this specific view isn't focusable, it may contain something that
                // is, so let the root view try to give this focus if nothing else does.
                shouldNotifyFocusableAvailable = hasSize();
            }
        }
@@ -14011,17 +14014,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                // a view becoming enabled should notify the parent as long as the view is also
                // visible and the parent wasn't already notified by becoming visible during this
                // setFlags invocation.
                shouldNotifyFocusableAvailable = true;
                shouldNotifyFocusableAvailable = canTakeFocus();
            } else {
                if (isFocused()) clearFocus();
            }
        }
        if (shouldNotifyFocusableAvailable) {
            if (mParent != null && canTakeFocus()) {
        if (shouldNotifyFocusableAvailable && mParent != null) {
            mParent.focusableViewAvailable(this);
        }
        }
        /* Check if the GONE bit has changed */
        if ((changed & GONE) != 0) {