From dfcc9a7ffe12d9b297205c263ef9a665c3c3bdd1 Mon Sep 17 00:00:00 2001 From: Alex Stetson Date: Mon, 10 Jan 2022 12:57:59 -0800 Subject: [PATCH] DO NOT MERGE Allow keyguard_message_area_container to be null In certain applications, the keyguard_message_area_container view may not be present around a KeyguardMessageArea instance. Allowing the container to be nullable and adding the appropriate null checks will prevent exceptions under these circumstances. Bug: 213476245 Bug: 217926975 Test: manual Change-Id: I65a4b6577c7b420ce6a55ae1d459989855c2e7a0 (cherry picked from commit ca21e7624d322bc25f763df8bcfa1f8d36ba9273) --- .../src/com/android/keyguard/KeyguardMessageArea.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java index a7840cbf2789b..87e853cf64d7b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java @@ -31,6 +31,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import androidx.annotation.Nullable; + import com.android.internal.policy.SystemBarUtils; import com.android.settingslib.Utils; import com.android.systemui.R; @@ -58,6 +60,11 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp private ColorStateList mNextMessageColorState = ColorStateList.valueOf(DEFAULT_COLOR); private boolean mBouncerVisible; private boolean mAltBouncerShowing; + /** + * Container that wraps the KeyguardMessageArea - may be null if current view hierarchy doesn't + * contain {@link R.id.keyguard_message_area_container}. + */ + @Nullable private ViewGroup mContainer; private int mContainerTopMargin; private int mLastOrientation = -1; @@ -77,6 +84,9 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp } void onConfigChanged(Configuration newConfig) { + if (mContainer == null) { + return; + } final int newTopMargin = SystemBarUtils.getStatusBarHeight(getContext()); if (mContainerTopMargin != newTopMargin) { mContainerTopMargin = newTopMargin;