From 96e2ff400264f2d9716b4caea0eb072b07921249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pomini?= Date: Mon, 17 Jul 2023 17:31:06 +0000 Subject: [PATCH] Release lock before color extraction on dim changes notifyWallpaperColorsChanged should always be called outside the lock since it may trigger heavy color computations. This is necessary in order to remove the old code paths of clearWallpaperLocked without causing boot time regressions. Flag: lockscreen live wallpaper Bug: 273443374 Test: atest WallpaperManagerTest Change-Id: Ib2b6dde8b65058874d2a4c014fa7de47320e6457 --- .../android/server/wallpaper/WallpaperManagerService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index ee7dc5007d979..309a9c0e0372e 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -2895,6 +2895,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub checkPermission(android.Manifest.permission.SET_WALLPAPER_DIM_AMOUNT); final long ident = Binder.clearCallingIdentity(); try { + List pendingColorExtraction = new ArrayList<>(); synchronized (mLock) { WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId); WallpaperData lockWallpaper = mLockWallpaperMap.get(mCurrentUserId); @@ -2930,7 +2931,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub // Need to extract colors again to re-calculate dark hints after // applying dimming. wp.mIsColorExtractedFromDim = true; - notifyWallpaperColorsChanged(wp, wp.mWhich); + pendingColorExtraction.add(wp); changed = true; } } @@ -2962,6 +2963,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } } } + for (WallpaperData wp: pendingColorExtraction) { + notifyWallpaperColorsChanged(wp, wp.mWhich); + } } finally { Binder.restoreCallingIdentity(ident); }