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

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

Check if activity entering PiP is a top activity

We need to make sure we handle any trampoline activity
start cases where, for instance, some Activity A,
start another activity B on creation, but then,
the activity A calls to enterPictureInPictureMode().

This also fixes an issue with the AE case which is why
the earlier version of this CL was reverted at ag/28822947

Bug: 359944953
Flag: com.android.wm.shell.enable_pip2_implementation
Test: atest PinnedStackTests#testAutoEnterPictureInPictureLaunchActivity
Test: atest SplitAttributesCalculatorTest
Change-Id: I30a28ad60a01d3f2192644ef150b22f7f36f7220
parent a9144842
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3292,6 +3292,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return false;
        }

        // Check if activity is top activity of its task fragment - this prevents any trampolines
        // followed by enterPictureInPictureMode() calls by an activity from below in its stack.
        if (getTaskFragment() == null || getTaskFragment().getTopNonFinishingActivity() != this) {
            return false;
        }

        // Check to see if PiP is supported for the display this container is on.
        if (mDisplayContent != null && !mDisplayContent.mDwpcHelper.isEnteringPipAllowed(
                getUid())) {