Clear preferred top focusable root task
When the last activity in the task is finishing and there is no next activity can be resumed. We will use pre-recorded task which is no longer visible to resume activity. This will not only fail to resume activity, but also miss the chance to resume home. We should not ask an invisible task to resume activity, so this CL is to clear mPreferredTopFocusableRootTask when we can't find a next focusable task. Bug: 183373468 Test: Finish SUW and use back key to finish AllSetActivity Test: atest ActivityRecordTests TaskTest RootTaskTests Test: atest DisplayContentTests#testNotResumeHomeRootTaskOnRemovingDisplay Change-Id: I38b69b9dd25ac1fbf88042fb943f1200c3e33474
This commit is contained in:
@@ -3080,6 +3080,11 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
focusableTask = mRootWindowContainer.getNextFocusableRootTask(this, !allowFocusSelf);
|
||||
}
|
||||
if (focusableTask == null) {
|
||||
final TaskDisplayArea taskDisplayArea = getDisplayArea();
|
||||
if (taskDisplayArea != null) {
|
||||
// Clear the recorded task since there is no next focusable task.
|
||||
taskDisplayArea.clearPreferredTopFocusableRootTask();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
|
||||
* unable to resume target root task properly when there are other focusable always-on-top
|
||||
* root tasks.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
Task mPreferredTopFocusableRootTask;
|
||||
|
||||
/**
|
||||
@@ -2128,6 +2129,10 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
|
||||
&& mDisplayContent.getOrientationRequestingTaskDisplayArea() == this;
|
||||
}
|
||||
|
||||
void clearPreferredTopFocusableRootTask() {
|
||||
mPreferredTopFocusableRootTask = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTaskDisplayArea() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user