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
This commit is contained in:
Riddle Hsu
2022-12-01 16:56:02 +08:00
parent f30746816a
commit dbfa31c2b4
3 changed files with 6 additions and 9 deletions

View File

@@ -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();

View File

@@ -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(),

View File

@@ -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