Notify organizer when the last activity in TaskFragment enter PiP

When the Task contains multiple activities, activity entering PiP will
be reparented to a new PiP Task. In this case, we should notify the
organizer about the behavior, and prevent the dependents from closing as
a result of an empty TaskFragment.

Bug: 225371112
Test: atest WmTests:TaskFragmentTest
Change-Id: I6f0138c0532d2d0249de38fd84d1a4690f266c07
This commit is contained in:
Chris Li
2022-04-12 20:42:09 +08:00
parent ff5064e713
commit 63ece2d2e5
5 changed files with 101 additions and 29 deletions

View File

@@ -155,13 +155,18 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
// Check if there are no running activities - consider the container empty if there are no
// non-finishing activities left.
if (!taskFragmentInfo.hasRunningActivity()) {
// TODO(b/225371112): Don't finish dependent if the last activity is moved to the PIP
// Task.
// Do not finish the dependents if this TaskFragment was cleared due to launching
// activity in the Task.
final boolean shouldFinishDependent =
!taskFragmentInfo.isTaskClearedForReuse();
mPresenter.cleanupContainer(container, shouldFinishDependent);
if (taskFragmentInfo.isTaskFragmentClearedForPip()) {
// Do not finish the dependents if the last activity is reparented to PiP.
// Instead, the original split should be cleanup, and the dependent may be expanded
// to fullscreen.
cleanupForEnterPip(container);
mPresenter.cleanupContainer(container, false /* shouldFinishDependent */);
} else {
// Do not finish the dependents if this TaskFragment was cleared due to launching
// activity in the Task.
final boolean shouldFinishDependent = !taskFragmentInfo.isTaskClearedForReuse();
mPresenter.cleanupContainer(container, shouldFinishDependent);
}
} else if (wasInPip && isInPip) {
// No update until exit PIP.
return;