From cc367f45128d1a4e7b66e6370a8a13cb76053ff9 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Wed, 1 Feb 2017 08:12:14 -0800 Subject: [PATCH] Fixed NPE during monkey testing. We tried to resume key dispatching for an activity after we destroyed it and removed its container which led to an NPE. We now resume key dispatching for an activity if it is currently paused just before we remove its container to not leave WM in a bad state and also avoid NPE later on. Change-Id: I89d366c8667e621f4515df802c6b8278fa4bd322 Fixes: 34808323 Test: adb shell monkey -p ... --- services/core/java/com/android/server/am/ActivityRecord.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index baf7772206919..2b0544e52af6c 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -749,6 +749,9 @@ final class ActivityRecord implements AppWindowContainerListener { } void removeWindowContainer() { + // Resume key dispatching if it is currently paused before we remove the container. + resumeKeyDispatchingLocked(); + mWindowContainerController.removeContainer(getDisplayId()); mWindowContainerController = null; }