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

Commit 4c5ee64c authored by Evan Rosky's avatar Evan Rosky Committed by Automerger Merge Worker
Browse files

Merge "Don't collect redundant activities in transient launch" into udc-dev am: 158198dd

parents 32b19f8d 158198dd
Loading
Loading
Loading
Loading
+18 −7
Original line number Original line Diff line number Diff line
@@ -287,7 +287,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {


        if (restoreBelow != null) {
        if (restoreBelow != null) {
            final Task transientRootTask = activity.getRootTask();
            final Task transientRootTask = activity.getRootTask();
            // Collect all visible activities which can be occluded by the transient activity to
            // Collect all visible tasks which can be occluded by the transient activity to
            // make sure they are in the participants so their visibilities can be updated when
            // make sure they are in the participants so their visibilities can be updated when
            // finishing transition.
            // finishing transition.
            ((WindowContainer<?>) restoreBelow.getParent()).forAllTasks(t -> {
            ((WindowContainer<?>) restoreBelow.getParent()).forAllTasks(t -> {
@@ -297,11 +297,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
                        mTransientHideTasks.add(t);
                        mTransientHideTasks.add(t);
                    }
                    }
                    if (t.isLeafTask()) {
                    if (t.isLeafTask()) {
                        t.forAllActivities(r -> {
                        collect(t);
                            if (r.isVisibleRequested()) {
                                collect(r);
                            }
                        });
                    }
                    }
                }
                }
                return t == restoreBelow;
                return t == restoreBelow;
@@ -904,6 +900,18 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        mController.mFinishingTransition = this;
        mController.mFinishingTransition = this;


        if (mTransientHideTasks != null && !mTransientHideTasks.isEmpty()) {
        if (mTransientHideTasks != null && !mTransientHideTasks.isEmpty()) {
            // Record all the now-hiding activities so that they are committed after
            // recalculating visibilities. We just use mParticipants because we can and it will
            // ensure proper reporting of `isInFinishTransition`.
            for (int i = 0; i < mTransientHideTasks.size(); ++i) {
                mTransientHideTasks.get(i).forAllActivities(r -> {
                    // Only check leaf-tasks that were collected
                    if (!mParticipants.contains(r.getTask())) return;
                    // Only concern ourselves with anything that can become invisible
                    if (!r.isVisible()) return;
                    mParticipants.add(r);
                });
            }
            // The transient hide tasks could be occluded now, e.g. returning to home. So trigger
            // The transient hide tasks could be occluded now, e.g. returning to home. So trigger
            // the update to make the activities in the tasks invisible-requested, then the next
            // the update to make the activities in the tasks invisible-requested, then the next
            // step can continue to commit the visibility.
            // step can continue to commit the visibility.
@@ -953,7 +961,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
                        enterAutoPip = true;
                        enterAutoPip = true;
                    }
                    }
                }
                }
                if (mChanges.get(ar).mVisible != visibleAtTransitionEnd) {
                final ChangeInfo changeInfo = mChanges.get(ar);
                // Due to transient-hide, there may be some activities here which weren't in the
                // transition.
                if (changeInfo != null && changeInfo.mVisible != visibleAtTransitionEnd) {
                    // Legacy dispatch relies on this (for now).
                    // Legacy dispatch relies on this (for now).
                    ar.mEnteringAnimation = visibleAtTransitionEnd;
                    ar.mEnteringAnimation = visibleAtTransitionEnd;
                } else if (mTransientLaunches != null && mTransientLaunches.containsKey(ar)
                } else if (mTransientLaunches != null && mTransientLaunches.containsKey(ar)
+4 −2
Original line number Original line Diff line number Diff line
@@ -1410,9 +1410,9 @@ public class TransitionTests extends WindowTestsBase {
        final Transition.ChangeInfo task1ChangeInfo = closeTransition.mChanges.get(task1);
        final Transition.ChangeInfo task1ChangeInfo = closeTransition.mChanges.get(task1);
        assertNotNull(task1ChangeInfo);
        assertNotNull(task1ChangeInfo);
        assertTrue(task1ChangeInfo.hasChanged());
        assertTrue(task1ChangeInfo.hasChanged());
        // Make sure the unrelated activity is NOT collected.
        final Transition.ChangeInfo activity1ChangeInfo = closeTransition.mChanges.get(activity1);
        final Transition.ChangeInfo activity1ChangeInfo = closeTransition.mChanges.get(activity1);
        assertNotNull(activity1ChangeInfo);
        assertNull(activity1ChangeInfo);
        assertTrue(activity1ChangeInfo.hasChanged());
        // No need to wait for the activity in transient hide task.
        // No need to wait for the activity in transient hide task.
        assertEquals(WindowContainer.SYNC_STATE_NONE, activity1.mSyncState);
        assertEquals(WindowContainer.SYNC_STATE_NONE, activity1.mSyncState);


@@ -1442,6 +1442,7 @@ public class TransitionTests extends WindowTestsBase {
                }
                }
            }
            }
        });
        });
        assertTrue(activity1.isVisible());
        controller.finishTransition(closeTransition);
        controller.finishTransition(closeTransition);
        assertTrue(wasInFinishingTransition[0]);
        assertTrue(wasInFinishingTransition[0]);
        assertNull(controller.mFinishingTransition);
        assertNull(controller.mFinishingTransition);
@@ -1450,6 +1451,7 @@ public class TransitionTests extends WindowTestsBase {
        assertEquals(ActivityTaskManagerService.APP_SWITCH_DISALLOW, mAtm.getBalAppSwitchesState());
        assertEquals(ActivityTaskManagerService.APP_SWITCH_DISALLOW, mAtm.getBalAppSwitchesState());
        // Because task1 is occluded by task2, finishTransition should make activity1 invisible.
        // Because task1 is occluded by task2, finishTransition should make activity1 invisible.
        assertFalse(activity1.isVisibleRequested());
        assertFalse(activity1.isVisibleRequested());
        // Make sure activity1 visibility was committed
        assertFalse(activity1.isVisible());
        assertFalse(activity1.isVisible());
        assertFalse(activity1.app.hasActivityInVisibleTask());
        assertFalse(activity1.app.hasActivityInVisibleTask());