From 7c288db5359427973d8751d69e9014649bda29ec Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Wed, 14 Sep 2022 16:02:44 -0700 Subject: [PATCH] Do not auto-pip on launching translucent activity Note we only prevent Activity from auto-pip in this case. Launching a translucent Activity still sets ActivityTaskSupervisor#mUserLeaving to be true and a non-auto-pip Activity will request to enter PiP when they receive the onUserLeaveHint callback. Bug: 245735998 Test: `adb shell am start -n ` over YT Test: atest PinnedStackTests Change-Id: Iee4dc55592d3e9851174d18759917dd14f5c0071 --- services/core/java/com/android/server/wm/TaskFragment.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 036a292c31743..d13cfdb5927b9 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -1595,12 +1595,14 @@ class TaskFragment extends WindowContainer { boolean pauseImmediately = false; boolean shouldAutoPip = false; if (resuming != null) { + // We do not want to trigger auto-PiP upon launch of a translucent activity. + final boolean resumingOccludesParent = resuming.occludesParent(); // Resuming the new resume activity only if the previous activity can't go into Pip // since we want to give Pip activities a chance to enter Pip before resuming the // next activity. final boolean lastResumedCanPip = prev.checkEnterPictureInPictureState( "shouldAutoPipWhilePausing", userLeaving); - if (userLeaving && lastResumedCanPip + if (userLeaving && resumingOccludesParent && lastResumedCanPip && prev.pictureInPictureArgs.isAutoEnterEnabled()) { shouldAutoPip = true; } else if (!lastResumedCanPip) {