diff options
| author | 2022-12-01 16:56:02 +0800 | |
|---|---|---|
| committer | 2023-01-07 20:29:34 +0800 | |
| commit | dbfa31c2b48c94cfc03219f96e171899fc8cc773 (patch) | |
| tree | d1fa4c791ce2f6a928a01ee082efc70865ae662a | |
| parent | f30746816ae9677199f2e8bb013d27d4cfb968f4 (diff) | |
Use parent frame to update wallpaper offset
This partial reverts [1], which is similar to restore to [2].
Because shell rotation transition was disabled and currently
shell also doesn't control wallpaper, the corresponding changes
can be restored to avoid side effects. Such as after changing
screen resolution, the last reported bounds may be still old
size, which leads to a temporary additional offset.
If shell rotation transition may be re-enabled in the future,
the correct fix should be to stop updating window frames of
invisible requested window instead of trying to use previous
bounds to calculate, i.e. keep parent frame in previous rotation.
[1]: I1db9207c79bc45dedd90e7b13af5517f09abe4a7
[2]: Icf55e3570c260b963fab6dc85814f9e8e305163c
Bug: 264018192
Test: WallpaperControllerTests
Change-Id: Ia6bf26b4576dcf9a036c3b8686e015e19fbf57a2
3 files changed, 6 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index 1d25dbc0d533..b2dab78b993d 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -371,7 +371,7 @@ class WallpaperController { boolean updateWallpaperOffset(WindowState wallpaperWin, boolean sync) { // Size of the display the wallpaper is rendered on. - final Rect lastWallpaperBounds = wallpaperWin.getLastReportedBounds(); + final Rect lastWallpaperBounds = wallpaperWin.getParentFrame(); // Full size of the wallpaper (usually larger than bounds above to parallax scroll when // swiping through Launcher pages). final Rect wallpaperFrame = wallpaperWin.getFrame(); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 04699619bfc8..ba4ff3762062 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -3081,12 +3081,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return mLastReportedConfiguration.getMergedConfiguration(); } - /** Returns the last window configuration bounds reported to the client. */ - Rect getLastReportedBounds() { - final Rect bounds = getLastReportedConfiguration().windowConfiguration.getBounds(); - return !bounds.isEmpty() ? bounds : getBounds(); - } - void adjustStartingWindowFlags() { if (mAttrs.type == TYPE_BASE_APPLICATION && mActivityRecord != null && mActivityRecord.mStartingWindow != null) { @@ -4421,6 +4415,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP pw.print("null"); } + if (mXOffset != 0 || mYOffset != 0) { + pw.println(prefix + "mXOffset=" + mXOffset + " mYOffset=" + mYOffset); + } if (mHScale != 1 || mVScale != 1) { pw.println(prefix + "mHScale=" + mHScale + " mVScale=" + mVScale); @@ -5573,7 +5570,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mSurfacePosition); if (mWallpaperScale != 1f) { - final Rect bounds = getLastReportedBounds(); + final Rect bounds = getParentFrame(); Matrix matrix = mTmpMatrix; matrix.setTranslate(mXOffset, mYOffset); matrix.postScale(mWallpaperScale, mWallpaperScale, bounds.exactCenterX(), diff --git a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java index 06a79f47de55..1407cdd8600c 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java @@ -391,7 +391,7 @@ public class WallpaperControllerTests extends WindowTestsBase { dc.updateOrientation(); dc.sendNewConfiguration(); spyOn(wallpaperWindow); - doReturn(new Rect(0, 0, width, height)).when(wallpaperWindow).getLastReportedBounds(); + doReturn(new Rect(0, 0, width, height)).when(wallpaperWindow).getParentFrame(); } @Test |