From ce07b079f0a9503e13c9da11063a4d04029f1c84 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Tue, 26 Oct 2021 17:12:41 +0800 Subject: [PATCH] Making activity invisible when occluded by one of the adjacent TF Multiple TaskFragments can be added in a leaf Task for activity embedding use case. Unlike split-screen use case, the adjacent TaskFragments are not always positioned next to each other. There could have a TaskFragment positioned in between two adjacent TaskFragments. Bug: 204185619 Test: atest SplitActivityLifecycleTest Change-Id: I27295a8176c61044bd8e92d70cb1aa422e3e88f6 --- .../java/com/android/server/wm/TaskFragment.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 99f6f341e9771..f08ebba7839ed 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -778,6 +778,7 @@ class TaskFragment extends WindowContainer { boolean gotOpaqueSplitScreenPrimary = false; boolean gotOpaqueSplitScreenSecondary = false; boolean gotTranslucentFullscreen = false; + boolean gotTranslucentAdjacent = false; boolean gotTranslucentSplitScreenPrimary = false; boolean gotTranslucentSplitScreenSecondary = false; boolean shouldBeVisible = true; @@ -806,6 +807,18 @@ class TaskFragment extends WindowContainer { final boolean hasRunningActivities = hasRunningActivity(other); if (other == this) { + if (!adjacentTaskFragments.isEmpty() && !gotTranslucentAdjacent) { + // The z-order of this TaskFragment is in middle of two adjacent TaskFragments + // and it cannot be visible if the TaskFragment on top is not translucent and + // is fully occluding this one. + for (int j = adjacentTaskFragments.size() - 1; j >= 0; --j) { + final TaskFragment taskFragment = adjacentTaskFragments.get(j); + if (!taskFragment.isTranslucent(starting) + && taskFragment.getBounds().contains(this.getBounds())) { + return TASK_FRAGMENT_VISIBILITY_INVISIBLE; + } + } + } // Should be visible if there is no other fragment occluding it, unless it doesn't // have any running activities, not starting one and not home stack. shouldBeVisible = hasRunningActivities @@ -875,6 +888,7 @@ class TaskFragment extends WindowContainer { || otherTaskFrag.mAdjacentTaskFragment.isTranslucent(starting)) { // Can be visible behind a translucent adjacent TaskFragments. gotTranslucentFullscreen = true; + gotTranslucentAdjacent = true; continue; } // Can not be visible behind adjacent TaskFragments.