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
This commit is contained in:
Jamie Garside
2022-11-15 14:42:46 +00:00
parent 4c430266c0
commit dd2b7e67ef

View File

@@ -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);