From 50038ee313b5f499b582ddf6261e2656cc773ce9 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Fri, 24 Apr 2020 17:09:12 -0700 Subject: [PATCH] Don't check parent's persistTaskBounds unless child is UNDEFINED. When Task gets an onConfigurationChanged call with a requested overriding configuration, it checks for itself and its parent's ability to see if persisting task bounds is possible or not. This was done for the case of freeform window support, where if the current window is undefined (persistBounds = false), it will then check for the parents (could be clamhshell, which persistBounds = true, or tablet, which persistBounds = false). However, there exists a case where this does not work well, which is when freeform window (inheriting from a freeform display) enters PIP, pinned windowing mode. We have already provided new PIP bounds, but since undefined window are not persistable and neither is PIP, but PIP's parent (the freeform display) is, it will end up setting the new bounds back to mLastNonFullscreenBounds, which is the freeform bounds. We then end up losing the new PIP bounds. Bug: 152911516 Test: On a freeform display, open an activity and enter PIP - PIP activity now has the correct bounds Change-Id: If73523ba1c54274eb5be4af5b967c6fef2993898 --- services/core/java/com/android/server/wm/Task.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 66e1b1758d851..160a649aa51aa 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1930,9 +1930,11 @@ class Task extends WindowContainer { // Check if the new configuration supports persistent bounds (eg. is Freeform) and if so // restore the last recorded non-fullscreen bounds. final boolean prevPersistTaskBounds = getWindowConfiguration().persistTaskBounds(); - final boolean nextPersistTaskBounds = - getRequestedOverrideConfiguration().windowConfiguration.persistTaskBounds() - || newParentConfig.windowConfiguration.persistTaskBounds(); + boolean nextPersistTaskBounds = + getRequestedOverrideConfiguration().windowConfiguration.persistTaskBounds(); + if (getRequestedOverrideWindowingMode() == WINDOWING_MODE_UNDEFINED) { + nextPersistTaskBounds = newParentConfig.windowConfiguration.persistTaskBounds(); + } if (!prevPersistTaskBounds && nextPersistTaskBounds && mLastNonFullscreenBounds != null && !mLastNonFullscreenBounds.isEmpty()) { // Bypass onRequestedOverrideConfigurationChanged here to avoid infinite loop.