summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ashok Mutyala <quic_c_nmutya@quicinc.com> 2021-08-12 12:36:21 +0000
committer Chilun <chilunhuang@google.com> 2021-10-12 17:58:01 +0800
commitfd53e5766e34f79c33674c4d7443b66f34c185c1 (patch)
tree02efc0c394f4d1de71f26dcc1177db995c2fcc40
parent8b701b0813d24f3a2e036fefa083c656dbf0e6e8 (diff)
Avoid the scenario where Contexts list filled with null value in ShowAnrDialogs()
Problem: Framework Reboot i.e., NullPointer Exception in android.ui Thread E AndroidRuntime: FATAL EXCEPTION IN SYSTEM PROCESS: android.ui E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference E AndroidRuntime: **at android.app.Dialog.<init>(Dialog.java:199) E AndroidRuntime: **at android.app.AlertDialog.<init>(AlertDialog.java:204) E AndroidRuntime: **at android.app.AlertDialog.<init>(AlertDialog.java:200) E AndroidRuntime: **at com.android.server.am.BaseErrorDialog.<init>(BaseErrorDialog.java:39) E AndroidRuntime: **at com.android.server.am.AppNotRespondingDialog.<init>(AppNotRespondingDialog.java:53) E AndroidRuntime: **at com.android.server.am.ErrorDialogController.showAnrDialogs(ErrorDialogController.java:183) E AndroidRuntime: **at com.android.server.am.AppErrors.handleShowAnrUi(AppErrors.java:1077) Analysis: As Context Object is passed from showAnrDialogs method and will be retrieved from getDisplayContextWithErrorDialogs And list of context objects will be filled by querying from RootWindowContainer.getDisplayUiContext and this method is Annotated with Nullable. So, the possibility could be null value filled in the context object List. Bug: 196189977 Bug: 200337305 Test: Stability Test Original Change-Id: Ib944fc5ffc8bcca999c75f99d462d441e555fcda Change-Id: I28bf8de72b4f6bce9210bb29fde2b3d989911c0e (cherry picked from commit 25b5d20adf26a0a402d81d49ff948bf96b79cea5)
-rw-r--r--services/core/java/com/android/server/wm/WindowProcessController.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java
index 719d52c89209..af386419d455 100644
--- a/services/core/java/com/android/server/wm/WindowProcessController.java
+++ b/services/core/java/com/android/server/wm/WindowProcessController.java
@@ -952,7 +952,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
final int displayId = r.getDisplayId();
final Context c = root.getDisplayUiContext(displayId);
- if (r.mVisibleRequested && !displayContexts.contains(c)) {
+ if (c != null && r.mVisibleRequested && !displayContexts.contains(c)) {
displayContexts.add(c);
}
}