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

Commit a99666e1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove exiting activity list"

parents 2ba67434 6d9f58c8
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -329,7 +329,6 @@ import com.android.internal.content.ReferrerIntent;
import com.android.internal.os.TransferPipe;
import com.android.internal.policy.AttributeCache;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.XmlUtils;
import com.android.server.LocalServices;
import com.android.server.am.AppTimeTracker;
@@ -1443,8 +1442,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            if (getDisplayContent() != null) {
                getDisplayContent().mClosingApps.remove(this);
            }
        } else if (oldTask != null && oldTask.getRootTask() != null) {
            task.getRootTask().mExitingActivities.remove(this);
        }
        final Task rootTask = getRootTask();

@@ -3832,22 +3829,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            getDisplayContent().mNoAnimationNotifyOnTransitionFinished.add(token);
        }

        final Task rootTask = getRootTask();
        if (delayed && !isEmpty()) {
            // set the token aside because it has an active animation to be finished
            ProtoLog.v(WM_DEBUG_ADD_REMOVE,
                    "removeAppToken make exiting: %s", this);
            if (rootTask != null) {
                rootTask.mExitingActivities.add(this);
            }
            mIsExiting = true;
        } else {
            // Make sure there is no animation running on this token, so any windows associated
            // with it will be removed as soon as their animations are complete
            cancelAnimation();
            if (rootTask != null) {
                rootTask.mExitingActivities.remove(this);
            }
            removeIfPossible();
        }

@@ -4204,23 +4194,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return candidate;
    }

    @Override
    boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) {
        // For legacy reasons we process the TaskStack.mExitingActivities first in DisplayContent
        // before the non-exiting app tokens. So, we skip the exiting app tokens here.
        // TODO: Investigate if we need to continue to do this or if we can just process them
        // in-order.
        if (mIsExiting && !forAllWindowsUnchecked(WindowState::waitingForReplacement, true)) {
            return false;
        }
        return forAllWindowsUnchecked(callback, traverseTopToBottom);
    }

    boolean forAllWindowsUnchecked(ToBooleanFunction<WindowState> callback,
            boolean traverseTopToBottom) {
        return super.forAllWindows(callback, traverseTopToBottom);
    }

    @Override
    boolean forAllActivities(Predicate<ActivityRecord> callback, boolean traverseTopToBottom) {
        return callback.test(this);
+0 −39
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.DisplayAreaOrganizer.FEATURE_ROOT;
import static android.window.DisplayAreaOrganizer.FEATURE_WINDOWED_MAGNIFICATION;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
@@ -700,8 +699,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    // well and thus won't change the top resumed / focused record
    boolean mDontMoveToTop;

    private final ArrayList<ActivityRecord> mTmpActivityList = new ArrayList<>();

    private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> {
        WindowStateAnimator winAnimator = w.mWinAnimator;
        final ActivityRecord activity = w.mActivityRecord;
@@ -4580,14 +4577,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        for (int i = mExitingTokens.size() - 1; i >= 0; i--) {
            mExitingTokens.get(i).hasVisible = hasVisible;
        }

        // Initialize state of exiting applications.
        forAllRootTasks(task -> {
            final ArrayList<ActivityRecord> activities = task.mExitingActivities;
            for (int j = activities.size() - 1; j >= 0; --j) {
                activities.get(j).hasVisible = hasVisible;
            }
        });
    }

    void removeExistingTokensIfPossible() {
@@ -4597,34 +4586,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                mExitingTokens.remove(i);
            }
        }

        // clear first just in case.
        mTmpActivityList.clear();
        // Time to remove any exiting applications?
        forAllRootTasks(task -> {
            final ArrayList<ActivityRecord> activities = task.mExitingActivities;
            for (int j = activities.size() - 1; j >= 0; --j) {
                final ActivityRecord activity = activities.get(j);
                if (!activity.hasVisible && !mDisplayContent.mClosingApps.contains(activity)
                        && (!activity.mIsExiting || activity.isEmpty())) {
                    mTmpActivityList.add(activity);
                }
            }
        });
        if (!mTmpActivityList.isEmpty()) {
            // Make sure there is no animation running on this activity, so any windows
            // associated with it will be removed as soon as their animations are
            // complete.
            cancelAnimation();
        }
        for (int i = 0; i < mTmpActivityList.size(); ++i) {
            final ActivityRecord activity = mTmpActivityList.get(i);
            ProtoLog.v(WM_DEBUG_ADD_REMOVE,
                    "performLayout: Activity exiting now removed %s", activity);
            activity.removeIfPossible();
        }
        // Clear afterwards so we don't hold references.
        mTmpActivityList.clear();
    }

    @Override
