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

Commit 6ab3ba5c authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Change Task to have generic WindowContainer children (73/n)"

parents 9b5095b4 a38654fc
Loading
Loading
Loading
Loading
+24 −25
Original line number Original line Diff line number Diff line
@@ -73,7 +73,9 @@ import android.util.proto.ProtoOutputStream;
import android.view.Display;
import android.view.Display;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledPredicate;
import com.android.server.protolog.common.ProtoLog;
import com.android.server.protolog.common.ProtoLog;


import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -617,7 +619,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
                continue;
                continue;
            }
            }


            stack.findTaskLocked(r, mTmpFindTaskResult);
            mTmpFindTaskResult.process(r, stack);
            // It is possible to have tasks in multiple stacks with the same root affinity, so
            // It is possible to have tasks in multiple stacks with the same root affinity, so
            // we should keep looking after finding an affinity match to see if there is a
            // we should keep looking after finding an affinity match to see if there is a
            // better match in another stack. Also, task affinity isn't a good enough reason
            // better match in another stack. Also, task affinity isn't a good enough reason
@@ -1190,12 +1192,11 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
    }
    }


    boolean isUidPresent(int uid) {
    boolean isUidPresent(int uid) {
        for (ActivityStack stack : mStacks) {
        final PooledPredicate p = PooledLambda.obtainPredicate(
            if (stack.isUidPresent(uid)) {
                ActivityRecord::isUid, PooledLambda.__(ActivityRecord.class), uid);
                return true;
        final boolean isUidPresent = mDisplayContent.getActivity(p) != null;
            }
        p.recycle();
        }
        return isUidPresent;
        return false;
    }
    }


    /**
    /**
@@ -1291,12 +1292,16 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
    /** Update and get all UIDs that are present on the display and have access to it. */
    /** Update and get all UIDs that are present on the display and have access to it. */
    IntArray getPresentUIDs() {
    IntArray getPresentUIDs() {
        mDisplayAccessUIDs.clear();
        mDisplayAccessUIDs.clear();
        for (ActivityStack stack : mStacks) {
        final PooledConsumer c = PooledLambda.obtainConsumer(ActivityDisplay::addActivityUid,
            stack.getPresentUIDs(mDisplayAccessUIDs);
                PooledLambda.__(ActivityRecord.class), mDisplayAccessUIDs);
        }
        mDisplayContent.forAllActivities(c);
        c.recycle();
        return mDisplayAccessUIDs;
        return mDisplayAccessUIDs;
    }
    }


    private static void addActivityUid(ActivityRecord r, IntArray uids) {
        uids.add(r.getUid());
    }
    /**
    /**
     * Checks if system decorations should be shown on this display.
     * Checks if system decorations should be shown on this display.
     *
     *
@@ -1449,22 +1454,16 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
            return null;
            return null;
        }
        }


        final ArrayList<Task> tasks = mHomeStack.getAllTasks();
        final PooledPredicate p = PooledLambda.obtainPredicate(
        for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
                ActivityDisplay::isHomeActivityForUser, PooledLambda.__(ActivityRecord.class),
            final Task task = tasks.get(taskNdx);
                userId);
            if (!task.isActivityTypeHome()) {
        final ActivityRecord r = mHomeStack.getActivity(p);
                continue;
        p.recycle();
            }

            for (int activityNdx = task.getChildCount() - 1; activityNdx >= 0; --activityNdx) {
                final ActivityRecord r = task.getChildAt(activityNdx);
                if (r.isActivityTypeHome()
                        && ((userId == UserHandle.USER_ALL) || (r.mUserId == userId))) {
        return r;
        return r;
    }
    }
            }

        }
    private static boolean isHomeActivityForUser(ActivityRecord r, int userId) {
        return null;
        return r.isActivityTypeHome() && (userId == UserHandle.USER_ALL || r.mUserId == userId);
    }
    }


    boolean isSleeping() {
    boolean isSleeping() {
+1 −7
Original line number Original line Diff line number Diff line
@@ -546,13 +546,7 @@ class ActivityMetricsLogger {


    /** @return {@code true} if the given task has an activity will be drawn. */
    /** @return {@code true} if the given task has an activity will be drawn. */
    private static boolean hasActivityToBeDrawn(Task t) {
    private static boolean hasActivityToBeDrawn(Task t) {
        for (int i = t.getChildCount() - 1; i >= 0; --i) {
        return t.forAllActivities((r) -> r.mVisibleRequested && !r.mDrawn && !r.finishing);
            final ActivityRecord r = t.getChildAt(i);
            if (r.mVisibleRequested && !r.mDrawn && !r.finishing) {
                return true;
            }
        }
        return false;
    }
    }


    private void checkVisibility(Task t, ActivityRecord r) {
    private void checkVisibility(Task t, ActivityRecord r) {
+84 −79
Original line number Original line Diff line number Diff line
@@ -301,6 +301,9 @@ import com.android.internal.app.ResolverActivity;
import com.android.internal.content.ReferrerIntent;
import com.android.internal.content.ReferrerIntent;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledFunction;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.AttributeCache;
import com.android.server.AttributeCache;
import com.android.server.LocalServices;
import com.android.server.LocalServices;
import com.android.server.am.AppTimeTracker;
import com.android.server.am.AppTimeTracker;
@@ -695,12 +698,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }
    }
    }


    void dump(PrintWriter pw, String prefix) {
    }

    /**
     * Copied from old AppWindowToken.
     */
    @Override
    @Override
    void dump(PrintWriter pw, String prefix, boolean dumpAll) {
    void dump(PrintWriter pw, String prefix, boolean dumpAll) {
        final long now = SystemClock.uptimeMillis();
        final long now = SystemClock.uptimeMillis();
@@ -940,6 +937,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }
    }
    }


    void setAppTimeTracker(AppTimeTracker att) {
        appTimeTracker = att;
    }

    /** Update the saved state of an activity. */
    /** Update the saved state of an activity. */
    void setSavedState(@Nullable Bundle savedState) {
    void setSavedState(@Nullable Bundle savedState) {
        mIcicle = savedState;
        mIcicle = savedState;
@@ -1167,6 +1168,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


        super.onParentChanged(newParent, oldParent);
        super.onParentChanged(newParent, oldParent);


        if (isPersistable()) {
            if (oldTask != null) {
                mAtmService.notifyTaskPersisterLocked(oldTask, false);
            }
            if (newTask != null) {
                mAtmService.notifyTaskPersisterLocked(newTask, false);
            }
        }

        if (oldParent == null && newParent != null) {
        if (oldParent == null && newParent != null) {
            // First time we are adding the activity to the system.
            // First time we are adding the activity to the system.
            mVoiceInteraction = newTask.voiceSession != null;
            mVoiceInteraction = newTask.voiceSession != null;
@@ -1261,14 +1271,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


        if (prevDc.mFocusedApp == this) {
        if (prevDc.mFocusedApp == this) {
            prevDc.setFocusedApp(null);
            prevDc.setFocusedApp(null);
            final ActivityStack stack = dc.getTopStack();
            if (dc.getTopMostActivity() == this) {
            if (stack != null) {
                final Task task = stack.getTopChild();
                if (task != null && task.getTopChild() == this) {
                dc.setFocusedApp(this);
                dc.setFocusedApp(this);
            }
            }
        }
        }
        }


        if (mLetterbox != null) {
        if (mLetterbox != null) {
            mLetterbox.onMovedToDisplay(mDisplayContent.getDisplayId());
            mLetterbox.onMovedToDisplay(mDisplayContent.getDisplayId());
@@ -2212,7 +2218,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                OP_PICTURE_IN_PICTURE, info.applicationInfo.uid, packageName) == MODE_ALLOWED;
                OP_PICTURE_IN_PICTURE, info.applicationInfo.uid, packageName) == MODE_ALLOWED;
    }
    }


    boolean isAlwaysFocusable() {
    private boolean isAlwaysFocusable() {
        return (info.flags & FLAG_ALWAYS_FOCUSABLE) != 0;
        return (info.flags & FLAG_ALWAYS_FOCUSABLE) != 0;
    }
    }


@@ -2269,23 +2275,28 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return true;
        return true;
    }
    }


    /** Finish all activities in the task with the same affinity as this one. */
    void finishIfSubActivity(ActivityRecord parent, String otherResultWho, int otherRequestCode) {
    void finishActivityAffinity() {
        if (resultTo != parent
        final ArrayList<ActivityRecord> activities = task.mChildren;
                || requestCode != otherRequestCode
        for (int index = activities.indexOf(this); index >= 0; --index) {
                || !Objects.equals(resultWho, otherResultWho)) return;
            final ActivityRecord cur = activities.get(index);

            if (!Objects.equals(cur.taskAffinity, taskAffinity)) {
        finishIfPossible("request-sub", false /* oomAdj */);
                break;
            }
            cur.finishIfPossible("request-affinity", true /* oomAdj */);
    }
    }

    /** Finish all activities in the task with the same affinity as this one. */
    boolean finishIfSameAffinity(ActivityRecord r) {
        // End search once we get to the activity that doesn't have the same affinity.
        if (!Objects.equals(r.taskAffinity, taskAffinity)) return true;

        r.finishIfPossible("request-affinity", true /* oomAdj */);
        return false;
    }
    }


    /**
    /**
     * Sets the result for activity that started this one, clears the references to activities
     * Sets the result for activity that started this one, clears the references to activities
     * started for result from this one, and clears new intents.
     * started for result from this one, and clears new intents.
     */
     */
    void finishActivityResults(int resultCode, Intent resultData) {
    private void finishActivityResults(int resultCode, Intent resultData) {
        // Send the result if needed
        // Send the result if needed
        if (resultTo != null) {
        if (resultTo != null) {
            if (DEBUG_RESULTS) {
            if (DEBUG_RESULTS) {
@@ -2384,14 +2395,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            final Task task = getTask();
            final Task task = getTask();
            EventLogTags.writeWmFinishActivity(mUserId, System.identityHashCode(this),
            EventLogTags.writeWmFinishActivity(mUserId, System.identityHashCode(this),
                    task.mTaskId, shortComponentName, reason);
                    task.mTaskId, shortComponentName, reason);
            final ArrayList<ActivityRecord> activities = task.mChildren;
            ActivityRecord next = task.getActivityAbove(this);
            final int index = activities.indexOf(this);
            if (next != null) {
            if (index < (task.getChildCount() - 1)) {
                if ((intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) != 0) {
                if ((intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) != 0) {
                    // If the caller asked that this activity (and all above it)
                    // If the caller asked that this activity (and all above it)
                    // be cleared when the task is reset, don't lose that information,
                    // be cleared when the task is reset, don't lose that information,
                    // but propagate it up to the next activity.
                    // but propagate it up to the next activity.
                    final ActivityRecord next = task.getChildAt(index + 1);
                    next.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    next.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                }
                }
            }
            }
@@ -2409,7 +2418,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                } else {
                } else {
                    // Only move the next stack to top in its display.
                    // Only move the next stack to top in its display.
                    final ActivityDisplay display = stack.getDisplay();
                    final ActivityDisplay display = stack.getDisplay();
                    final ActivityRecord next = display.topRunningActivity();
                    next = display.topRunningActivity();
                    if (next != null) {
                    if (next != null) {
                        display.positionChildAtTop(next.getActivityStack(),
                        display.positionChildAtTop(next.getActivityStack(),
                                false /* includingParents */, "finish-display-top");
                                false /* includingParents */, "finish-display-top");
@@ -2419,7 +2428,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


            finishActivityResults(resultCode, resultData);
            finishActivityResults(resultCode, resultData);


            final boolean endTask = index <= 0 && !task.isClearingToReuseTask();
            final boolean endTask = task.getActivityBelow(this) == null
                    && !task.isClearingToReuseTask();
            final int transit = endTask ? TRANSIT_TASK_CLOSE : TRANSIT_ACTIVITY_CLOSE;
            final int transit = endTask ? TRANSIT_TASK_CLOSE : TRANSIT_ACTIVITY_CLOSE;
            if (isState(RESUMED)) {
            if (isState(RESUMED)) {
                if (endTask) {
                if (endTask) {
@@ -2479,16 +2489,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                // sync with the activity visibility being set for this finishing activity above.
                // sync with the activity visibility being set for this finishing activity above.
                // In this case, we can set the visibility of all the task overlay activities when
                // In this case, we can set the visibility of all the task overlay activities when
                // we detect the last one is finishing to keep them in sync.
                // we detect the last one is finishing to keep them in sync.
                if (task.onlyHasTaskOverlayActivities(true /* excludeFinishing */)) {
                if (task.onlyHasTaskOverlayActivities(false /* includeFinishing */)) {
                    for (int i = task.getChildCount() - 1; i >= 0 ; --i) {
                    final PooledConsumer c = PooledLambda.obtainConsumer(
                        final ActivityRecord taskOverlay = task.getChildAt(i);
                            ActivityRecord::prepareActivityHideTransitionAnimationIfOvarlay,
                        if (!taskOverlay.mTaskOverlay) {
                            PooledLambda.__(ActivityRecord.class), transit);
                            continue;
                    task.forAllActivities(c);
                        }
                    c.recycle();
                        taskOverlay.prepareActivityHideTransitionAnimation(transit);
                    }
                }
                }

                return removedActivity ? FINISH_RESULT_REMOVED : FINISH_RESULT_REQUESTED;
                return removedActivity ? FINISH_RESULT_REMOVED : FINISH_RESULT_REQUESTED;
            } else {
            } else {
                if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Finish waiting for pause of: " + this);
                if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Finish waiting for pause of: " + this);
@@ -2500,6 +2507,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }
    }
    }


    private void prepareActivityHideTransitionAnimationIfOvarlay(int transit) {
        if (mTaskOverlay) {
            prepareActivityHideTransitionAnimation(transit);
        }
    }

    private void prepareActivityHideTransitionAnimation(int transit) {
    private void prepareActivityHideTransitionAnimation(int transit) {
        final DisplayContent dc = getDisplay().mDisplayContent;
        final DisplayContent dc = getDisplay().mDisplayContent;
        dc.prepareAppTransition(transit, false);
        dc.prepareAppTransition(transit, false);
@@ -3271,15 +3284,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * immediately finishes after, so we have to transfer T to M.
     * immediately finishes after, so we have to transfer T to M.
     */
     */
    void transferStartingWindowFromHiddenAboveTokenIfNeeded() {
    void transferStartingWindowFromHiddenAboveTokenIfNeeded() {
        for (int i = task.mChildren.size() - 1; i >= 0; i--) {
        final PooledFunction p = PooledLambda.obtainFunction(ActivityRecord::transferStartingWindow,
            final ActivityRecord fromActivity = task.mChildren.get(i);
                this, PooledLambda.__(ActivityRecord.class));
            if (fromActivity == this) {
        task.forAllActivities(p);
                return;
        p.recycle();
            }
            if (!fromActivity.mVisibleRequested && transferStartingWindow(fromActivity.token)) {
                return;
            }
    }
    }

    private boolean transferStartingWindow(ActivityRecord fromActivity) {
        if (fromActivity == this) return true;

        return !fromActivity.mVisibleRequested && transferStartingWindow(fromActivity.token);
    }
    }


    void checkKeyguardFlagsChanged() {
    void checkKeyguardFlagsChanged() {
@@ -3351,7 +3365,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (!inPinnedWindowingMode() && (mShowWhenLocked || containsShowWhenLockedWindow())) {
        if (!inPinnedWindowingMode() && (mShowWhenLocked || containsShowWhenLockedWindow())) {
            return true;
            return true;
        } else if (mInheritShownWhenLocked) {
        } else if (mInheritShownWhenLocked) {
            final ActivityRecord r = getActivityBelow();
            final ActivityRecord r = task.getActivityBelow(this);
            return r != null && !r.inPinnedWindowingMode() && (r.mShowWhenLocked
            return r != null && !r.inPinnedWindowingMode() && (r.mShowWhenLocked
                    || r.containsShowWhenLockedWindow());
                    || r.containsShowWhenLockedWindow());
        } else {
        } else {
@@ -3376,19 +3390,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                true /* topToBottom */);
                true /* topToBottom */);
    }
    }


    /**
     * @return an {@link ActivityRecord} of the activity below this activity, or {@code null} if no
     * such activity exists.
     */
    @Nullable
    private ActivityRecord getActivityBelow() {
        final int pos = task.mChildren.indexOf(this);
        if (pos == -1) {
            throw new IllegalStateException("Activity not found in its task");
        }
        return pos == 0 ? null : task.getChildAt(pos - 1);
    }

    WindowState getImeTargetBelowWindow(WindowState w) {
    WindowState getImeTargetBelowWindow(WindowState w) {
        final int index = mChildren.indexOf(w);
        final int index = mChildren.indexOf(w);
        if (index > 0) {
        if (index > 0) {
@@ -3432,7 +3433,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }
    }


    @Override
    @Override
    boolean forAllActivities(Function<ActivityRecord, Boolean> callback) {
    boolean forAllActivities(
            Function<ActivityRecord, Boolean> callback, boolean traverseTopToBottom) {
        return callback.apply(this);
        return callback.apply(this);
    }
    }


@@ -3609,7 +3611,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                clearOptionsLocked(false /* withAbort */);
                clearOptionsLocked(false /* withAbort */);
            } else {
            } else {
                // This will clear the options for all the ActivityRecords for this Task.
                // This will clear the options for all the ActivityRecords for this Task.
                task.clearAllPendingOptions();
                task.forAllActivities((r) -> {
                    r.clearOptionsLocked(false /* withAbort */);
                });
            }
            }
        }
        }
    }
    }
@@ -4602,16 +4606,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }


        // Check if position in task allows to become paused
        // Check if position in task allows to become paused
        final int positionInTask = task.mChildren.indexOf(this);
        if (!task.hasChild(this)) {
        if (positionInTask == -1) {
            throw new IllegalStateException("Activity not found in its task");
            throw new IllegalStateException("Activity not found in its task");
        }
        }
        if (positionInTask == task.getChildCount() - 1) {
        final ActivityRecord activityAbove = task.getActivityAbove(this);
        if (activityAbove == null) {
            // It's the topmost activity in the task - should become resumed now
            // It's the topmost activity in the task - should become resumed now
            return true;
            return true;
        }
        }
        // Check if activity above is finishing now and this one becomes the topmost in task.
        // Check if activity above is finishing now and this one becomes the topmost in task.
        final ActivityRecord activityAbove = task.getChildAt(positionInTask + 1);
        if (activityAbove.finishing) {
        if (activityAbove.finishing) {
            return true;
            return true;
        }
        }
@@ -4667,7 +4670,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        stopped = false;
        stopped = false;


        if (isActivityTypeHome()) {
        if (isActivityTypeHome()) {
            mStackSupervisor.updateHomeProcess(task.getChildAt(0).app);
            mStackSupervisor.updateHomeProcess(task.getBottomMostActivity().app);
        }
        }


        if (nowVisible) {
        if (nowVisible) {
@@ -5294,6 +5297,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                && mAtmService.mAmInternal.isUserRunning(mUserId, 0 /* flags */));
                && mAtmService.mAmInternal.isUserRunning(mUserId, 0 /* flags */));
    }
    }


    boolean canBeTopRunning() {
        return !finishing && okToShowLocked();
    }

    /**
    /**
     * This method will return true if the activity is either visible, is becoming visible, is
     * This method will return true if the activity is either visible, is becoming visible, is
     * currently pausing, or is resumed.
     * currently pausing, or is resumed.
@@ -5325,13 +5332,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


    static int getTaskForActivityLocked(IBinder token, boolean onlyRoot) {
    static int getTaskForActivityLocked(IBinder token, boolean onlyRoot) {
        final ActivityRecord r = ActivityRecord.forTokenLocked(token);
        final ActivityRecord r = ActivityRecord.forTokenLocked(token);
        if (r == null) {
        if (r == null || r.getParent() == null) {
            return INVALID_TASK_ID;
            return INVALID_TASK_ID;
        }
        }
        final Task task = r.task;
        final Task task = r.task;
        final int activityNdx = task.mChildren.indexOf(r);
        if (onlyRoot && r.compareTo(task.getRootActivity(
        if (activityNdx < 0
                false /*ignoreRelinquishIdentity*/, true /*setToBottomIfNone*/)) > 0) {
                || (onlyRoot && activityNdx > task.findRootIndex(true /* effectiveRoot */))) {
            return INVALID_TASK_ID;
            return INVALID_TASK_ID;
        }
        }
        return task.mTaskId;
        return task.mTaskId;
