Consider the lock-task mode while using FLAG_ACTIVITY_TASK_ON_HOME

The flag will cause a newly launching task to be placed on top of the
current home activity task but it did ignore the lock-task mode
mechansim.

This CL checks the home task whether violated with lock-task mode when
startActivity with task-on-home flag.

Bug: 202980858
Test: atest TaskTests#testReturnsToHomeRootTask
      atest ActivityVisibilityTests#testLaunchTaskOnHome
Change-Id: I521b9e4fc32648263afb70de3342dbb5f3583330
This commit is contained in:
Jeff Chang
2021-11-05 17:28:55 +08:00
parent 6ee7e8b6b3
commit d41841f469

View File

@@ -1123,7 +1123,11 @@ class Task extends TaskFragment {
if (inMultiWindowMode() || !hasChild()) return false;
if (intent != null) {
final int returnHomeFlags = FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME;
return intent != null && (intent.getFlags() & returnHomeFlags) == returnHomeFlags;
final Task task = getDisplayArea() != null ? getDisplayArea().getRootHomeTask() : null;
final boolean isLockTaskModeViolation = task != null
&& mAtmService.getLockTaskController().isLockTaskModeViolation(task);
return (intent.getFlags() & returnHomeFlags) == returnHomeFlags
&& !isLockTaskModeViolation;
}
final Task bottomTask = getBottomMostTask();
return bottomTask != this && bottomTask.returnsToHomeRootTask();