From 82378198a9fb4b65acfaab9e78ead1fe6afcb688 Mon Sep 17 00:00:00 2001 From: Yuncheol Heo Date: Thu, 18 Mar 2021 12:34:41 -0700 Subject: Fix NPE in ActivityRecord.inSizeCompatMode() - Since commit c3cb0cb, isSizeCompatMode is included in protoDump. If ActivityMetricsLogger dumps log and the Activity is in detached state, then 'parent' can be null. Bug: 183043632 Test: atest AndroidCarApiTest in cf_x86_auto-userdebug Change-Id: I823e787ce4f1c70736edcb10e043a4062a31e774 --- services/core/java/com/android/server/wm/ActivityRecord.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index a909c6d119e8..259dffdf1231 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -6772,7 +6772,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // The app bounds hasn't been computed yet. return false; } - final Configuration parentConfig = getParent().getConfiguration(); + final WindowContainer parent = getParent(); + if (parent == null) { + // The parent of detached Activity can be null. + return false; + } + final Configuration parentConfig = parent.getConfiguration(); // Although colorMode, screenLayout, smallestScreenWidthDp are also fixed, generally these // fields should be changed with density and bounds, so here only compares the most // significant field. -- cgit v1.2.3-59-g8ed1b