From 514e43a6ab42a6928f3ac740d0a82be902d5941d Mon Sep 17 00:00:00 2001 From: Shen Lin Date: Sun, 29 Jan 2023 10:53:22 +0800 Subject: [PATCH] Change mODICaptionsTooltipView null check occasion to avoid potential crash Null check before a runnable can not guarantee a non-null mODICaptionsTooltipView when it starts running. This CL switched the null check occasion to fix it. Fixes: 266980616 Test: manual, atest Change-Id: I3c83e775a7fd278dc255242518412ba790625fdb --- .../systemui/volume/VolumeDialogImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java index 198d022297407..c63b3b336aded 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java @@ -1128,13 +1128,13 @@ public class VolumeDialogImpl implements VolumeDialog, rescheduleTimeoutH(); } - if (mODICaptionsTooltipView != null) { - mODICaptionsTooltipView.setAlpha(0.0f); + // We need to wait for layout and then center the caption view. Since the height of the + // dialog is now dynamic (with the variable ringer drawer height changing the height of + // the dialog), we need to do this here in code vs. in XML. + mHandler.post(() -> { + if (mODICaptionsTooltipView != null) { + mODICaptionsTooltipView.setAlpha(0.0f); - // We need to wait for layout and then center the caption view. Since the height of the - // dialog is now dynamic (with the variable ringer drawer height changing the height of - // the dialog), we need to do this here in code vs. in XML. - mHandler.post(() -> { final int[] odiTooltipLocation = mODICaptionsTooltipView.getLocationOnScreen(); final int[] odiButtonLocation = mODICaptionsIcon.getLocationOnScreen(); @@ -1160,8 +1160,8 @@ public class VolumeDialogImpl implements VolumeDialog, } }) .start(); - }); - } + } + }); } private void hideCaptionsTooltip() {