diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index 8729aa0fbf6f1..af30268927254 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -198,17 +198,12 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV public boolean launchFocusedTask() { if (mTaskStackView != null) { TaskStack stack = mTaskStackView.getStack(); - // Iterate the stack views and try and find the focused task - List taskViews = mTaskStackView.getTaskViews(); - int taskViewCount = taskViews.size(); - for (int j = 0; j < taskViewCount; j++) { - TaskView tv = taskViews.get(j); - Task task = tv.getTask(); - if (tv.isFocusedTask()) { - onTaskViewClicked(mTaskStackView, tv, stack, task, false, false, null, - INVALID_STACK_ID); - return true; - } + Task task = mTaskStackView.getFocusedTask(); + if (task != null) { + TaskView taskView = mTaskStackView.getChildViewForTask(task); + onTaskViewClicked(mTaskStackView, taskView, stack, task, false, false, null, + INVALID_STACK_ID); + return true; } } return false; 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 39c45ccbb1c58..4a11b9327b1f5 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -116,6 +116,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal List mImmutableTaskViews = new ArrayList<>(); LayoutInflater mInflater; boolean mLayersDisabled; + boolean mTouchExplorationEnabled; Interpolator mFastOutSlowInInterpolator; @@ -183,6 +184,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal @Override protected void onAttachedToWindow() { + SystemServicesProxy ssp = Recents.getSystemServices(); + mTouchExplorationEnabled = ssp.isTouchExplorationEnabled(); EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1); super.onAttachedToWindow(); } @@ -425,7 +428,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal visibleStackRange[1] <= taskIndex && taskIndex <= visibleStackRange[0]) { mTmpTaskViewMap.put(task, tv); } else { - if (tv.isFocusedTask()) { + if (mTouchExplorationEnabled && tv.isFocusedTask()) { wasLastFocusedTaskAnimated = tv.isFocusAnimated(); lastFocusedTaskIndex = taskIndex; resetFocusedTask(); @@ -716,6 +719,16 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal mFocusedTaskIndex = -1; } + /** + * Returns the focused task. + */ + Task getFocusedTask() { + if (mFocusedTaskIndex != -1) { + return mStack.getTasks().get(mFocusedTaskIndex); + } + return null; + } + @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event);