From 0e2a67bb701d232a723539e2493588be30036347 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Wed, 4 May 2022 15:16:45 -0700 Subject: [PATCH] Completely remove pinned task when starting a new PiP When a new ActivityRecord tries to replace the existing PiP by explicitly call enterPictureInPictureMode (normally a cause of in-app enter PiP button), it's more desirable that the old PiP disappears instead of turning into full-screen at the same time, as the Task#dismissPip is trying to do. Video: http://recall/-/aaaaaabFQoRHlzixHdtY/ebskmHfvlcwKa3OSBFONWY Bug: 231294285 Test: following the reproduce steps, see video Test: atest PinnedStackTests Change-Id: Ib4fb9be03d1a26a7046c303124224b0ecccabecb --- .../core/java/com/android/server/wm/RootWindowContainer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index c0dff14e5de50..0aab186045286 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -1999,7 +1999,10 @@ class RootWindowContainer extends WindowContainer final Task rootPinnedTask = taskDisplayArea.getRootPinnedTask(); if (rootPinnedTask != null) { transitionController.collect(rootPinnedTask); - rootPinnedTask.dismissPip(); + // The new ActivityRecord should replace the existing PiP, so it's more desirable + // that the old PiP disappears instead of turning to full-screen at the same time, + // as the Task#dismissPip is trying to do. + removeRootTasksInWindowingModes(WINDOWING_MODE_PINNED); } // Set a transition to ensure that we don't immediately try and update the visibility