Merge "Make sure tasks not in split root is invisible while in split" into sc-dev

This commit is contained in:
Jerry Chang
2021-05-13 09:38:14 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 20 deletions

View File

@@ -4356,7 +4356,12 @@ class Task extends WindowContainer<WindowContainer> {
case WINDOWING_MODE_FULLSCREEN:
if (gotTranslucentSplitScreenPrimary || gotTranslucentSplitScreenSecondary) {
// At least one of the split-screen stacks that covers this one is translucent.
return TASK_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT;
// When in split mode, home task will be reparented to the secondary split while
// leaving tasks not supporting split below. Due to
// TaskDisplayArea#assignRootTaskOrdering always adjusts home surface layer to
// the bottom, this makes sure tasks not in split roots won't occlude home task
// unexpectedly.
return TASK_VISIBILITY_INVISIBLE;
}
break;
case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY:

View File

@@ -586,38 +586,30 @@ public class RootTaskTests extends WindowTestsBase {
@Test
public void testShouldBeVisible_SplitScreen() {
final Task homeRootTask = createTaskForShouldBeVisibleTest(mDefaultTaskDisplayArea,
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, true /* onTop */);
// Home root task should always be fullscreen for this test.
doReturn(false).when(homeRootTask).supportsSplitScreenWindowingMode();
// task not supporting split should be fullscreen for this test.
final Task notSupportingSplitTask = createTaskForShouldBeVisibleTest(
mDefaultTaskDisplayArea, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD,
true /* onTop */);
doReturn(false).when(notSupportingSplitTask).supportsSplitScreenWindowingMode();
final Task splitScreenPrimary = createTaskForShouldBeVisibleTest(mDefaultTaskDisplayArea,
WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_STANDARD, true /* onTop */);
final Task splitScreenSecondary = createTaskForShouldBeVisibleTest(mDefaultTaskDisplayArea,
WINDOWING_MODE_SPLIT_SCREEN_SECONDARY, ACTIVITY_TYPE_STANDARD, true /* onTop */);
// Home root task shouldn't be visible if both halves of split-screen are opaque.
// root task not supporting split shouldn't be visible if both halves of split-screen are
// opaque.
doReturn(false).when(splitScreenPrimary).isTranslucent(any());
doReturn(false).when(splitScreenSecondary).isTranslucent(any());
assertFalse(homeRootTask.shouldBeVisible(null /* starting */));
assertFalse(notSupportingSplitTask.shouldBeVisible(null /* starting */));
assertTrue(splitScreenPrimary.shouldBeVisible(null /* starting */));
assertTrue(splitScreenSecondary.shouldBeVisible(null /* starting */));
assertEquals(TASK_VISIBILITY_INVISIBLE, homeRootTask.getVisibility(null /* starting */));
assertEquals(TASK_VISIBILITY_VISIBLE,
splitScreenPrimary.getVisibility(null /* starting */));
assertEquals(TASK_VISIBILITY_VISIBLE,
splitScreenSecondary.getVisibility(null /* starting */));
// Home root task should be visible if one of the halves of split-screen is translucent.
// root task not supporting split shouldn't be visible if one of the halves of split-screen
// is translucent.
doReturn(true).when(splitScreenPrimary).isTranslucent(any());
assertTrue(homeRootTask.shouldBeVisible(null /* starting */));
assertFalse(notSupportingSplitTask.shouldBeVisible(null /* starting */));
assertTrue(splitScreenPrimary.shouldBeVisible(null /* starting */));
assertTrue(splitScreenSecondary.shouldBeVisible(null /* starting */));
assertEquals(TASK_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT,
homeRootTask.getVisibility(null /* starting */));
assertEquals(TASK_VISIBILITY_VISIBLE,
splitScreenPrimary.getVisibility(null /* starting */));
assertEquals(TASK_VISIBILITY_VISIBLE,
splitScreenSecondary.getVisibility(null /* starting */));
final Task splitScreenSecondary2 = createTaskForShouldBeVisibleTest(mDefaultTaskDisplayArea,
WINDOWING_MODE_SPLIT_SCREEN_SECONDARY, ACTIVITY_TYPE_STANDARD, true /* onTop */);