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

Commit 214e635e authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Reduce duplicated layer assignment and placement"

parents 29329617 affc70fa
Loading
Loading
Loading
Loading
+7 −11
Original line number Original line Diff line number Diff line
@@ -1451,6 +1451,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
                mUserLeaving = true;
                mUserLeaving = true;
            }
            }


            mService.deferWindowLayout();
            final Transition newTransition = task.mTransitionController.isShellTransitionsEnabled()
            final Transition newTransition = task.mTransitionController.isShellTransitionsEnabled()
                    ? task.mTransitionController.isCollecting() ? null
                    ? task.mTransitionController.isCollecting() ? null
                    : task.mTransitionController.createTransition(TRANSIT_TO_FRONT) : null;
                    : task.mTransitionController.createTransition(TRANSIT_TO_FRONT) : null;
@@ -1458,9 +1459,6 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
            reason = reason + " findTaskToMoveToFront";
            reason = reason + " findTaskToMoveToFront";
            boolean reparented = false;
            boolean reparented = false;
            if (task.isResizeable() && canUseActivityOptionsLaunchBounds(options)) {
            if (task.isResizeable() && canUseActivityOptionsLaunchBounds(options)) {
                final Rect bounds = options.getLaunchBounds();
                task.setBounds(bounds);

                Task targetRootTask =
                Task targetRootTask =
                        mRootWindowContainer.getOrCreateRootTask(null, options, task, ON_TOP);
                        mRootWindowContainer.getOrCreateRootTask(null, options, task, ON_TOP);


@@ -1473,14 +1471,11 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
                    // task.reparent() should already placed the task on top,
                    // task.reparent() should already placed the task on top,
                    // still need moveTaskToFrontLocked() below for any transition settings.
                    // still need moveTaskToFrontLocked() below for any transition settings.
                }
                }
                if (targetRootTask.shouldResizeRootTaskWithLaunchBounds()) {
                // The resizeTask must be done after the task is moved to the correct root task,
                    targetRootTask.resize(bounds, !PRESERVE_WINDOWS, !DEFER_RESUME);
                } else {
                    // WM resizeTask must be done after the task is moved to the correct stack,
                // because Task's setBounds() also updates dim layer's bounds, but that has
                // because Task's setBounds() also updates dim layer's bounds, but that has
                // dependency on the root task.
                // dependency on the root task.
                    task.resize(false /* relayout */, false /* forced */);
                final Rect bounds = options.getLaunchBounds();
                }
                task.setBounds(bounds);
            }
            }


            if (!reparented) {
            if (!reparented) {
@@ -1510,6 +1505,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
            }
            }
        } finally {
        } finally {
            mUserLeaving = false;
            mUserLeaving = false;
            mService.continueWindowLayout();
        }
        }
    }
    }


+0 −1
Original line number Original line Diff line number Diff line
@@ -500,7 +500,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    // Accessed directly by all users.
    // Accessed directly by all users.
    private boolean mLayoutNeeded;
    private boolean mLayoutNeeded;
    int pendingLayoutChanges;
    int pendingLayoutChanges;
    boolean mLayoutAndAssignWindowLayersScheduled;


    /**
    /**
     * Used to gate application window layout until we have sent the complete configuration.
     * Used to gate application window layout until we have sent the complete configuration.
+0 −6
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ import static com.android.server.wm.InsetsSourceProviderProto.SEAMLESS_ROTATING;
import static com.android.server.wm.InsetsSourceProviderProto.SERVER_VISIBLE;
import static com.android.server.wm.InsetsSourceProviderProto.SERVER_VISIBLE;
import static com.android.server.wm.InsetsSourceProviderProto.SOURCE;
import static com.android.server.wm.InsetsSourceProviderProto.SOURCE;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_INSETS_CONTROL;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_INSETS_CONTROL;
import static com.android.server.wm.WindowManagerService.H.LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
@@ -508,11 +507,6 @@ abstract class InsetsSourceProvider {
            return;
            return;
        }
        }
        mClientVisible = clientVisible;
        mClientVisible = clientVisible;
        if (!mDisplayContent.mLayoutAndAssignWindowLayersScheduled) {
            mDisplayContent.mLayoutAndAssignWindowLayersScheduled = true;
            mDisplayContent.mWmService.mH.obtainMessage(
                    LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED, mDisplayContent).sendToTarget();
        }
        updateVisibility();
        updateVisibility();
    }
    }


+1 −48
Original line number Original line Diff line number Diff line
@@ -423,9 +423,6 @@ class Task extends TaskFragment {
    // This number will be assigned when we evaluate OOM scores for all visible tasks.
    // This number will be assigned when we evaluate OOM scores for all visible tasks.
    int mLayerRank = LAYER_RANK_INVISIBLE;
    int mLayerRank = LAYER_RANK_INVISIBLE;


    /** Helper object used for updating override configuration. */
    private Configuration mTmpConfig = new Configuration();

    /* Unique identifier for this task. */
    /* Unique identifier for this task. */
    final int mTaskId;
    final int mTaskId;
    /* User for which this task was created. */
    /* User for which this task was created. */
