From 99114e35ead06b411583058b8e25620f6a1458d1 Mon Sep 17 00:00:00 2001 From: Julia Tuttle Date: Mon, 23 May 2022 15:29:19 -0400 Subject: [PATCH] Avert potential crashes in NotificationChildrenContainer.getMinHeight It's unclear if these crashes are causing the setup wizard hang in the bug or if these crashes and the hang share a common root cause, but convert them to logged errors just in case. Bug: 231915007 Test: atest PlatformScenarioTests Change-Id: I89892bd2cae8e99040cd0636b1d1f775c4d97653 --- .../stack/NotificationChildrenContainer.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java index dad06d91dea19..d897b976fc9e2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java @@ -24,6 +24,7 @@ import android.content.res.TypedArray; import android.graphics.drawable.ColorDrawable; import android.service.notification.StatusBarNotification; import android.util.AttributeSet; +import android.util.Log; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.NotificationHeaderView; @@ -58,6 +59,8 @@ import java.util.List; public class NotificationChildrenContainer extends ViewGroup implements NotificationFadeAware { + private static final String TAG = "NotificationChildrenContainer"; + @VisibleForTesting static final int NUMBER_OF_CHILDREN_WHEN_COLLAPSED = 2; @VisibleForTesting @@ -1144,6 +1147,10 @@ public class NotificationChildrenContainer extends ViewGroup private int getMinHeight(int maxAllowedVisibleChildren, boolean likeHighPriority, int headerTranslation) { if (!likeHighPriority && showingAsLowPriority()) { + if (mNotificationHeaderLowPriority == null) { + Log.e(TAG, "getMinHeight: low priority header is null", new Exception()); + return 0; + } return mNotificationHeaderLowPriority.getHeight(); } int minExpandHeight = mNotificationHeaderMargin + headerTranslation; @@ -1160,7 +1167,13 @@ public class NotificationChildrenContainer extends ViewGroup firstChild = false; } ExpandableNotificationRow child = mAttachedChildren.get(i); - minExpandHeight += child.getSingleLineView().getHeight(); + View singleLineView = child.getSingleLineView(); + if (singleLineView != null) { + minExpandHeight += singleLineView.getHeight(); + } else { + Log.e(TAG, "getMinHeight: child " + child + " single line view is null", + new Exception()); + } visibleChildren++; } minExpandHeight += mCollapsedBottomPadding;