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

Commit 91184837 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

[PiP2] Handle legacy case if organized TF present

If an app uses AE, but its TF is effectively filling
the task or if it isn't really changing, it still might get
added into the changes list (task fragments can be organized which
are always added to the list of targets even if canPromote() returns
true).

So on Shell side we can effectively count such container "chains"
as one underlying change under a root PiP task. This way we can still
animate it as a normal single-activity legacy-enter PiP transition.

Bug: 398862854
Flag: com.android.wm.shell.enable_pip2
Test: swipe-to-enter PiP from a Whatsapp call
Change-Id: I8f06fdcb607680230ab31909113184f97de28252
parent 43111cf9
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -794,9 +794,26 @@ public class PipTransition extends PipTransitionController implements
                setEnterAnimationType(ANIM_TYPE_BOUNDS);
                return true;
            }
            // If the only change in the changes list is a opening type PiP task,

            // Sometimes root PiP task can have TF children. These child containers can be collected
            // even if they can promote to their parents: e.g. if they are marked as "organized".
            // So we count the chain of containers under PiP task as one "real" changing target;
            // iterate through changes bottom-to-top to properly identify parents.
            int expectedTargetCount = 1;
            WindowContainerToken lastPipChildToken = pipChange.getContainer();
            for (int i = info.getChanges().size() - 1; i >= 0; --i) {
                TransitionInfo.Change change = info.getChanges().get(i);
                if (change == pipChange || change.getContainer() == null) continue;
                if (change.getParent() != null && change.getParent().equals(lastPipChildToken)) {
                    // Allow an extra change since our pinned root task has a child.
                    ++expectedTargetCount;
                    lastPipChildToken = change.getContainer();
                }
            }

            // If the only root task change in the changes list is a opening type PiP task,
            // then this is legacy-enter PiP.
            return info.getChanges().size() == 1
            return info.getChanges().size() == expectedTargetCount
                    && TransitionUtil.isOpeningMode(pipChange.getMode());
        }
        return false;