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

Commit e3a5d23a authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Adding TaskFragment to provide the basic policies of a Task" into sc-v2-dev

parents e0b77bee 94ad4198
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ import static com.android.server.wm.Task.ActivityState.RESUMED;
import static com.android.server.wm.Task.ActivityState.STARTED;
import static com.android.server.wm.Task.ActivityState.STOPPED;
import static com.android.server.wm.Task.ActivityState.STOPPING;
import static com.android.server.wm.Task.TASK_VISIBILITY_VISIBLE;
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_VISIBLE;
import static com.android.server.wm.TaskPersister.DEBUG;
import static com.android.server.wm.TaskPersister.IMAGE_EXTENSION;
import static com.android.server.wm.WindowContainer.AnimationFlags.CHILDREN;
@@ -5228,7 +5228,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     */
    private boolean shouldBeResumed(ActivityRecord activeActivity) {
        return shouldMakeActive(activeActivity) && isFocusable()
                && getTask().getVisibility(activeActivity) == TASK_VISIBILITY_VISIBLE
                && getTask().getVisibility(activeActivity) == TASK_FRAGMENT_VISIBILITY_VISIBLE
                && canResumeByCompat();
    }

+18 −16
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.util.Slog;

/** Helper class to ensure activities are in the right visible state for a container. */
class EnsureActivitiesVisibleHelper {
    private final Task mTask;
    private final TaskFragment mTaskFragment;
    private ActivityRecord mTop;
    private ActivityRecord mStarting;
    private boolean mAboveTop;
@@ -34,12 +34,12 @@ class EnsureActivitiesVisibleHelper {
    private boolean mPreserveWindows;
    private boolean mNotifyClients;

    EnsureActivitiesVisibleHelper(Task container) {
        mTask = container;
    EnsureActivitiesVisibleHelper(TaskFragment container) {
        mTaskFragment = container;
    }

    /**
     * Update all attributes except {@link mTask} to use in subsequent calculations.
     * Update all attributes except {@link mTaskFragment} to use in subsequent calculations.
     *
     * @param starting The activity that is being started
     * @param configChanges Parts of the configuration that changed for this activity for evaluating
@@ -51,11 +51,11 @@ class EnsureActivitiesVisibleHelper {
    void reset(ActivityRecord starting, int configChanges, boolean preserveWindows,
            boolean notifyClients) {
        mStarting = starting;
        mTop = mTask.topRunningActivity();
        mTop = mTaskFragment.topRunningActivity();
        // If the top activity is not fullscreen, then we need to make sure any activities under it
        // are now visible.
        mAboveTop = mTop != null;
        mContainerShouldBeVisible = mTask.shouldBeVisible(mStarting);
        mContainerShouldBeVisible = mTaskFragment.shouldBeVisible(mStarting);
        mBehindFullscreenActivity = !mContainerShouldBeVisible;
        mConfigChanges = configChanges;
        mPreserveWindows = preserveWindows;
@@ -85,22 +85,23 @@ class EnsureActivitiesVisibleHelper {
            Slog.v(TAG_VISIBILITY, "ensureActivitiesVisible behind " + mTop
                    + " configChanges=0x" + Integer.toHexString(configChanges));
        }
        if (mTop != null) {
            mTask.checkTranslucentActivityWaiting(mTop);
        if (mTop != null && mTaskFragment.asTask() != null) {
            // TODO(14709632): Check if this needed to be implemented in TaskFragment.
            mTaskFragment.asTask().checkTranslucentActivityWaiting(mTop);
        }

        // We should not resume activities that being launched behind because these
        // activities are actually behind other fullscreen activities, but still required
        // to be visible (such as performing Recents animation).
        final boolean resumeTopActivity = mTop != null && !mTop.mLaunchTaskBehind
                && mTask.isTopActivityFocusable()
                && (starting == null || !starting.isDescendantOf(mTask));
                && mTaskFragment.isTopActivityFocusable()
                && (starting == null || !starting.isDescendantOf(mTaskFragment));

        mTask.forAllActivities(a -> {
        mTaskFragment.forAllActivities(a -> {
            setActivityVisibilityState(a, starting, resumeTopActivity);
        });
        if (mTask.mAtmService.getTransitionController().getTransitionPlayer() != null) {
            mTask.getDisplayContent().mWallpaperController.adjustWallpaperWindows();
        if (mTaskFragment.mAtmService.getTransitionController().getTransitionPlayer() != null) {
            mTaskFragment.getDisplayContent().mWallpaperController.adjustWallpaperWindows();
        }
    }

@@ -179,9 +180,9 @@ class EnsureActivitiesVisibleHelper {
            r.makeInvisible();
        }

        if (!mBehindFullscreenActivity && mTask.isActivityTypeHome() && r.isRootOfTask()) {
        if (!mBehindFullscreenActivity && mTaskFragment.isActivityTypeHome() && r.isRootOfTask()) {
            if (DEBUG_VISIBILITY) {
                Slog.v(TAG_VISIBILITY, "Home task: at " + mTask
                Slog.v(TAG_VISIBILITY, "Home task: at " + mTaskFragment
                        + " containerShouldBeVisible=" + mContainerShouldBeVisible
                        + " behindFullscreenActivity=" + mBehindFullscreenActivity);
            }
@@ -219,7 +220,8 @@ class EnsureActivitiesVisibleHelper {
            r.setVisibility(true);
        }
        if (r != starting) {
            mTask.mTaskSupervisor.startSpecificActivity(r, andResume, true /* checkConfig */);
            mTaskFragment.mTaskSupervisor.startSpecificActivity(r, andResume,
                    true /* checkConfig */);
        }
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ import static com.android.server.wm.Task.ActivityState.STOPPED;
import static com.android.server.wm.Task.ActivityState.STOPPING;
import static com.android.server.wm.Task.REPARENT_LEAVE_ROOT_TASK_IN_PLACE;
import static com.android.server.wm.Task.REPARENT_MOVE_ROOT_TASK_TO_FRONT;
import static com.android.server.wm.Task.TASK_VISIBILITY_INVISIBLE;
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_INVISIBLE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_TRACE;
@@ -1911,7 +1911,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                    return;
                }

                if (rootTask.getVisibility(null /*starting*/) == TASK_VISIBILITY_INVISIBLE) {
                if (rootTask.getVisibility(null /* starting */)
                        == TASK_FRAGMENT_VISIBILITY_INVISIBLE) {
                    return;
                }

+25 −275

File changed.

Preview size limit exceeded, changes collapsed.

+9 −7
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STATES;
import static com.android.server.wm.ActivityTaskManagerService.TAG_ROOT_TASK;
import static com.android.server.wm.DisplayContent.alwaysCreateRootTask;
import static com.android.server.wm.Task.ActivityState.RESUMED;
import static com.android.server.wm.Task.TASK_VISIBILITY_VISIBLE;
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_VISIBLE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ROOT_TASK;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

@@ -1229,7 +1229,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
                                + adjacentFlagRootTask);
            }

            if (adjacentFlagRootTask.mAdjacentTask == null) {
            if (adjacentFlagRootTask.getAdjacentTaskFragment() == null) {
                throw new UnsupportedOperationException(
                        "Can't set non-adjacent root as launch adjacent flag root tr="
                                + adjacentFlagRootTask);
@@ -1267,8 +1267,8 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
            // If the adjacent launch is coming from the same root, launch to adjacent root instead.
            if (sourceTask != null
                    && sourceTask.getRootTask().mTaskId == mLaunchAdjacentFlagRootTask.mTaskId
                    && mLaunchAdjacentFlagRootTask.mAdjacentTask != null) {
                return mLaunchAdjacentFlagRootTask.mAdjacentTask;
                    && mLaunchAdjacentFlagRootTask.getAdjacentTaskFragment() != null) {
                return mLaunchAdjacentFlagRootTask.getAdjacentTaskFragment().asTask();
            } else {
                return mLaunchAdjacentFlagRootTask;
            }
@@ -1278,8 +1278,10 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
            if (mLaunchRootTasks.get(i).contains(windowingMode, activityType)) {
                final Task launchRootTask = mLaunchRootTasks.get(i).task;
                // Return the focusable root task for improving the UX with staged split screen.
                final Task adjacentRootTask = launchRootTask != null
                        ? launchRootTask.mAdjacentTask : null;
                final TaskFragment adjacentTaskFragment = launchRootTask != null
                        ? launchRootTask.getAdjacentTaskFragment() : null;
                final Task adjacentRootTask =
                        adjacentTaskFragment != null ? adjacentTaskFragment.asTask() : null;
                if (adjacentRootTask != null && adjacentRootTask.isFocusedRootTaskOnDisplay()) {
                    return adjacentRootTask;
                } else {
@@ -1452,7 +1454,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
        forAllLeafTasks((task) -> {
            final ActivityRecord resumedActivity = task.getResumedActivity();
            if (resumedActivity != null
                    && (task.getVisibility(resuming) != TASK_VISIBILITY_VISIBLE
                    && (task.getVisibility(resuming) != TASK_FRAGMENT_VISIBILITY_VISIBLE
                    || !task.isTopActivityFocusable())) {
                ProtoLog.d(WM_DEBUG_STATES, "pauseBackTasks: task=%s "
                        + "mResumedActivity=%s", task, resumedActivity);
Loading