@@ -7222,6 +7228,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return info.applicationInfo.uid;
        return info.applicationInfo.uid;
    }
    }


    boolean isUid(int uid) {
        return info.applicationInfo.uid == uid;
    }

    int getPid() {
    int getPid() {
        return app != null ? app.getPid() : 0;
        return app != null ? app.getPid() : 0;
    }
    }
@@ -7285,14 +7295,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (task == null) {
        if (task == null) {
            return false;
            return false;
        }
        }
        final ActivityRecord rootActivity = task.getRootActivity();
        final ActivityRecord rootActivity = task.getRootActivity(true);
        if (rootActivity != null) {
        return this == rootActivity;
        return this == rootActivity;
    }
    }
        // No non-finishing activity found. In this case the bottom-most activity is considered to
        // be the root.
        return task.getChildAt(0) == this;
    }


    @Override
    @Override
    public String toString() {
    public String toString() {
+444 −821

File changed.

Preview size limit exceeded, changes collapsed.

+36 −25
Original line number Original line Diff line number Diff line
@@ -138,6 +138,7 @@ import com.android.internal.content.ReferrerIntent;
import com.android.internal.os.TransferPipe;
import com.android.internal.os.TransferPipe;
import com.android.internal.os.logging.MetricsLoggerWrapper;
import com.android.internal.os.logging.MetricsLoggerWrapper;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.am.ActivityManagerService;
import com.android.server.am.ActivityManagerService;
import com.android.server.am.UserState;
import com.android.server.am.UserState;
@@ -825,7 +826,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                        task.mTaskId, r.shortComponentName);
                        task.mTaskId, r.shortComponentName);
                if (r.isActivityTypeHome()) {
                if (r.isActivityTypeHome()) {
                    // Home process is the root process of the task.
                    // Home process is the root process of the task.
                    updateHomeProcess(task.getChildAt(0).app);
                    updateHomeProcess(task.getBottomMostActivity().app);
                }
                }
                mService.getPackageManagerInternalLocked().notifyPackageUse(
                mService.getPackageManagerInternalLocked().notifyPackageUse(
                        r.intent.getComponent().getPackageName(), NOTIFY_PACKAGE_USE_ACTIVITY);
                        r.intent.getComponent().getPackageName(), NOTIFY_PACKAGE_USE_ACTIVITY);