+0 −17
Original line number Diff line number Diff line
@@ -485,9 +485,6 @@ class Task extends TaskFragment {

    private static Exception sTmpException;

    /** ActivityRecords that are exiting, but still on screen for animations. */
    final ArrayList<ActivityRecord> mExitingActivities = new ArrayList<>();

    private boolean mForceShowForAllUsers;

    /** When set, will force the task to report as invisible. */
@@ -3322,20 +3319,6 @@ class Task extends TaskFragment {
    @Override
    void dump(PrintWriter pw, String prefix, boolean dumpAll) {
        super.dump(pw, prefix, dumpAll);

        if (!mExitingActivities.isEmpty()) {
            final String doublePrefix = prefix + "  ";
            pw.println();
            pw.println(prefix + "Exiting application tokens:");
            for (int i = mExitingActivities.size() - 1; i >= 0; i--) {
                WindowToken token = mExitingActivities.get(i);
                pw.print(doublePrefix + "Exiting App #" + i);
                pw.print(' '); pw.print(token);
                pw.println(':');
                token.dump(pw, doublePrefix, dumpAll);
            }
            pw.println();
        }
        mAnimatingActivityRegistry.dump(pw, "AnimatingApps:", prefix);
    }

+0 −67
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ import android.window.WindowContainerTransaction;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledPredicate;
import com.android.server.wm.LaunchParamsController.LaunchParams;
@@ -68,7 +67,6 @@ import com.android.server.wm.LaunchParamsController.LaunchParams;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -686,71 +684,6 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
        return targetPosition;
    }

    @Override
    boolean forAllWindows(ToBooleanFunction<WindowState> callback,
            boolean traverseTopToBottom) {
        if (traverseTopToBottom) {
            if (super.forAllWindows(callback, traverseTopToBottom)) {
                return true;
            }
            if (forAllExitingAppTokenWindows(callback, traverseTopToBottom)) {
                return true;
            }
        } else {
            if (forAllExitingAppTokenWindows(callback, traverseTopToBottom)) {
                return true;
            }
            if (super.forAllWindows(callback, traverseTopToBottom)) {
                return true;
            }
        }
        return false;
    }

    private boolean forAllExitingAppTokenWindows(ToBooleanFunction<WindowState> callback,
            boolean traverseTopToBottom) {
        // For legacy reasons we process the RootTask.mExitingActivities first here before the
        // app tokens.
        // TODO: Investigate if we need to continue to do this or if we can just process them
        // in-order.
        if (traverseTopToBottom) {
            for (int i = mChildren.size() - 1; i >= 0; --i) {
                // Only run on those of direct Task child, because child TaskDisplayArea has run on
                // its child in #forAllWindows()
                if (mChildren.get(i).asTask() == null) {
                    continue;
                }
                final List<ActivityRecord> activities =
                        mChildren.get(i).asTask().mExitingActivities;
                for (int j = activities.size() - 1; j >= 0; --j) {
                    if (activities.get(j).forAllWindowsUnchecked(callback,
                            traverseTopToBottom)) {
                        return true;
                    }
                }
            }
        } else {
            final int count = mChildren.size();
            for (int i = 0; i < count; ++i) {
                // Only run on those of direct Task child, because child TaskDisplayArea has run on
                // its child in #forAllWindows()
                if (mChildren.get(i).asTask() == null) {
                    continue;
                }
                final List<ActivityRecord> activities =
                        mChildren.get(i).asTask().mExitingActivities;
                final int appTokensCount = activities.size();
                for (int j = 0; j < appTokensCount; j++) {
                    if (activities.get(j).forAllWindowsUnchecked(callback,
                            traverseTopToBottom)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    @Override
    int getOrientation(int candidate) {
        mLastOrientationSource = null;
+4 −16
Original line number Diff line number Diff line
@@ -2069,26 +2069,14 @@ public class WindowManagerService extends IWindowManager.Stub
        }

        final WindowToken token = win.mToken;
        final ActivityRecord activity = win.mActivityRecord;
        ProtoLog.v(WM_DEBUG_ADD_REMOVE, "Removing %s from %s", win, token);
        // Window will already be removed from token before this post clean-up method is called.
        if (token.isEmpty()) {
            if (!token.mPersistOnEmpty) {
        if (token.isEmpty() && !token.mPersistOnEmpty) {
            token.removeImmediately();
            } else if (activity != null) {
                // TODO: Should this be moved into ActivityRecord.removeWindow? Might go away after
                // re-factor.
                activity.firstWindowDrawn = false;
                activity.clearAllDrawn();
                final Task rootTask = activity.getRootTask();
                if (rootTask != null) {
                    rootTask.mExitingActivities.remove(activity);
                }
            }
        }

        if (activity != null) {
            activity.postWindowRemoveStartingWindowCleanup(win);
        if (win.mActivityRecord != null) {
            win.mActivityRecord.postWindowRemoveStartingWindowCleanup(win);
        }

        if (win.mAttrs.type == TYPE_WALLPAPER) {
Loading