From 31e9ca615b326f5b46e58dbd3716fe5bbb0517ed Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 15 Apr 2021 19:41:07 +0800 Subject: [PATCH] Fix NPE if display is off and then removed The additional display can be removed right after turning off. Bug: 185460118 Test: Toggle display Change-Id: I25d86e952f5e24f3165ce556b6435ba61b59f596 --- .../java/com/android/server/wm/TaskSnapshotController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java index 5ffab483202f0..a467d82b362e0 100644 --- a/services/core/java/com/android/server/wm/TaskSnapshotController.java +++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java @@ -646,8 +646,12 @@ class TaskSnapshotController { if (shouldDisableSnapshots()) { return; } + final DisplayContent displayContent = mService.mRoot.getDisplayContent(displayId); + if (displayContent == null) { + return; + } mTmpTasks.clear(); - mService.mRoot.getDisplayContent(displayId).forAllTasks(task -> { + displayContent.forAllTasks(task -> { // Since RecentsAnimation will handle task snapshot while switching apps with the best // capture timing (e.g. IME window capture), No need additional task capture while task // is controlled by RecentsAnimation.