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

Commit 89f64b84 authored by Vali Calinescu's avatar Vali Calinescu
Browse files

Refactor dispatching the focus event from handleWindowFocusChanged

Bug: 262216060
Test: N/A
Change-Id: Ic2814d9665b8f293249de5fe2158f83af72517da
Merged-In: Ic2814d9665b8f293249de5fe2158f83af72517da
parent e7786409
Loading
Loading
Loading
Loading
+40 −38
Original line number Diff line number Diff line
@@ -3808,9 +3808,45 @@ public final class ViewRootImpl implements ViewParent,
        }

        if (mAdded) {
            profileRendering(hasWindowFocus);
            dispatchFocusEvent(hasWindowFocus);

            // Note: must be done after the focus change callbacks,
            // so all of the view state is set up correctly.
            mImeFocusController.onPostWindowFocus(
                    getFocusedViewOrNull(), hasWindowFocus, mWindowAttributes);

            if (hasWindowFocus) {
                if (mAttachInfo.mThreadedRenderer != null && mSurface.isValid()) {
                // Clear the forward bit.  We can just do this directly, since
                // the window manager doesn't care about it.
                mWindowAttributes.softInputMode &=
                        ~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
                ((WindowManager.LayoutParams) mView.getLayoutParams())
                        .softInputMode &=
                        ~WindowManager.LayoutParams
                                .SOFT_INPUT_IS_FORWARD_NAVIGATION;

                // Refocusing a window that has a focused view should fire a
                // focus event for the view since the global focused view changed.
                fireAccessibilityFocusEventIfHasFocusedNode();
            } else {
                if (mPointerCapture) {
                    handlePointerCaptureChanged(false);
                }
            }
        }
        mFirstInputStage.onWindowFocusChanged(hasWindowFocus);

        // NOTE: there's no view visibility (appeared / disapparead) events when the windows focus
        // is lost, so we don't need to to force a flush - there might be other events such as
        // text changes, but these should be flushed independently.
        if (hasWindowFocus) {
            handleContentCaptureFlush();
        }
    }

    private void dispatchFocusEvent(boolean hasWindowFocus) {
        profileRendering(hasWindowFocus);
        if (hasWindowFocus && mAttachInfo.mThreadedRenderer != null && mSurface.isValid()) {
            mFullRedrawNeeded = true;
            try {
                final Rect surfaceInsets = mWindowAttributes.surfaceInsets;
@@ -3832,7 +3868,6 @@ public final class ViewRootImpl implements ViewParent,
                return;
            }
        }
            }

        mAttachInfo.mHasWindowFocus = hasWindowFocus;
        mImeFocusController.updateImeFocusable(mWindowAttributes, true /* force */);
@@ -3846,39 +3881,6 @@ public final class ViewRootImpl implements ViewParent,
                mAttachInfo.mTooltipHost.hideTooltip();
            }
        }

            // Note: must be done after the focus change callbacks,
            // so all of the view state is set up correctly.
            mImeFocusController.onPostWindowFocus(
                    getFocusedViewOrNull(), hasWindowFocus, mWindowAttributes);

            if (hasWindowFocus) {
                // Clear the forward bit.  We can just do this directly, since
                // the window manager doesn't care about it.
                mWindowAttributes.softInputMode &=
                        ~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
                ((WindowManager.LayoutParams) mView.getLayoutParams())
                        .softInputMode &=
                        ~WindowManager.LayoutParams
                                .SOFT_INPUT_IS_FORWARD_NAVIGATION;

                // Refocusing a window that has a focused view should fire a
                // focus event for the view since the global focused view changed.
                fireAccessibilityFocusEventIfHasFocusedNode();
            } else {
                if (mPointerCapture) {
                    handlePointerCaptureChanged(false);
                }
            }
        }
        mFirstInputStage.onWindowFocusChanged(hasWindowFocus);

        // NOTE: there's no view visibility (appeared / disapparead) events when the windows focus
        // is lost, so we don't need to to force a flush - there might be other events such as
        // text changes, but these should be flushed independently.
        if (hasWindowFocus) {
            handleContentCaptureFlush();
        }
    }

    private void handleWindowTouchModeChanged() {