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

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

Merge "Check visible transient launch explicitly" into main

parents 4f2fdc03 baeb6640
Loading
Loading
Loading
Loading
+25 −14
Original line number Diff line number Diff line
@@ -1216,6 +1216,30 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        return false;
    }

    /** Returns {@code true} if the end state of a transient launch is visible. */
    private boolean handleVisibleTransientLaunchOnFinish() {
        if (mTransientLaunches == null) return false;
        boolean found = false;
        for (int i = mTransientLaunches.size() - 1; i >= 0; --i) {
            final ActivityRecord ar = mTransientLaunches.keyAt(i);
            final Task task = ar.getTask();
            if (task == null || !ar.isVisible()) {
                continue;
            }
            // Because transient launches don't automatically take focus, make sure it is focused
            // since the launch is committed.
            if (!task.isFocused() && ar.isTopRunningActivity()) {
                mController.mAtm.setLastResumedActivityUncheckLocked(ar, "transitionFinished");
            }
            // Prevent spurious background app switches.
            if (ar.mDisplayContent.mFocusedApp == ar) {
                mController.mAtm.stopAppSwitches();
            }
            found = true;
        }
        return found;
    }

    /**
     * Check if pip-entry is possible after finishing and enter-pip if it is.
     *
@@ -1336,7 +1360,6 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        }

        boolean hasParticipatedDisplay = false;
        boolean hasVisibleTransientLaunch = false;
        boolean enterAutoPip = false;
        boolean committedSomeInvisible = false;
        // Commit all going-invisible containers
@@ -1415,19 +1438,6 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
                        && ar.isVisible()) {
                    // Transient launch was committed, so report enteringAnimation
                    ar.mEnteringAnimation = true;
                    hasVisibleTransientLaunch = true;

                    // Since transient launches don't automatically take focus, make sure we
                    // synchronize focus since we committed to the launch.
                    if (!task.isFocused() && ar.isTopRunningActivity()) {
                        mController.mAtm.setLastResumedActivityUncheckLocked(ar,
                                "transitionFinished");
                    }

                    // Prevent spurious background app switches.
                    if (ar.mDisplayContent.mFocusedApp == ar) {
                        mController.mAtm.stopAppSwitches();
                    }
                }
                continue;
            }
@@ -1479,6 +1489,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
            mController.onCommittedInvisibles();
        }

        final boolean hasVisibleTransientLaunch = handleVisibleTransientLaunchOnFinish();
        if (hasVisibleTransientLaunch) {
            // Notify the change about the transient-below task if entering auto-pip.
            if (enterAutoPip) {
+26 −0
Original line number Diff line number Diff line
@@ -1617,6 +1617,32 @@ public class TransitionTests extends WindowTestsBase {
        assertTrue(enteringAnimReports.contains(activity2));
    }

    @Test
    public void testTransientLaunchWithTranslucentTask() {
        final ActivityRecord recent = new ActivityBuilder(mAtm).setCreateTask(true).build();
        final ActivityRecord translucentApp = new ActivityBuilder(mAtm).setCreateTask(true)
                .setActivityTheme(android.R.style.Theme_Translucent).build();
        final Task taskRecent = recent.getTask();
        final TestTransitionPlayer player = registerTestTransitionPlayer();
        final Transition transition = createTestTransition(TRANSIT_OPEN, player.mController);
        player.mController.moveToCollecting(transition);
        player.mController.requestStartTransition(transition, taskRecent,
                null /* remoteTransition */, null /* displayChange */);
        transition.setTransientLaunch(recent, taskRecent);
        taskRecent.moveToFront("move-recent-to-front");
        // Assume that the recents activity is not collected because it keeps visible when the
        // translucent app was on top.
        assertFalse(transition.mParticipants.contains(recent));

        player.start();
        clearInvocations(mDisplayContent);
        doCallRealMethod().when(mWm.mRoot).ensureActivitiesVisible(any(), anyBoolean());
        player.finish();
        // Transition#finishTransition -> updateImeForVisibleTransientLaunch.
        verify(mDisplayContent).computeImeLayeringTarget(true /* update */);
        assertFalse(translucentApp.isVisible());
    }

    @Test
    public void testIsTransientVisible() {
        final ActivityRecord appB = new ActivityBuilder(mAtm).setCreateTask(true)