diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 883ce99d313df..bfe1f30f671ad 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -5603,19 +5603,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A "makeInvisible", true /* beforeStopping */); // Defer telling the client it is hidden if it can enter Pip and isn't current paused, // stopped or stopping. This gives it a chance to enter Pip in onPause(). - // TODO: There is still a question surrounding activities in multi-window mode that want - // to enter Pip after they are paused, but are still visible. I they should be okay to - // enter Pip in those cases, but not "auto-Pip" which is what this condition covers and - // the current contract for "auto-Pip" is that the app should enter it before onPause - // returns. Just need to confirm this reasoning makes sense. final boolean deferHidingClient = canEnterPictureInPicture && !isState(STARTED, STOPPING, STOPPED, PAUSED); - if (!mTransitionController.isShellTransitionsEnabled() - && deferHidingClient && pictureInPictureArgs.isAutoEnterEnabled()) { - // Go ahead and just put the activity in pip if it supports auto-pip. - mAtmService.enterPictureInPictureMode(this, pictureInPictureArgs); - return; - } setDeferHidingClient(deferHidingClient); setVisibility(false); diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index d187bd6f3dfdf..2ac41a7c1c1d2 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -1459,7 +1459,8 @@ class TaskFragment extends WindowContainer { // next activity. final boolean lastResumedCanPip = prev.checkEnterPictureInPictureState( "shouldAutoPipWhilePausing", userLeaving); - if (lastResumedCanPip && prev.pictureInPictureArgs.isAutoEnterEnabled()) { + if (userLeaving && lastResumedCanPip + && prev.pictureInPictureArgs.isAutoEnterEnabled()) { shouldAutoPip = true; } else if (!lastResumedCanPip) { // If the flag RESUME_WHILE_PAUSING is set, then continue to schedule the previous