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

Commit d50231ad authored by Gaurav Bhola's avatar Gaurav Bhola Committed by Android (Google) Code Review
Browse files

Merge "Move insets related logic from WindowState to WindowContainer."

parents 909c8bbe f60944f1
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1362,8 +1362,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return mDisplayRotation;
    }

    void setInsetProvider(@InternalInsetsType int type, WindowState win,
            @Nullable TriConsumer<DisplayFrames, WindowState, Rect> frameProvider){
    void setInsetProvider(@InternalInsetsType int type, WindowContainer win,
            @Nullable TriConsumer<DisplayFrames, WindowContainer, Rect> frameProvider) {
        setInsetProvider(type, win, frameProvider, null /* imeFrameProvider */);
    }

@@ -1377,10 +1377,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     * @param imeFrameProvider Function to compute the frame when dispatching insets to the IME, or
     *                         {@code null} if the normal frame should be taken.
     */
    void setInsetProvider(@InternalInsetsType int type, WindowState win,
            @Nullable TriConsumer<DisplayFrames, WindowState, Rect> frameProvider,
            @Nullable TriConsumer<DisplayFrames, WindowState, Rect> imeFrameProvider) {
        mInsetsStateController.getSourceProvider(type).setWindow(win, frameProvider,
    void setInsetProvider(@InternalInsetsType int type, WindowContainer win,
            @Nullable TriConsumer<DisplayFrames, WindowContainer, Rect> frameProvider,
            @Nullable TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider) {
        mInsetsStateController.getSourceProvider(type).setWindowContainer(win, frameProvider,
                imeFrameProvider);
    }

@@ -3822,7 +3822,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            final int imePid = mInputMethodWindow.mSession.mPid;
            mAtmService.onImeWindowSetOnDisplayArea(imePid, mImeWindowsContainer);
        }
        mInsetsStateController.getSourceProvider(ITYPE_IME).setWindow(win,
        mInsetsStateController.getSourceProvider(ITYPE_IME).setWindowContainer(win,
                mDisplayPolicy.getImeSourceFrameProvider(), null /* imeFrameProvider */);
        computeImeTarget(true /* updateImeTarget */);
        updateImeControlTarget();
+28 −21
Original line number Diff line number Diff line
@@ -1106,8 +1106,8 @@ public class DisplayPolicy {
                break;
            case TYPE_STATUS_BAR:
                mStatusBar = win;
                final TriConsumer<DisplayFrames, WindowState, Rect> gestureFrameProvider =
                        (displayFrames, windowState, rect) -> {
                final TriConsumer<DisplayFrames, WindowContainer, Rect> gestureFrameProvider =
                        (displayFrames, windowContainer, rect) -> {
                            rect.bottom = rect.top + getStatusBarHeight(displayFrames);
                            final DisplayCutout cutout =
                                    displayFrames.mInsetsState.getDisplayCutout();
@@ -1128,24 +1128,25 @@ public class DisplayPolicy {
            case TYPE_NAVIGATION_BAR:
                mNavigationBar = win;
                mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            if (!mNavButtonForcedVisible) {
                                inOutFrame.inset(windowState.getLayoutingAttrs(
                                inOutFrame.inset(win.getLayoutingAttrs(
                                        displayFrames.mRotation).providedInternalInsets);
                                inOutFrame.inset(win.mGivenContentInsets);
                            }
                        },

                        // For IME we use regular frame.
                        (displayFrames, windowState, inOutFrame) ->
                                inOutFrame.set(windowState.getFrame()));
                        (displayFrames, windowContainer, inOutFrame) -> {
                            inOutFrame.set(win.getFrame());
                        });

                mDisplayContent.setInsetProvider(ITYPE_BOTTOM_MANDATORY_GESTURES, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            inOutFrame.top -= mBottomGestureAdditionalInset;
                        });
                mDisplayContent.setInsetProvider(ITYPE_LEFT_GESTURES, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            final int leftSafeInset =
                                    Math.max(displayFrames.mDisplayCutoutSafe.left, 0);
                            inOutFrame.left = 0;
@@ -1154,7 +1155,7 @@ public class DisplayPolicy {
                            inOutFrame.right = leftSafeInset + mLeftGestureInset;
                        });
                mDisplayContent.setInsetProvider(ITYPE_RIGHT_GESTURES, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            final int rightSafeInset =
                                    Math.min(displayFrames.mDisplayCutoutSafe.right,
                                            displayFrames.mUnrestricted.right);
@@ -1164,8 +1165,8 @@ public class DisplayPolicy {
                            inOutFrame.right = displayFrames.mDisplayWidth;
                        });
                mDisplayContent.setInsetProvider(ITYPE_BOTTOM_TAPPABLE_ELEMENT, win,
                        (displayFrames, windowState, inOutFrame) -> {
                            if ((windowState.getAttrs().flags & FLAG_NOT_TOUCHABLE) != 0
                        (displayFrames, windowContainer, inOutFrame) -> {
                            if ((win.getAttrs().flags & FLAG_NOT_TOUCHABLE) != 0
                                    || mNavigationBarLetsThroughTaps) {
                                inOutFrame.setEmpty();
                            }
@@ -1176,11 +1177,13 @@ public class DisplayPolicy {
            default:
                if (attrs.providesInsetsTypes != null) {
                    for (@InternalInsetsType int insetsType : attrs.providesInsetsTypes) {
                        final TriConsumer<DisplayFrames, WindowState, Rect> imeFrameProvider =
                        final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
                                !attrs.providedInternalImeInsets.equals(Insets.NONE)
                                        ? (displayFrames, windowState, inOutFrame) ->
                                        inOutFrame.inset(windowState.getLayoutingAttrs(
                                                displayFrames.mRotation).providedInternalImeInsets)
                                        ? (displayFrames, windowContainer, inOutFrame) -> {
                                            inOutFrame.inset(win.getLayoutingAttrs(
                                                    displayFrames.mRotation)
                                                    .providedInternalImeInsets);
                                        }
                                        : null;
                        switch (insetsType) {
                            case ITYPE_STATUS_BAR:
@@ -1201,10 +1204,9 @@ public class DisplayPolicy {
                                break;
                        }
                        mDisplayContent.setInsetProvider(insetsType, win, (displayFrames,
                                windowState, inOutFrame) -> {
                            inOutFrame.inset(
                                    windowState.getLayoutingAttrs(displayFrames.mRotation)
                                            .providedInternalInsets);
                                windowContainer, inOutFrame) -> {
                            inOutFrame.inset(win.getLayoutingAttrs(
                                    displayFrames.mRotation).providedInternalInsets);
                            inOutFrame.inset(win.mGivenContentInsets);
                        }, imeFrameProvider);
                        mInsetsSourceWindowsExceptIme.add(win);
@@ -1230,8 +1232,13 @@ public class DisplayPolicy {
        }
    }

    TriConsumer<DisplayFrames, WindowState, Rect> getImeSourceFrameProvider() {
        return (displayFrames, windowState, inOutFrame) -> {
    TriConsumer<DisplayFrames, WindowContainer, Rect> getImeSourceFrameProvider() {
        return (displayFrames, windowContainer, inOutFrame) -> {
            WindowState windowState = windowContainer.asWindowState();
            if (windowState == null) {
                throw new IllegalArgumentException("IME insets must be provided by a window.");
            }

            if (mNavigationBar != null && navigationBarPosition(displayFrames.mRotation)
                    == NAV_BAR_BOTTOM) {
                // In gesture navigation, nav bar frame is larger than frame to calculate insets.
+11 −5
Original line number Diff line number Diff line
@@ -113,8 +113,8 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
    private void reportImeDrawnForOrganizer(InsetsControlTarget caller) {
        if (caller.getWindow() != null && caller.getWindow().getTask() != null) {
            if (caller.getWindow().getTask().isOrganized()) {
                mWin.mWmService.mAtmService.mTaskOrganizerController.reportImeDrawnOnTask(
                        caller.getWindow().getTask());
                mWindowContainer.mWmService.mAtmService.mTaskOrganizerController
                        .reportImeDrawnOnTask(caller.getWindow().getTask());
            }
        }
    }
@@ -173,12 +173,18 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
    }

    void checkShowImePostLayout() {
        if (mWindowContainer == null) {
            return;
        }
        WindowState windowState =  mWindowContainer.asWindowState();
        if (windowState == null) {
            throw new IllegalArgumentException("IME insets must be provided by a window.");
        }
        // check if IME is drawn
        if (mIsImeLayoutDrawn
                || (isReadyToShowIme()
                && mWin != null
                && mWin.isDrawn()
                && !mWin.mGivenInsetsPending)) {
                && windowState.isDrawn()
                && !windowState.mGivenInsetsPending)) {
            mIsImeLayoutDrawn = true;
            // show IME if InputMethodService requested it to be shown.
            if (mShowImeRunner != null) {
+3 −2
Original line number Diff line number Diff line
@@ -177,7 +177,8 @@ class InsetsPolicy {

    boolean isHidden(@InternalInsetsType int type) {
        final InsetsSourceProvider provider =  mStateController.peekSourceProvider(type);
        return provider != null && provider.hasWindow() && !provider.getSource().isVisible();
        return provider != null && provider.hasWindowContainer()
                && !provider.getSource().isVisible();
    }

    void showTransient(@InternalInsetsType int[] types, boolean isGestureOnSystemBar) {
+108 −72

File changed.

Preview size limit exceeded, changes collapsed.

Loading