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

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

Merge "Execute transition by starting window of cold launch existed task" into main

parents fffea711 62bfef80
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -6975,14 +6975,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        updateReportedVisibilityLocked();
    }
    /**
     * Sets whether something has been visible in the task and returns {@code true} if the state
     * is changed from invisible to visible.
     */
    private boolean setTaskHasBeenVisible() {
    /** Sets whether something has been visible in the task. */
    private void setTaskHasBeenVisible() {
        final boolean wasTaskVisible = task.getHasBeenVisible();
        if (wasTaskVisible) {
            return false;
            return;
        }
        if (inTransition()) {
            // The deferring will be canceled until transition is ready so it won't dispatch
@@ -6990,20 +6987,22 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            task.setDeferTaskAppear(true);
        }
        task.setHasBeenVisible(true);
        return true;
    }
    void onStartingWindowDrawn() {
        boolean wasTaskVisible = false;
        if (task != null) {
            mSplashScreenStyleSolidColor = true;
            wasTaskVisible = !setTaskHasBeenVisible();
            setTaskHasBeenVisible();
        }
        if (mStartingData == null || mStartingData.mIsDisplayed) {
            return;
        }
        mStartingData.mIsDisplayed = true;
        // The transition may not be executed if the starting process hasn't attached. But if the
        // starting window is drawn, the transition can start earlier. Exclude finishing and bubble
        // because it may be a trampoline.
        if (!wasTaskVisible && mStartingData != null && !finishing && !mLaunchedFromBubble
        if (app == null && !finishing && !mLaunchedFromBubble
                && mVisibleRequested && !mDisplayContent.mAppTransition.isReady()
                && !mDisplayContent.mAppTransition.isRunning()
                && mDisplayContent.isNextTransitionForward()) {
@@ -7240,9 +7239,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        isInterestingAndDrawn = true;
                    }
                }
            } else if (mStartingData != null && w.isDrawn()) {
                // The starting window for this container is drawn.
                mStartingData.mIsDisplayed = true;
            }
        }
+24 −0
Original line number Diff line number Diff line
@@ -3097,6 +3097,30 @@ public class ActivityRecordTests extends WindowTestsBase {
        assertFalse("Starting window should not be present", activity.hasStartingWindow());
    }

    @Test
    public void testOnStartingWindowDrawn() {
        final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
        // The task-has-been-visible should not affect the decision of making transition ready.
        activity.getTask().setHasBeenVisible(true);
        activity.detachFromProcess();
        activity.mStartingData = mock(StartingData.class);
        registerTestTransitionPlayer();
        final Transition transition = activity.mTransitionController.requestTransitionIfNeeded(
                WindowManager.TRANSIT_OPEN, 0 /* flags */, null /* trigger */, mDisplayContent);
        activity.onStartingWindowDrawn();
        assertTrue(activity.mStartingData.mIsDisplayed);
        // The transition can be ready by the starting window of a visible-requested activity
        // without a running process.
        assertTrue(transition.allReady());

        // If other event makes the transition unready, the reentrant of onStartingWindowDrawn
        // should not replace the readiness again.
        transition.setReady(mDisplayContent, false);
        activity.onStartingWindowDrawn();
        assertFalse(transition.allReady());
    }


    @Test
    public void testCloseToSquareFixedOrientation() {
        if (Flags.insetsDecoupledConfiguration()) {