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

Commit db377aec authored by Nick Chameyev's avatar Nick Chameyev Committed by Android (Google) Code Review
Browse files

Merge "[waitForAllWindowsDrawn] Wait for default display transition when...

Merge "[waitForAllWindowsDrawn] Wait for default display transition when INVALID_DISPLAY is passed" into main
parents 1248cf23 31d4f150
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7920,7 +7920,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            boolean allWindowsDrawn = false;
            synchronized (mGlobalLock) {
                if (displayId == DEFAULT_DISPLAY
                if ((displayId == DEFAULT_DISPLAY || displayId == INVALID_DISPLAY)
                        && mRoot.getDefaultDisplay().mDisplayUpdater.waitForTransition(message)) {
                    // Use the ready-to-play of transition as the signal.
                    return;
+45 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.wm;

import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
@@ -316,6 +317,50 @@ public class DisplayContentDeferredUpdateTests extends WindowTestsBase {
        verify(mScreenUnblocker).sendToTarget();
    }

    @Test
    public void testWaitForAllWindowsDrawnForInvalidDisplay_usesTransitionToUnblock() {
        mSetFlagsRule.enableFlags(Flags.FLAG_WAIT_FOR_TRANSITION_ON_DISPLAY_SWITCH);

        final WindowState defaultDisplayWindow = createWindow(/* parent= */ null,
                TYPE_BASE_APPLICATION, mDisplayContent, "DefaultDisplayWindow");
        makeWindowVisibleAndNotDrawn(defaultDisplayWindow);

        mDisplayContent.mDisplayUpdater.onDisplaySwitching(/* switching= */ true);

        mWmInternal.waitForAllWindowsDrawn(mScreenUnblocker,
                /* timeout= */ Integer.MAX_VALUE, INVALID_DISPLAY);

        // Perform display update
        mUniqueId = "new_default_display_unique_id";
        mDisplayContent.requestDisplayUpdate(mock(Runnable.class));

        when(mDisplayContent.mTransitionController.inTransition()).thenReturn(true);

        // Notify that transition started collecting
        captureStartTransitionCollection().getAllValues().forEach((callback) ->
                callback.onCollectStarted(/* deferred= */ true));

        // Verify that screen is not unblocked yet
        verify(mScreenUnblocker, never()).sendToTarget();

        // Make all display windows drawn
        defaultDisplayWindow.mWinAnimator.mDrawState = HAS_DRAWN;
        mWm.mRoot.performSurfacePlacement();

        // Verify that default display is still not unblocked yet
        // (so it doesn't use old windows drawn path)
        verify(mScreenUnblocker, never()).sendToTarget();

        // Mark start transaction as presented
        when(mDisplayContent.mTransitionController.inTransition()).thenReturn(false);
        captureRequestedTransition().getAllValues().forEach(
                this::makeTransitionTransactionCompleted);

        // Verify that the default screen unblocker is sent only after start transaction
        // of the Shell transition is presented
        verify(mScreenUnblocker).sendToTarget();
    }

    private void prepareSecondaryDisplay() {
        mSecondaryDisplayContent = createNewDisplay();
        when(mSecondaryScreenUnblocker.getTarget()).thenReturn(mWm.mH);