From c6036ba887e926cd7912f18ddbc8c81605d0175e Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 24 Nov 2020 15:07:30 -0800 Subject: [PATCH] WallpaperService: Respond to WM protocol change. The client is now responsible for updating the size of its own Surface. When we updated ViewRootImpl we forgot to make this change for wallpaper service. Bug: 172346563 Test: Existing tests pass. Change-Id: I2107106c8057151f3fa0d9761ce88abeefc58350 --- .../java/android/service/wallpaper/WallpaperService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 9a76f19f3e416..37637119c70af 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -199,6 +199,7 @@ public abstract class WallpaperService extends Service { final InsetsSourceControl[] mTempControls = new InsetsSourceControl[0]; final MergedConfiguration mMergedConfiguration = new MergedConfiguration(); private final Point mSurfaceSize = new Point(); + private final Point mLastSurfaceSize = new Point(); private final Matrix mTmpMatrix = new Matrix(); private final float[] mTmpValues = new float[9]; @@ -908,6 +909,14 @@ public abstract class WallpaperService extends Service { if (mSurfaceControl.isValid()) { mSurfaceHolder.mSurface.copyFrom(mSurfaceControl); } + if (!mLastSurfaceSize.equals(mSurfaceSize)) { + mLastSurfaceSize.set(mSurfaceSize.x, mSurfaceSize.y); + if (mSurfaceControl != null && mSurfaceControl.isValid()) { + SurfaceControl.Transaction t = new SurfaceControl.Transaction(); + t.setBufferSize(mSurfaceControl, mSurfaceSize.x, mSurfaceSize.y); + t.apply(); + } + } if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface + ", frame=" + mWinFrames);