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

Commit 44dbfdb9 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Request transition when disposing TF organizer

To make sure the changes are collected. Otherwise if the activity
in the TaskFragment is the top app, the previous playing transition
won't be aware of the next resuming activity should be visible.

For example, if there is an opening transition that shows B and
hides A, but A is died suddenly and disposing its TaskFragment,
then B should show again. With the requested CLOSE transition,
the playing transition will be able to merge the transition and
update the surface visibility for A (TO_FRONT) in finishTransaction.

Bug: 288565944
Bug: 287895832
Bug: 297315249
Test: Launch an app which supports embedded activity.
      E.g. Settings with window extensions and large_screen_opt.
      Launch Settings and open SubSettings. Press home key.
      Launch Settings again and enter the command immediately
        adb shell kill -9 $(adb shell pidof com.android.settings)
      Home should still be visible.
Change-Id: I36703c8d54d3b9539ca7987ba62db9dd235b3909
parent 7f052ad3
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -184,14 +184,31 @@ public class TaskFragmentOrganizerController extends ITaskFragmentOrganizerContr
        }

        void dispose() {
            boolean wasVisible = false;
            for (int i = mOrganizedTaskFragments.size() - 1; i >= 0; i--) {
                final TaskFragment taskFragment = mOrganizedTaskFragments.get(i);
                if (taskFragment.isVisibleRequested()) {
                    wasVisible = true;
                }
                // Cleanup the TaskFragmentOrganizer from all TaskFragments it organized before
                // removing the windows to prevent it from adding any additional TaskFragment
                // pending event.
                final TaskFragment taskFragment = mOrganizedTaskFragments.get(i);
                taskFragment.onTaskFragmentOrganizerRemoved();
            }

            final TransitionController transitionController = mAtmService.getTransitionController();
            if (wasVisible && transitionController.isShellTransitionsEnabled()
                    && !transitionController.isCollecting()) {
                final Task task = mOrganizedTaskFragments.get(0).getTask();
                final boolean containsNonEmbeddedActivity =
                        task != null && task.getActivity(a -> !a.isEmbedded()) != null;
                transitionController.requestStartTransition(
                        transitionController.createTransition(WindowManager.TRANSIT_CLOSE),
                        // The task will be removed if all its activities are embedded, then the
                        // task is the trigger.
                        containsNonEmbeddedActivity ? null : task,
                        null /* remoteTransition */, null /* displayChange */);
            }
            // Defer to avoid unnecessary layout when there are multiple TaskFragments removal.
            mAtmService.deferWindowLayout();
            try {