diff options
| -rw-r--r-- | services/core/java/com/android/server/wallpaper/WallpaperManagerService.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 0536ff155513..b888ec21e708 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -1301,15 +1301,13 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { } void switchUser(int userId, IRemoteCallback reply) { - WallpaperData systemWallpaper; - WallpaperData lockWallpaper; + final WallpaperData systemWallpaper; + final WallpaperData lockWallpaper; synchronized (mLock) { mCurrentUserId = userId; systemWallpaper = getWallpaperSafeLocked(userId, FLAG_SYSTEM); - lockWallpaper = mLockWallpaperMap.get(userId); - if (lockWallpaper == null) { - lockWallpaper = systemWallpaper; - } + final WallpaperData tmpLockWallpaper = mLockWallpaperMap.get(userId); + lockWallpaper = tmpLockWallpaper == null ? systemWallpaper : tmpLockWallpaper; // Not started watching yet, in case wallpaper data was loaded for other reasons. if (systemWallpaper.wallpaperObserver == null) { systemWallpaper.wallpaperObserver = new WallpaperObserver(systemWallpaper); @@ -1317,8 +1315,13 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { } switchWallpaper(systemWallpaper, reply); } - notifyWallpaperColorsChanged(systemWallpaper, FLAG_SYSTEM); - notifyWallpaperColorsChanged(lockWallpaper, FLAG_LOCK); + + // Offload color extraction to another thread since switchUser will be called + // from the main thread. + FgThread.getHandler().post(() -> { + notifyWallpaperColorsChanged(systemWallpaper, FLAG_SYSTEM); + notifyWallpaperColorsChanged(lockWallpaper, FLAG_LOCK); + }); } void switchWallpaper(WallpaperData wallpaper, IRemoteCallback reply) { |