From 5c58aae54d2e7c208e2ff4cff0dd649ddebdc27e Mon Sep 17 00:00:00 2001 From: Aurélien Pomini Date: Mon, 3 Jun 2024 14:31:56 +0000 Subject: Updates the dim for USER_SYSTEM if mCurrentUserId = null If setWallpaperDimAmount is called during boot before WallpaperManagerService#switchUser is called, it will produce a NPE since the mCurrentUserId is still USER_NULL. Instead, update the dim for USER_SYSTEM in that scenario. Flag: NONE, the logic only changes in a case that would produce a NPE otherwise. Test: presubmit Bug: 344545351 Change-Id: I3c8de053837e80fa6dc90f26b61e1f0f3af0eecf --- .../java/com/android/server/wallpaper/WallpaperManagerService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index f8eb78914857..abc6bf698d66 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -2729,8 +2729,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub try { List pendingColorExtraction = new ArrayList<>(); synchronized (mLock) { - WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId); - WallpaperData lockWallpaper = mLockWallpaperMap.get(mCurrentUserId); + // If called in boot before mCurrentUserId is set, sets the dim for USER_SYSTEM. + int userId = mCurrentUserId != UserHandle.USER_NULL + ? mCurrentUserId : UserHandle.USER_SYSTEM; + WallpaperData wallpaper = mWallpaperMap.get(userId); + WallpaperData lockWallpaper = mLockWallpaperMap.get(userId); if (dimAmount == 0.0f) { wallpaper.mUidToDimAmount.remove(uid); -- cgit v1.2.3-59-g8ed1b