From 7c64525d1caa3996d65f01f1fe3145b9bea27cd2 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Wed, 20 Apr 2022 14:14:36 -0700 Subject: [PATCH] PiP: Re-attach PiP menu when display changes. When changing the display (e.g. foldables that fold/unfolds) while the menu is showing, it seems the SF layers go through some changes that get the menu in a bad state and no longer renders correctly. Just teardown and recreate/re-attach the menu instead. Bug: 218987352 Test: Unfold/fold device while menu is showing, menu still shows up afterwards Change-Id: I4255191c3298cf663b6a0428ece6f34fd96ff3a6 --- .../com/android/wm/shell/pip/phone/PhonePipMenuController.java | 2 +- .../Shell/src/com/android/wm/shell/pip/phone/PipController.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java index f73b81e9d3f3e..50f373f09b20a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java @@ -171,7 +171,7 @@ public class PhonePipMenuController implements PipMenuController { detachPipMenuView(); } - private void attachPipMenuView() { + void attachPipMenuView() { // In case detach was not called (e.g. PIP unexpectedly closed) if (mPipMenuView != null) { detachPipMenuView(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index 175a2445f28d9..272331b7cd3fd 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -521,6 +521,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb }; if (mPipTaskOrganizer.isInPip() && saveRestoreSnapFraction) { + mMenuController.attachPipMenuView(); // Calculate the snap fraction of the current stack along the old movement bounds final PipSnapAlgorithm pipSnapAlgorithm = mPipBoundsAlgorithm.getSnapAlgorithm(); final Rect postChangeStackBounds = new Rect(mPipBoundsState.getBounds());