Auto remove the embedded task from Recents

The embedded task was displayed in Recents because
we won't be able to tell if the task is embedded
once the task is removed from the wm hierarchy.

Bug: 194243805
Test: not showing embedded task in Recents

Change-Id: I045ebad855b19a7711af3426d78f02d3f247d29c
This commit is contained in:
Louis Chang
2021-08-10 17:06:08 +08:00
parent 4c06d013b5
commit b9abece8fb

View File

@@ -723,7 +723,7 @@ class Task extends TaskFragment {
} catch (RemoteException e) {
}
}
if (autoRemoveFromRecents() || isVoiceSession) {
if (autoRemoveFromRecents(oldParent.asTaskFragment()) || isVoiceSession) {
// Task creator asked to remove this when done, or this task was a voice
// interaction, so it should not remain on the recent tasks list.
mTaskSupervisor.mRecentTasks.remove(this);
@@ -1575,11 +1575,12 @@ class Task extends TaskFragment {
return count > 0;
}
private boolean autoRemoveFromRecents() {
private boolean autoRemoveFromRecents(TaskFragment oldParentFragment) {
// We will automatically remove the task either if it has explicitly asked for
// this, or it is empty and has never contained an activity that got shown to
// the user.
return autoRemoveRecents || (!hasChild() && !getHasBeenVisible());
// the user, or it was being embedded in another Task.
return autoRemoveRecents || (!hasChild() && !getHasBeenVisible()
|| (oldParentFragment != null && oldParentFragment.isEmbedded()));
}
private void clearPinnedTaskIfNeed() {