@@ -1688,7 +1689,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                }
                }
            }
            }
            if (!deferResume) {
            if (!deferResume) {
                stack.ensureVisibleActivitiesConfigurationLocked(r, preserveWindows);
                stack.ensureVisibleActivitiesConfiguration(r, preserveWindows);
            }
            }
        } finally {
        } finally {
            mAllowDockedStackResize = true;
            mAllowDockedStackResize = true;
@@ -2485,18 +2486,23 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
            return;
            return;
        }
        }


        for (int i = task.getChildCount() - 1; i >= 0; i--) {
        final PooledConsumer c = PooledLambda.obtainConsumer(
            final ActivityRecord r = task.getChildAt(i);
                ActivityStackSupervisor::addToMultiWindowModeChangedList, this,
            if (r.attachedToProcess()) {
                PooledLambda.__(ActivityRecord.class));
                mMultiWindowModeChangedActivities.add(r);
        task.forAllActivities(c);
            }
        c.recycle();
        }


        if (!mHandler.hasMessages(REPORT_MULTI_WINDOW_MODE_CHANGED_MSG)) {
        if (!mHandler.hasMessages(REPORT_MULTI_WINDOW_MODE_CHANGED_MSG)) {
            mHandler.sendEmptyMessage(REPORT_MULTI_WINDOW_MODE_CHANGED_MSG);
            mHandler.sendEmptyMessage(REPORT_MULTI_WINDOW_MODE_CHANGED_MSG);
        }
        }
    }
    }


    private void addToMultiWindowModeChangedList(ActivityRecord r) {
        if (r.attachedToProcess()) {
            mMultiWindowModeChangedActivities.add(r);
        }
    }

    void scheduleUpdatePictureInPictureModeIfNeeded(Task task, ActivityStack prevStack) {
    void scheduleUpdatePictureInPictureModeIfNeeded(Task task, ActivityStack prevStack) {
        final ActivityStack stack = task.getStack();
        final ActivityStack stack = task.getStack();
        if (prevStack == null || prevStack == stack
        if (prevStack == null || prevStack == stack
@@ -2507,17 +2513,13 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        scheduleUpdatePictureInPictureModeIfNeeded(task, stack.getRequestedOverrideBounds());
        scheduleUpdatePictureInPictureModeIfNeeded(task, stack.getRequestedOverrideBounds());
    }
    }


    void scheduleUpdatePictureInPictureModeIfNeeded(Task task, Rect targetStackBounds) {
    private void scheduleUpdatePictureInPictureModeIfNeeded(Task task, Rect targetStackBounds) {
        for (int i = task.getChildCount() - 1; i >= 0; i--) {
        final PooledConsumer c = PooledLambda.obtainConsumer(
            final ActivityRecord r = task.getChildAt(i);
                ActivityStackSupervisor::addToPipModeChangedList, this,
            if (r.attachedToProcess()) {
                PooledLambda.__(ActivityRecord.class));
                mPipModeChangedActivities.add(r);
        task.forAllActivities(c);
                // If we are scheduling pip change, then remove this activity from multi-window
        c.recycle();
                // change list as the processing of pip change will make sure multi-window changed

                // message is processed in the right order relative to pip changed.
                mMultiWindowModeChangedActivities.remove(r);
            }
        }
        mPipModeChangedTargetStackBounds = targetStackBounds;
        mPipModeChangedTargetStackBounds = targetStackBounds;


        if (!mHandler.hasMessages(REPORT_PIP_MODE_CHANGED_MSG)) {
        if (!mHandler.hasMessages(REPORT_PIP_MODE_CHANGED_MSG)) {
@@ -2525,14 +2527,23 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        }
        }
    }
    }


    private void addToPipModeChangedList(ActivityRecord r) {
        if (!r.attachedToProcess()) return;

        mPipModeChangedActivities.add(r);
        // If we are scheduling pip change, then remove this activity from multi-window
        // change list as the processing of pip change will make sure multi-window changed
        // message is processed in the right order relative to pip changed.
        mMultiWindowModeChangedActivities.remove(r);
    }

    void updatePictureInPictureMode(Task task, Rect targetStackBounds, boolean forceUpdate) {
    void updatePictureInPictureMode(Task task, Rect targetStackBounds, boolean forceUpdate) {
        mHandler.removeMessages(REPORT_PIP_MODE_CHANGED_MSG);
        mHandler.removeMessages(REPORT_PIP_MODE_CHANGED_MSG);
        for (int i = task.getChildCount() - 1; i >= 0; i--) {
        final PooledConsumer c = PooledLambda.obtainConsumer(
            final ActivityRecord r = task.getChildAt(i);
                ActivityRecord::updatePictureInPictureMode,
            if (r.attachedToProcess()) {
                PooledLambda.__(ActivityRecord.class), targetStackBounds, forceUpdate);
                r.updatePictureInPictureMode(targetStackBounds, forceUpdate);
        task.forAllActivities(c);
            }
        c.recycle();
        }
    }
    }


    void wakeUp(String reason) {
    void wakeUp(String reason) {
Loading