From a9c9d9871b43fea3a99d9905935c6d39368e7b15 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Mon, 11 Nov 2019 11:20:19 +0800 Subject: [PATCH] Activity windows should not be focusable if not attached to the hierarchy Top focused activity window was set to invisible and was removed from display. While comparing the current focused window z-order with other windows (in order to update focused window), an exception was thrown because the current focused window was already removed from the hierarchy. Bug: 144146795 Test: existing tests Change-Id: If50012d5d3cbe88d0644daa8ef035007f48d1e5f --- services/core/java/com/android/server/wm/ActivityRecord.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 708e5a19bb0c2..9f70da94258bb 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -42,7 +42,6 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.ROTATION_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; -import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.activityTypeToString; @@ -2241,7 +2240,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return false; } } - return getWindowConfiguration().canReceiveKeys() || isAlwaysFocusable(); + return (getWindowConfiguration().canReceiveKeys() || isAlwaysFocusable()) + && getParent() != null; } /** Move activity with its stack to front and make the stack focused. */