From 44dbfdb975ca07f4b23e639ca70b64f3558cdedc Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 12 Sep 2023 11:52:44 +0000 Subject: 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 --- .../server/wm/TaskFragmentOrganizerController.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java b/services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java index a27cc3ad9973..ea722b61be6f 100644 --- a/services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java +++ b/services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java @@ -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 { -- cgit v1.2.3-59-g8ed1b