Do not force relayout for wallpaper visibility change

The force-relayout was added in [1] for the side effect of [2].
Since the preserve-surface has been completely removed in [3].
So [1] can be restored to avoid unnecessary cost.

WallpaperService always calls relayout with View.VISIBLE, so
unless it requests to remove the wallpaper window, its surface
should not be removed. Though currently there might be no such
cases, add a log in case something goes wrong.

[1]: I79f97df61696eea325183e9b9057cbb10ce8cc66
[2]: Iea8ed86a9c4a7674804152aa44df7ef3d6341768
[3]: I4574ac0d3b8a63b13ac44846e729b73ca0f88f23

Bug: 233599092
Test: No additional relayout from wallpaper when turning on screen,
      swiping/closing up to home.
Test: Toggle overview from wallpaper picker while using live wallpaper.
      The wallpaper won't disappear.

Change-Id: I6673e458b5577f780be17a51cf5de1d6493ab5ca
This commit is contained in:
Riddle Hsu
2022-05-23 22:40:05 -06:00
parent e606dcceb0
commit 07f2a71eda
2 changed files with 9 additions and 2 deletions

View File

@@ -1536,8 +1536,9 @@ public abstract class WallpaperService extends Service {
// may have been destroyed so now we need to make
// sure it is re-created.
doOffsetsChanged(false);
// force relayout to get new surface
updateSurface(true, false, false);
// It will check mSurfaceCreated so no need to force relayout.
updateSurface(false /* forceRelayout */, false /* forceReport */,
false /* redrawNeeded */);
}
onVisibilityChanged(visible);
if (mReportedVisible && mFrozenRequested) {

View File

@@ -139,6 +139,12 @@ class WindowSurfaceController {
"Destroying surface %s called by %s", this, Debug.getCallers(8));
try {
if (mSurfaceControl != null) {
if (mAnimator.mIsWallpaper && !mAnimator.mWin.mWindowRemovalAllowed
&& !mAnimator.mWin.mRemoveOnExit) {
// The wallpaper surface should have the same lifetime as its window.
Slog.e(TAG, "Unexpected removing wallpaper surface of " + mAnimator.mWin
+ " by " + Debug.getCallers(8));
}
t.remove(mSurfaceControl);
}
} catch (RuntimeException e) {