From d558f89afcc3d0c4f3c9d1b8021d7b6abcb774af Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Fri, 12 May 2023 13:39:49 +0000 Subject: [PATCH] Fix a NPE in InputMonitor#updateInputFocusRequest ..introduced by CL[1] that getTask() may null if the activity is removing. [1]: I71f397b93b9f94e9351ded8191676b1dfb249d9e Fix: 282114478 Bug: 222064495 Test: all tests passed Change-Id: Ie24370d4ae06a82e9e5ab4d0f728226cc11b8852 --- services/core/java/com/android/server/wm/InputMonitor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 0b960ec2a5837..b67ccd2a7672b 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -439,7 +439,9 @@ final class InputMonitor { ? mDisplayContent.getImeInputTarget().getActivityRecord() : null; if (app != null) { mDisplayContent.removeImeSurfaceImmediately(); - mDisplayContent.mAtmService.takeTaskSnapshot(app.getTask().mTaskId); + if (app.getTask() != null) { + mDisplayContent.mAtmService.takeTaskSnapshot(app.getTask().mTaskId); + } } } else { // Disable IME icon explicitly when IME attached to the app in case