@@ -796,16 +793,11 @@ class Task extends TaskFragment {


            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "resizeTask_" + mTaskId);
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "resizeTask_" + mTaskId);


            boolean updatedConfig = false;
            mTmpConfig.setTo(getResolvedOverrideConfiguration());
            if (setBounds(bounds) != BOUNDS_CHANGE_NONE) {
                updatedConfig = !mTmpConfig.equals(getResolvedOverrideConfiguration());
            }
            // This variable holds information whether the configuration didn't change in a
            // This variable holds information whether the configuration didn't change in a
            // significant way and the activity was kept the way it was. If it's false, it means
            // significant way and the activity was kept the way it was. If it's false, it means
            // the activity had to be relaunched due to configuration change.
            // the activity had to be relaunched due to configuration change.
            boolean kept = true;
            boolean kept = true;
            if (updatedConfig) {
            if (setBounds(bounds, forced) != BOUNDS_CHANGE_NONE) {
                final ActivityRecord r = topRunningActivityLocked();
                final ActivityRecord r = topRunningActivityLocked();
                if (r != null) {
                if (r != null) {
                    kept = r.ensureActivityConfiguration(0 /* globalChanges */,
                    kept = r.ensureActivityConfiguration(0 /* globalChanges */,
@@ -822,8 +814,6 @@ class Task extends TaskFragment {
                    }
                    }
                }
                }
            }
            }
            resize(kept, forced);

            saveLaunchingStateIfNeeded();
            saveLaunchingStateIfNeeded();


            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
@@ -2693,12 +2683,6 @@ class Task extends TaskFragment {
        return canSpecifyOrientation() && getDisplayArea().canSpecifyOrientation(orientation);
        return canSpecifyOrientation() && getDisplayArea().canSpecifyOrientation(orientation);
    }
    }


    void resize(boolean relayout, boolean forced) {
        if (setBounds(getRequestedOverrideBounds(), forced) != BOUNDS_CHANGE_NONE && relayout) {
            getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
        }
    }

    @Override
    @Override
    void onDisplayChanged(DisplayContent dc) {
    void onDisplayChanged(DisplayContent dc) {
        final boolean isRootTask = isRootTask();
        final boolean isRootTask = isRootTask();
@@ -4750,14 +4734,6 @@ class Task extends TaskFragment {
        }
        }
    }
    }


    /**
     * Returns true if this root task should be resized to match the bounds specified by
     * {@link ActivityOptions#setLaunchBounds} when launching an activity into the root task.
     */
    boolean shouldResizeRootTaskWithLaunchBounds() {
        return inPinnedWindowingMode();
    }

    void checkTranslucentActivityWaiting(ActivityRecord top) {
    void checkTranslucentActivityWaiting(ActivityRecord top) {
        if (mTranslucentActivityWaiting != top) {
        if (mTranslucentActivityWaiting != top) {
            mUndrawnActivitiesBelowTopTranslucent.clear();
            mUndrawnActivitiesBelowTopTranslucent.clear();
@@ -5582,29 +5558,6 @@ class Task extends TaskFragment {
        return true;
        return true;
    }
    }


    // TODO: Can only be called from special methods in ActivityTaskSupervisor.
    // Need to consolidate those calls points into this resize method so anyone can call directly.
    void resize(Rect displayedBounds, boolean preserveWindows, boolean deferResume) {
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "task.resize_" + getRootTaskId());
        mAtmService.deferWindowLayout();
        try {
            // TODO: Why not just set this on the root task directly vs. on each tasks?
            // Update override configurations of all tasks in the root task.
            forAllTasks(task -> {
                if (task.isResizeable()) {
                    task.setBounds(displayedBounds);
                }
            }, true /* traverseTopToBottom */);

            if (!deferResume) {
                ensureVisibleActivitiesConfiguration(topRunningActivity(), preserveWindows);
            }
        } finally {
            mAtmService.continueWindowLayout();
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }
    }

    boolean willActivityBeVisible(IBinder token) {
    boolean willActivityBeVisible(IBinder token) {
        final ActivityRecord r = ActivityRecord.forTokenLocked(token);
        final ActivityRecord r = ActivityRecord.forTokenLocked(token);
        if (r == null) {
        if (r == null) {
+1 −3
Original line number Original line Diff line number Diff line
@@ -756,9 +756,7 @@ class WallpaperController {
    private void updateWallpaperTokens(boolean visible) {
    private void updateWallpaperTokens(boolean visible) {
        for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
        for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
            final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
            final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
            if (token.updateWallpaperWindows(visible)) {
            token.updateWallpaperWindows(visible);
                token.mDisplayContent.assignWindowLayers(false /* setLayoutNeeded */);
            }
        }
        }
    }
    }


Loading