From a4a4763f5857ed39d6e4dae263ee9dc01eec756a Mon Sep 17 00:00:00 2001 From: Sid Soundararajan Date: Wed, 5 Oct 2016 10:30:32 -0700 Subject: Recents TV: Do not allow negative delay In rare cases, the getChildCount() has a delayed update. It enters the for loop, and then changes to return 0. This can potentially allow a negative delay, causing a crash. BUG: 31933255 Change-Id: Ia245edc9fca0e1712c2af5c301bac632caed1568 --- .../recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java index 9faaa4bdccb6..a673c8c67696 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java +++ b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java @@ -47,12 +47,13 @@ public class HomeRecentsEnterExitAnimationHolder { public void startEnterAnimation(boolean isPipShown) { for(int i = 0; i < mGridView.getChildCount(); i++) { TaskCardView view = (TaskCardView) mGridView.getChildAt(i); + long delay = Math.max(mDelay * i, 0); view.setTranslationX(-mTranslationX); view.animate() .alpha(isPipShown ? mDimAlpha : 1.0f) .translationX(0) .setDuration(mDuration) - .setStartDelay(mDelay * i) + .setStartDelay(delay) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN); } } @@ -60,11 +61,12 @@ public class HomeRecentsEnterExitAnimationHolder { public void startExitAnimation(DismissRecentsToHomeAnimationStarted dismissEvent) { for(int i = mGridView.getChildCount() - 1; i >= 0; i--) { TaskCardView view = (TaskCardView) mGridView.getChildAt(i); + long delay = Math.max(mDelay * (mGridView.getChildCount() - 1 - i), 0); view.animate() .alpha(0.0f) .translationXBy(-mTranslationX) .setDuration(mDuration) - .setStartDelay(mDelay * (mGridView.getChildCount() - 1 - i)) + .setStartDelay(delay) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN); if(i == 0) { view.animate().setListener(dismissEvent.getAnimationTrigger() -- cgit v1.2.3-59-g8ed1b