From 3f3d744d5c51d3ecc06af22ac7d69f4437671915 Mon Sep 17 00:00:00 2001 From: Winson Date: Tue, 1 Mar 2016 10:07:04 -0800 Subject: [PATCH] Skip animation in error case, log for further investigation. Bug: 27389156 Change-Id: Idc2ebdf04ab72d326f68a47627b27d6e61315d1e --- .../recents/views/TaskStackAnimationHelper.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java index 2cd0c19a4352..d152010c71c8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java @@ -20,8 +20,8 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.content.res.Resources; -import android.graphics.Path; import android.graphics.RectF; +import android.util.Log; import android.view.View; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; @@ -441,11 +441,13 @@ public class TaskStackAnimationHelper { TaskStackViewScroller stackScroller = mStackView.getScroller(); TaskStack stack = mStackView.getStack(); + final float curScroll = stackScroller.getStackScroll(); final float newScroll = stackLayout.getStackScrollForTask(newFocusedTask); - boolean willScrollToFront = newScroll > stackScroller.getStackScroll(); - boolean willScroll = Float.compare(newScroll, stackScroller.getStackScroll()) != 0; + boolean willScrollToFront = newScroll > curScroll; + boolean willScroll = Float.compare(newScroll, curScroll) != 0; // Get the current set of task transforms + int taskViewCount = mStackView.getTaskViews().size(); ArrayList stackTasks = stack.getStackTasks(); mStackView.getCurrentTaskTransforms(stackTasks, mTmpCurrentTaskTransforms); @@ -463,6 +465,13 @@ public class TaskStackAnimationHelper { // Focus the task view TaskView newFocusedTaskView = mStackView.getChildViewForTask(newFocusedTask); + if (newFocusedTaskView == null) { + // Log the error if we have no task view, and skip the animation + Log.e("TaskStackAnimationHelper", "b/27389156 null-task-view prebind:" + taskViewCount + + " postbind:" + mStackView.getTaskViews().size() + " prescroll:" + curScroll + + " postscroll: " + newScroll); + return false; + } newFocusedTaskView.setFocusedState(true, requestViewFocus); // Setup the end listener to return all the hidden views to the view pool after the @@ -476,7 +485,7 @@ public class TaskStackAnimationHelper { }); List taskViews = mStackView.getTaskViews(); - int taskViewCount = taskViews.size(); + taskViewCount = taskViews.size(); int newFocusTaskViewIndex = taskViews.indexOf(newFocusedTaskView); for (int i = 0; i < taskViewCount; i++) { TaskView tv = taskViews.get(i); -- 2.11.0