From 35a8b04140598a5b5c4865254b942adb6a830991 Mon Sep 17 00:00:00 2001 From: Winson Date: Fri, 22 Jan 2016 09:41:09 -0800 Subject: [PATCH] Fixing crash with retrieving the first stack task. - We should be retrieving the first stack task for calculating the thumbnail transition, regardless of whether it is freeform or not. Bug: 26739531 Change-Id: I27037a480201396011d7f9b8d094b4d9afe66f0e --- .../SystemUI/src/com/android/systemui/recents/RecentsImpl.java | 8 ++++---- .../src/com/android/systemui/recents/model/TaskStack.java | 8 ++++---- .../src/com/android/systemui/recents/views/TaskStackView.java | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 3eee08766c73..f8cbf656dfa0 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -651,7 +651,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements mDummyStackView.updateLayoutForStack(stack); final Task toTask = new Task(); final TaskViewTransform toTransform = getThumbnailTransitionTransform(stack, stackView, - topTask.id, toTask); + toTask); ForegroundThread.getHandler().postAtFrontOfQueue(new Runnable() { @Override public void run() { @@ -721,7 +721,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements // Update the destination rect Task toTask = new Task(); TaskViewTransform toTransform = getThumbnailTransitionTransform(stack, stackView, - topTask.id, toTask); + toTask); RectF toTaskRect = toTransform.rect; Bitmap thumbnail = getThumbnailBitmap(topTask, toTask, toTransform); if (thumbnail != null) { @@ -754,14 +754,14 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements * Returns the transition rect for the given task id. */ private TaskViewTransform getThumbnailTransitionTransform(TaskStack stack, - TaskStackView stackView, int runningTaskId, Task runningTaskOut) { + TaskStackView stackView, Task runningTaskOut) { // Find the running task in the TaskStack Task launchTask = stack.getLaunchTarget(); if (launchTask != null) { runningTaskOut.copyFrom(launchTask); } else { // If no task is specified or we can not find the task just use the front most one - launchTask = stack.getStackFrontMostTask(); + launchTask = stack.getStackFrontMostTask(true /* includeFreeform */); runningTaskOut.copyFrom(launchTask); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java index c73273e6f258..de1daa8ea988 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java @@ -527,9 +527,9 @@ public class TaskStack { */ public void removeTask(Task t, TaskViewAnimation animation) { if (mStackTaskList.contains(t)) { - boolean wasFrontMostTask = (getStackFrontMostTask() == t); + boolean wasFrontMostTask = (getStackFrontMostTask(false /* includeFreeform */) == t); removeTaskImpl(mStackTaskList, t); - Task newFrontMostTask = getStackFrontMostTask(); + Task newFrontMostTask = getStackFrontMostTask(false /* includeFreeform */); if (mCb != null) { // Notify that a task has been removed mCb.onStackTaskRemoved(this, t, wasFrontMostTask, newFrontMostTask, animation); @@ -616,14 +616,14 @@ public class TaskStack { /** * Gets the front-most task in the stack. */ - public Task getStackFrontMostTask() { + public Task getStackFrontMostTask(boolean includeFreeformTasks) { ArrayList stackTasks = mStackTaskList.getTasks(); if (stackTasks.isEmpty()) { return null; } for (int i = stackTasks.size() - 1; i >= 0; i--) { Task task = stackTasks.get(i); - if (!task.isFreeformTask()) { + if (!task.isFreeformTask() || includeFreeformTasks) { return task; } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index 809d4eed7a11..de045f46f9f9 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -1427,7 +1427,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } // Restore the action button visibility if it is the front most task view - if (mScreenPinningEnabled && tv.getTask() == mStack.getStackFrontMostTask()) { + if (mScreenPinningEnabled && tv.getTask() == + mStack.getStackFrontMostTask(false /* includeFreeform */)) { tv.showActionButton(false /* fadeIn */, 0 /* fadeInDuration */); } } -- 2.11.0