Fixing issue with regression with launching focused task.
- Only update the focused task as you scroll if we are in touch
exploration mode.
- Use stack's notion of focused task as the currently focused task may
not have a TaskView and can be scrolled offscreen.
Bug: 25590404
Change-Id: I5ef1b66ec74aa1a3131993ed84905210f1e45f18
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 8729aa0..af30268 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 boolean launchFocusedTask() {
if (mTaskStackView != null) {
TaskStack stack = mTaskStackView.getStack();
- // Iterate the stack views and try and find the focused task
- List<TaskView> 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 39c45cc..4a11b93 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 @@
List<TaskView> mImmutableTaskViews = new ArrayList<>();
LayoutInflater mInflater;
boolean mLayersDisabled;
+ boolean mTouchExplorationEnabled;
Interpolator mFastOutSlowInInterpolator;
@@ -183,6 +184,8 @@
@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 @@
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 @@
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);