Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92650726 authored by Louis Chang's avatar Louis Chang
Browse files

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
parent 5214873a
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -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);
            }