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

Commit affc70fa authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce duplicated layer assignment and placement

- LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED is done by
  INSETS_CHANGED.
- Wallpaper visibility is unrelated to layer change.
- Remove some legacy resizing code which are no longer needed
  since hierarchy merged.
- Remove unused PreAssignChildLayersCallback.

Bug: 159103089
Test: CtsWindowManagerDeviceTestCases

Change-Id: Ia2b14131c2d2c5ffc82702fdc653bdd7ee703ad4
parent 099f8243
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -1450,6 +1450,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
                mUserLeaving = true;
            }

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

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

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

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

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

    /**
     * Used to gate application window layout until we have sent the complete configuration.
+0 −6
Original line number 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.SOURCE;
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.Nullable;
@@ -508,11 +507,6 @@ abstract class InsetsSourceProvider {
            return;
        }
        mClientVisible = clientVisible;
        if (!mDisplayContent.mLayoutAndAssignWindowLayersScheduled) {
            mDisplayContent.mLayoutAndAssignWindowLayersScheduled = true;
            mDisplayContent.mWmService.mH.obtainMessage(
                    LAYOUT_AND_ASSIGN_WINDOW_LAYERS_IF_NEEDED, mDisplayContent).sendToTarget();
        }
        updateVisibility();
    }

+1 −48
Original line number 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.
    int mLayerRank = LAYER_RANK_INVISIBLE;

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

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

            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
            // 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.
            boolean kept = true;
            if (updatedConfig) {
            if (setBounds(bounds, forced) != BOUNDS_CHANGE_NONE) {
                final ActivityRecord r = topRunningActivityLocked();
                if (r != null) {
                    kept = r.ensureActivityConfiguration(0 /* globalChanges */,
@@ -822,8 +814,6 @@ class Task extends TaskFragment {
                    }
                }
            }
            resize(kept, forced);

            saveLaunchingStateIfNeeded();

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

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

    @Override
    void onDisplayChanged(DisplayContent dc) {
        final boolean isRootTask = isRootTask();
@@ -4771,14 +4755,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) {
        if (mTranslucentActivityWaiting != top) {
            mUndrawnActivitiesBelowTopTranslucent.clear();
@@ -5603,29 +5579,6 @@ class Task extends TaskFragment {
        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) {
        final ActivityRecord r = ActivityRecord.forTokenLocked(token);
        if (r == null) {
+1 −3
Original line number Diff line number Diff line
@@ -756,9 +756,7 @@ class WallpaperController {
    private void updateWallpaperTokens(boolean visible) {
        for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
            final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
            if (token.updateWallpaperWindows(visible)) {
                token.mDisplayContent.assignWindowLayers(false /* setLayoutNeeded */);
            }
            token.updateWallpaperWindows(visible);
        }
    }

Loading