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

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

Merge "Unset window destroying state only if its surface is destroyed" into main

parents f2d350f1 97afa758
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3380,8 +3380,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            if (cleanupOnResume) {
                requestUpdateWallpaperIfNeeded();
            }
            if (!mHasSurface) {
                mDestroying = false;
                destroyedSomething = true;
            }

            // Since mDestroying will affect ActivityRecord#allDrawn, we need to perform another
            // traversal in case we are waiting on this window to start the transition.
+23 −0
Original line number Diff line number Diff line
@@ -352,6 +352,29 @@ public class WindowStateTests extends WindowTestsBase {
        assertTrue(windows.isEmpty());
    }

    @Test
    public void testDestroySurface() {
        final WindowState win = createWindow(null, TYPE_APPLICATION, "win");
        win.mHasSurface = win.mAnimatingExit = true;
        win.mWinAnimator.mSurfaceControl = mock(SurfaceControl.class);
        win.onExitAnimationDone();

        assertFalse("Case 1 destroySurface no-op",
                win.destroySurface(false /* cleanupOnResume */, false /* appStopped */));
        assertTrue(win.mHasSurface);
        assertTrue(win.mDestroying);

        assertFalse("Case 2 destroySurface no-op",
                win.destroySurface(true /* cleanupOnResume */, false /* appStopped */));
        assertTrue(win.mHasSurface);
        assertTrue(win.mDestroying);

        assertTrue("Case 3 destroySurface destroys surface",
                win.destroySurface(false /* cleanupOnResume */, true /* appStopped */));
        assertFalse(win.mDestroying);
        assertFalse(win.mHasSurface);
    }

    @Test
    public void testPrepareWindowToDisplayDuringRelayout() {
        // Call prepareWindowToDisplayDuringRelayout for a window without FLAG_TURN_SCREEN_ON before