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

Commit 74f58154 authored by Chris Li's avatar Chris Li
Browse files

Do not remove/hide surface when waiting for transition start

When the activity is added to DisplayContent#mClosingApps and prepare
for transition, we want to keep the window for the animation.

Bug: 196173550
Test: test with demo app that the activity exit is not blank
Test: atest WmTests:ActivityRecordTests
      #testInClosingAnimation_doNotHideSurface
Change-Id: I4da65a8d302af6ab846a19132397bfbac4ff2f4e
parent e3b03918
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -3790,8 +3790,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "Removing app token: %s", this);

        commitVisibility(false /* visible */, true /* performLayout */);

        getDisplayContent().mOpeningApps.remove(this);
        getDisplayContent().mUnknownAppVisibilityController.appRemovedOrHidden(this);
        mWmService.mTaskSnapshotController.onAppRemoved(this);
@@ -3799,8 +3797,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mTaskSupervisor.mStoppingActivities.remove(this);
        waitingToShow = false;

        // TODO(b/169035022): move to a more-appropriate place.
        mAtmService.getTransitionController().collect(this);
        // Defer removal of this activity when either a child is animating, or app transition is on
        // going. App transition animation might be applied on the parent task not on the activity,
        // but the actual frame buffer is associated with the activity, so we have to keep the
@@ -3816,6 +3812,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            delayed = true;
        }

        // Don't commit visibility if it is waiting to animate. It will be set post animation.
        if (!delayed) {
            commitVisibility(false /* visible */, true /* performLayout */);
        } else {
            setVisibleRequested(false /* visible */);
        }

        // TODO(b/169035022): move to a more-appropriate place.
        mAtmService.getTransitionController().collect(this);

        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "Removing app %s delayed=%b animation=%s animating=%b", this, delayed,
                getAnimation(),
@@ -4972,7 +4978,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    private void postApplyAnimation(boolean visible) {
        final boolean usingShellTransitions =
                mAtmService.getTransitionController().getTransitionPlayer() != null;
        final boolean delayed = isAnimating(PARENTS | CHILDREN,
        final boolean delayed = isAnimating(TRANSITION | PARENTS | CHILDREN,
                ANIMATION_TYPE_APP_TRANSITION | ANIMATION_TYPE_WINDOW_ANIMATION
                        | ANIMATION_TYPE_RECENTS);
        if (!delayed && !usingShellTransitions) {
@@ -6909,7 +6915,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    @Override
    void prepareSurfaces() {
        final boolean show = isVisible() || isAnimating(PARENTS,
        final boolean show = isVisible() || isAnimating(TRANSITION | PARENTS,
                ANIMATION_TYPE_APP_TRANSITION | ANIMATION_TYPE_RECENTS);

        if (mSurfaceControl != null) {
+1 −2
Original line number Diff line number Diff line
@@ -2582,8 +2582,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    }
                }
                final boolean isAnimating = mAnimatingExit
                        || isAnimating(TRANSITION | PARENTS, EXIT_ANIMATING_TYPES)
                        && (mActivityRecord == null || !mActivityRecord.isWaitingForTransitionStart());
                        || isAnimating(TRANSITION | PARENTS, EXIT_ANIMATING_TYPES);
                final boolean lastWindowIsStartingWindow = startingWindow && mActivityRecord != null
                        && mActivityRecord.isLastWindow(this);
                // We delay the removal of a window if it has a showing surface that can be used to run
+19 −0
Original line number Diff line number Diff line
@@ -2987,6 +2987,7 @@ public class ActivityRecordTests extends WindowTestsBase {
        mDisplayContent.setImeInputTarget(app);

        // Simulate app is closing and expect the last IME is shown and IME insets is frozen.
        mDisplayContent.mOpeningApps.clear();
        app.mActivityRecord.commitVisibility(false, false);
        app.mActivityRecord.onWindowsGone();

@@ -3005,6 +3006,24 @@ public class ActivityRecordTests extends WindowTestsBase {
        assertFalse(app.mActivityRecord.mImeInsetsFrozenUntilStartInput);
    }

    @Test
    public void testInClosingAnimation_doNotHideSurface() {
        final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
        makeWindowVisibleAndDrawn(app);

        // Put the activity in close transition.
        mDisplayContent.mOpeningApps.clear();
        mDisplayContent.mClosingApps.add(app.mActivityRecord);
        mDisplayContent.prepareAppTransition(TRANSIT_CLOSE);

        // Update visibility and call to remove window
        app.mActivityRecord.commitVisibility(false, false);
        app.mActivityRecord.prepareSurfaces();

        // Because the app is waiting for transition, it should not hide the surface.
        assertTrue(app.mActivityRecord.isSurfaceShowing());
    }

    private void assertHasStartingWindow(ActivityRecord atoken) {
        assertNotNull(atoken.mStartingSurface);
        assertNotNull(atoken.mStartingData);