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

Commit 9125a15d authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Commit draw state before computing whether display has content" into main

parents c1607eef 879057a8
Loading
Loading
Loading
Loading
+18 −21
Original line number Diff line number Diff line
@@ -1004,6 +1004,24 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                mTmpApplySurfaceChangesTransactionState.obscured;
        final RootWindowContainer root = mWmService.mRoot;

        if (w.mHasSurface) {
            // Take care of the window being ready to display.
            final boolean committed = w.mWinAnimator.commitFinishDrawingLocked();
            if (isDefaultDisplay && committed) {
                if (w.hasWallpaper()) {
                    ProtoLog.v(WM_DEBUG_WALLPAPER,
                            "First draw done in potential wallpaper target %s", w);
                    mWallpaperMayChange = true;
                    pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
                    if (DEBUG_LAYOUT_REPEATS) {
                        surfacePlacer.debugLayoutRepeats(
                                "wallpaper and commitFinishDrawingLocked true",
                                pendingLayoutChanges);
                    }
                }
            }
        }

        // Update effect.
        w.mObscured = mTmpApplySurfaceChangesTransactionState.obscured;

@@ -1090,30 +1108,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

        w.handleWindowMovedIfNeeded();

        final WindowStateAnimator winAnimator = w.mWinAnimator;

        //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
        w.resetContentChanged();

        // Moved from updateWindowsAndWallpaperLocked().
        if (w.mHasSurface) {
            // Take care of the window being ready to display.
            final boolean committed = winAnimator.commitFinishDrawingLocked();
            if (isDefaultDisplay && committed) {
                if (w.hasWallpaper()) {
                    ProtoLog.v(WM_DEBUG_WALLPAPER,
                            "First draw done in potential wallpaper target %s", w);
                    mWallpaperMayChange = true;
                    pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
                    if (DEBUG_LAYOUT_REPEATS) {
                        surfacePlacer.debugLayoutRepeats(
                                "wallpaper and commitFinishDrawingLocked true",
                                pendingLayoutChanges);
                    }
                }
            }
        }

        final ActivityRecord activity = w.mActivityRecord;
        if (activity != null && activity.isVisibleRequested()) {
            activity.updateLetterboxSurface(w);
+15 −0
Original line number Diff line number Diff line
@@ -642,6 +642,21 @@ public class DisplayContentTests extends WindowTestsBase {
        assertFalse(secondaryDisplay.shouldWaitForSystemDecorWindowsOnBoot());
    }

    @Test
    public void testDisplayHasContent() {
        final WindowState window = createWindow(null, TYPE_APPLICATION_OVERLAY, "window");
        setDrawnState(WindowStateAnimator.COMMIT_DRAW_PENDING, window);
        assertFalse(mDisplayContent.getLastHasContent());
        // The pending draw state should be committed and the has-content state is also updated.
        mDisplayContent.applySurfaceChangesTransaction();
        assertTrue(window.isDrawn());
        assertTrue(mDisplayContent.getLastHasContent());
        // If the only window is no longer visible, has-content will be false.
        setDrawnState(WindowStateAnimator.NO_SURFACE, window);
        mDisplayContent.applySurfaceChangesTransaction();
        assertFalse(mDisplayContent.getLastHasContent());
    }

    @Test
    public void testImeIsAttachedToDisplayForLetterboxedApp() {
        final DisplayContent dc = mDisplayContent;