From dcf8a9c0f180ce0b392c5deb36a98c8b761c5d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ciche=C5=84ski?= Date: Sat, 14 Jan 2023 02:14:38 +0000 Subject: [PATCH] Don't add a dismiss target to WM if we're not in PiP. This prevents adding dismiss-overlay window even when user never had entered PiP mode. (e.g. booting a device) Otherwise we re-add the same dismiss target in onConfigurationChange and it doesn't get removed properly in onOverlayChanged that calls init(). That in turn is caused because the same View is being added twice, and the corresponding AttachInfo is not set properly the second time, which prevents the removal logic in init() from working correctly. It is not set properly because the ViewRootImpl traversal didn't have a chance to set the mAttachInfo in the first traversal, when the onOverlayChanged gets called. Test: atest WMShellFlickerTests Bug: 258120818 Change-Id: I9bca4d179aabe6f95d0416cd457d4707b25e113c --- .../src/com/android/wm/shell/pip/phone/PipTouchHandler.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java index 83bc7c0e6e7d9..850c561c891fe 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java @@ -337,8 +337,10 @@ public class PipTouchHandler { mMotionHelper.synchronizePinnedStackBounds(); reloadResources(); - // Recreate the dismiss target for the new orientation. - mPipDismissTargetHandler.createOrUpdateDismissTarget(); + if (mPipTaskOrganizer.isInPip()) { + // Recreate the dismiss target for the new orientation. + mPipDismissTargetHandler.createOrUpdateDismissTarget(); + } } public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {