diff options
| author | 2021-04-05 12:08:48 -0700 | |
|---|---|---|
| committer | 2021-04-05 12:08:48 -0700 | |
| commit | b32b6acfe20cc2e8016aba794fef3dd8daaee01a (patch) | |
| tree | f75b5a6c09738c24906f4c45661cbb1ea10c97ee | |
| parent | 9ad3b820bef9de56d1e07f9857bddaeaf2df768a (diff) | |
Call surfaceplacement if the window goes for relayout
We do not perform surface placement on the window if its considered
gone for relayout. This change was introduced to prevent us from
using invalid mFrames. However there is a discrepancy in the gone
for relayout check. We will still relayout a window if the window is
not currently visible but a layout is request of reasons such as
window size changed. Fix this by requesting a surface placement
if relayout is requested.
This fixes an issue where a toast window created under the lock screen,
shows up with the wrong position for a few frames.
Test: go/wm-smoke
Test: open toast under lock screen, check toast appears in the correct position
Fixes: 175668342
Change-Id: Ibfe6aeb5704a348014e2ebca996874ebae18fdd2
| -rw-r--r-- | services/core/java/com/android/server/wm/DisplayContent.java | 2 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowState.java | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index a9d33dc29467..e5f0cc55ea1d 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -776,6 +776,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (mTmpInitial) { w.resetContentChanged(); } + w.mSurfacePlacementNeeded = true; w.mLayoutNeeded = false; w.prelayout(); final boolean firstLayout = !w.isLaidOut(); @@ -818,6 +819,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial"); w.resetContentChanged(); } + w.mSurfacePlacementNeeded = true; w.mLayoutNeeded = false; w.prelayout(); getDisplayPolicy().layoutWindowLw(w, w.getParentWindow(), mDisplayFrames); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 171e93fb4df9..808a014ff6df 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -513,6 +513,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP */ boolean mLayoutNeeded; + /** + * If the application is not currently visible but requires a layout, + * then make sure we call performSurfacePlacement as well. This is set + * in layout if mLayoutNeeded is set until surface placement is done. + */ + boolean mSurfacePlacementNeeded; + /** Currently running an exit animation? */ boolean mAnimatingExit; @@ -5368,7 +5375,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mIsDimming = false; applyDims(); updateSurfacePositionNonOrganized(); - // Send information to SufaceFlinger about the priority of the current window. + // Send information to SurfaceFlinger about the priority of the current window. updateFrameRateSelectionPriorityIfNeeded(); if (isVisibleRequested()) updateGlobalScaleIfNeeded(); @@ -5382,13 +5389,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP if (mSurfaceControl == null) { return; } - if (mWmService.mWindowPlacerLocked.isLayoutDeferred() || isGoneForLayout()) { + + if ((mWmService.mWindowPlacerLocked.isLayoutDeferred() || isGoneForLayout()) + && !mSurfacePlacementNeeded) { // Since this relies on mWindowFrames, changes made while layout is deferred are // likely to be invalid. Similarly, if it's goneForLayout, mWindowFrames may not be // up-to-date and thus can't be relied on. return; } + mSurfacePlacementNeeded = false; transformFrameToSurfacePosition(mWindowFrames.mFrame.left, mWindowFrames.mFrame.top, mSurfacePosition); |