Activities behind two adjacent TaskFragments should be invisible

Making sure the activities behind two adjacent TaskFragments
are invisible and should be stopped.

Bug: 196192135
Test: manually with sample app
Change-Id: I36446a5e193becf4316eecfcdad706d05715c122
This commit is contained in:
Louis Chang
2021-08-11 16:54:35 +08:00
parent 5214873aa8
commit 926507262c

View File

@@ -23,6 +23,8 @@ import static com.android.server.wm.Task.TAG_VISIBILITY;
import android.annotation.Nullable;
import android.util.Slog;
import java.util.ArrayList;
/** Helper class to ensure activities are in the right visible state for a container. */
class EnsureActivitiesVisibleHelper {
private final TaskFragment mTaskFragment;
@@ -98,17 +100,37 @@ class EnsureActivitiesVisibleHelper {
&& mTaskFragment.isTopActivityFocusable()
&& (starting == null || !starting.isDescendantOf(mTaskFragment));
ArrayList<TaskFragment> adjacentTaskFragments = null;
for (int i = mTaskFragment.mChildren.size() - 1; i >= 0; --i) {
final WindowContainer child = mTaskFragment.mChildren.get(i);
if (child.asTaskFragment() != null) {
final TaskFragment childTaskFragment = child.asTaskFragment();
childTaskFragment.updateActivityVisibilities(starting, configChanges,
preserveWindows, notifyClients);
mBehindFullyOccludedContainer = childTaskFragment.getBounds().equals(
mBehindFullyOccludedContainer |= childTaskFragment.getBounds().equals(
mTaskFragment.getBounds());
if (mAboveTop && mTop.getTaskFragment() == childTaskFragment) {
mAboveTop = false;
}
if (mBehindFullyOccludedContainer) {
continue;
}
if (adjacentTaskFragments != null && adjacentTaskFragments.contains(
childTaskFragment)) {
// Everything behind two adjacent TaskFragments are occluded.
mBehindFullyOccludedContainer = true;
continue;
}
final TaskFragment adjacentTaskFrag = childTaskFragment.getAdjacentTaskFragment();
if (adjacentTaskFrag != null) {
if (adjacentTaskFragments == null) {
adjacentTaskFragments = new ArrayList<>();
}
adjacentTaskFragments.add(adjacentTaskFrag);
}
} else if (child.asActivityRecord() != null) {
setActivityVisibilityState(child.asActivityRecord(), starting, resumeTopActivity);
}