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

Commit baeb6640 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Check visible transient launch explicitly

When launching a visible transient task to front (a translucent
activity is on top), the transition participants contain the
transient launch task (reorder) but don't contain the activity
(no visibility change). Then hasVisibleTransientLaunch may be
missed to set. That causes the dependent logic of the flag not
to be called, e.g. update ime target.

So check from mTransientLaunches directly instead of depending on
transition participants.

Fix: 409453244
Flag: EXEMPT bugfix
Test: atest TransitionTests#testTransientLaunchWithTranslucentTask
Change-Id: I020228c6dfd58c43c94f586ad811ab183a98f041
parent eb737b68
Loading
Loading
Loading
Loading
+25 −14
Original line number Diff line number Diff line
@@ -1215,6 +1215,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.
     *
@@ -1335,7 +1359,6 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        }

        boolean hasParticipatedDisplay = false;
        boolean hasVisibleTransientLaunch = false;
        boolean enterAutoPip = false;
        boolean committedSomeInvisible = false;
        // Commit all going-invisible containers
@@ -1414,19 +1437,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;
            }
@@ -1478,6 +1488,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)