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

Commit 03d7d474 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

[PiP2] Do not pip when candidate transient hides

In PiP2, we are setting/resetting supportsEnterPipOnTaskSwitch
downstream as we startPausing, right before we decide to auto-enter or
not.

This means in cases like quickswitch, where there is a follow-up
transition, we can't really rely on ActivityOptions$mTransientLaunch
to decide whether to set the flag or not (only the first transition
transient launches home, the follow-up quickswitch transition doesn't
transient launch the next toFrontActivity).

Thus, a more reliable way of checking whether we are in quickswitch, for
instance, is whether the pipCandidate's root task is transient hiding,
as the first recents transition that is still playing and is waiting for
the second one to merge into it will also be checked for transient
hides.

Bug: 406503807
Flag: com.android.wm.shell.enable_pip2
Test: manually repro the steps in the bug

Change-Id: If35e9ed86c3d865300d0635acdb56b42291def0b
parent cf320c95
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -5422,8 +5422,18 @@ class Task extends TaskFragment {
            Slog.e(TAG, "No root task for enter pip, both to front task and activity are null?");
            return;
        }

        // If we are updating the flag when a follow-up transition to the still playing transient
        // transition starts collecting, the toFrontActivity might not be transient launch anymore.
        // Instead, checking whether PiP candidate's task is transient hide would be more reliable;
        // e.g. second transition is quickswitch flow might not transient launch toFrontActivity.
        final boolean isPipCandidateTransientHide = pipCandidate.getRootTask() != null
                && targetRootTask.mTransitionController.isTransientHide(pipCandidate.getRootTask());

        final boolean isTransient = opts != null && opts.getTransientLaunch()
                || (targetRootTask.mTransitionController.isTransientHide(targetRootTask));
                || (targetRootTask.mTransitionController.isTransientHide(targetRootTask))
                || (ActivityTaskManagerService.isPip2ExperimentEnabled()
                && isPipCandidateTransientHide);

        // Ensure the task/activity being brought forward is not the assistant and is not transient
        // nor transient hide target. In the case of transient-launch, we want to wait until the end