From dd2b7e67ef6682d127faead49c4d9df37867dc31 Mon Sep 17 00:00:00 2001 From: Jamie Garside Date: Tue, 15 Nov 2022 14:42:46 +0000 Subject: [PATCH] Fix bug where the clock may not exist when using custom animation. It's possible that CLockContainerView has no children when updateKeyguardStatusViewAlignemnt is called, which can cause an NPE. Test: Manually verified. Bug: 257762349 Change-Id: I0757abed8ffc26c8a654e55c352052098bc9086a --- .../NotificationPanelViewController.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 32c8f3bba6c1a..0f4cac9ede775 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -1569,23 +1569,31 @@ public final class NotificationPanelViewController implements Dumpable { // Find the clock, so we can exclude it from this transition. FrameLayout clockContainerView = mView.findViewById(R.id.lockscreen_clock_view_large); - View clockView = clockContainerView.getChildAt(0); - transition.excludeTarget(clockView, /* exclude= */ true); + // The clock container can sometimes be null. If it is, just fall back to the + // old animation rather than setting up the custom animations. + if (clockContainerView == null || clockContainerView.getChildCount() == 0) { + TransitionManager.beginDelayedTransition( + mNotificationContainerParent, transition); + } else { + View clockView = clockContainerView.getChildAt(0); - TransitionSet set = new TransitionSet(); - set.addTransition(transition); + transition.excludeTarget(clockView, /* exclude= */ true); - SplitShadeTransitionAdapter adapter = - new SplitShadeTransitionAdapter(mKeyguardStatusViewController); + TransitionSet set = new TransitionSet(); + set.addTransition(transition); - // Use linear here, so the actual clock can pick its own interpolator. - adapter.setInterpolator(Interpolators.LINEAR); - adapter.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); - adapter.addTarget(clockView); - set.addTransition(adapter); + SplitShadeTransitionAdapter adapter = + new SplitShadeTransitionAdapter(mKeyguardStatusViewController); - TransitionManager.beginDelayedTransition(mNotificationContainerParent, set); + // Use linear here, so the actual clock can pick its own interpolator. + adapter.setInterpolator(Interpolators.LINEAR); + adapter.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); + adapter.addTarget(clockView); + set.addTransition(adapter); + + TransitionManager.beginDelayedTransition(mNotificationContainerParent, set); + } } else { TransitionManager.beginDelayedTransition( mNotificationContainerParent, transition);