Focus the first task in KQS when it is not currently running
Flag: LEGACY ENABLE_KEYBOARD_QUICK_SWITCH ENABLED Fixes: 316004088 Test: TaplTestsKeyboardQuickSwitch Change-Id: I8a91ca0dd32c6fc2352d285934a2c4f79ba1bb13
This commit is contained in:
@@ -32,6 +32,7 @@ import com.android.quickstep.util.DesktopTask;
|
||||
import com.android.quickstep.util.GroupTask;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
@@ -115,8 +116,15 @@ public final class KeyboardQuickSwitchController implements
|
||||
&& desktopController.areFreeformTasksVisible();
|
||||
|
||||
if (mModel.isTaskListValid(mTaskListChangeId)) {
|
||||
mQuickSwitchViewController.openQuickSwitchView(mTasks,
|
||||
mNumHiddenTasks, /* updateTasks= */ false, currentFocusedIndex, onDesktop);
|
||||
// When we are opening the KQS with no focus override, check if the first task is
|
||||
// running. If not, focus that first task.
|
||||
mQuickSwitchViewController.openQuickSwitchView(
|
||||
mTasks,
|
||||
mNumHiddenTasks,
|
||||
/* updateTasks= */ false,
|
||||
currentFocusedIndex == -1 && !mControllerCallbacks.isFirstTaskRunning()
|
||||
? 0 : currentFocusedIndex,
|
||||
onDesktop);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,8 +134,15 @@ public final class KeyboardQuickSwitchController implements
|
||||
} else {
|
||||
processLoadedTasks(tasks);
|
||||
}
|
||||
mQuickSwitchViewController.openQuickSwitchView(mTasks,
|
||||
mNumHiddenTasks, /* updateTasks= */ true, currentFocusedIndex, onDesktop);
|
||||
// Check if the first task is running after the recents model has updated so that we use
|
||||
// the correct index.
|
||||
mQuickSwitchViewController.openQuickSwitchView(
|
||||
mTasks,
|
||||
mNumHiddenTasks,
|
||||
/* updateTasks= */ true,
|
||||
currentFocusedIndex == -1 && !mControllerCallbacks.isFirstTaskRunning()
|
||||
? 0 : currentFocusedIndex,
|
||||
onDesktop);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -246,5 +261,20 @@ public final class KeyboardQuickSwitchController implements
|
||||
void onCloseComplete() {
|
||||
mQuickSwitchViewController = null;
|
||||
}
|
||||
|
||||
boolean isTaskRunning(@Nullable GroupTask task) {
|
||||
if (task == null) {
|
||||
return false;
|
||||
}
|
||||
int runningTaskId = ActivityManagerWrapper.getInstance().getRunningTask().taskId;
|
||||
Task task2 = task.task2;
|
||||
|
||||
return runningTaskId == task.task1.key.id
|
||||
|| (task2 != null && runningTaskId == task2.key.id);
|
||||
}
|
||||
|
||||
boolean isFirstTaskRunning() {
|
||||
return isTaskRunning(getTaskAt(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user