From fdd50fb110440407d748cb4c8f0f6429cfc6d1c1 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Fri, 23 Apr 2021 18:32:06 -0400 Subject: [PATCH] Add extra null-checks to WallpaperManagerService. Test: Wallpaper API still works Bug: 186263410 Change-Id: I7effb855003724fa79eea11b7df9fe027bb98896 --- .../wallpaper/WallpaperManagerService.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 9acbdcc177ccf..c888e545b24ea 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -2384,17 +2384,19 @@ public class WallpaperManagerService extends IWallpaperManager.Stub public void notifyWakingUp(int x, int y, @NonNull Bundle extras) { synchronized (mLock) { final WallpaperData data = mWallpaperMap.get(mCurrentUserId); - data.connection.forEachDisplayConnector( - displayConnector -> { - if (displayConnector.mEngine != null) { - try { - displayConnector.mEngine.dispatchWallpaperCommand( - WallpaperManager.COMMAND_WAKING_UP, x, y, -1, extras); - } catch (RemoteException e) { - e.printStackTrace(); + if (data != null && data.connection != null) { + data.connection.forEachDisplayConnector( + displayConnector -> { + if (displayConnector.mEngine != null) { + try { + displayConnector.mEngine.dispatchWallpaperCommand( + WallpaperManager.COMMAND_WAKING_UP, x, y, -1, extras); + } catch (RemoteException e) { + e.printStackTrace(); + } } - } - }); + }); + } } } @@ -2404,17 +2406,20 @@ public class WallpaperManagerService extends IWallpaperManager.Stub public void notifyGoingToSleep(int x, int y, @NonNull Bundle extras) { synchronized (mLock) { final WallpaperData data = mWallpaperMap.get(mCurrentUserId); - data.connection.forEachDisplayConnector( - displayConnector -> { - if (displayConnector.mEngine != null) { - try { - displayConnector.mEngine.dispatchWallpaperCommand( - WallpaperManager.COMMAND_GOING_TO_SLEEP, x, y, -1, extras); - } catch (RemoteException e) { - e.printStackTrace(); + if (data != null && data.connection != null) { + data.connection.forEachDisplayConnector( + displayConnector -> { + if (displayConnector.mEngine != null) { + try { + displayConnector.mEngine.dispatchWallpaperCommand( + WallpaperManager.COMMAND_GOING_TO_SLEEP, x, y, -1, + extras); + } catch (RemoteException e) { + e.printStackTrace(); + } } - } - }); + }); + } } }