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

Commit bebd8cd9 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Merge Stack level of window hierarchy (63/n)

Bug: 80414790
Test: Existing tests pass
Change-Id: Ia6765f7ebd89b38e0d2b88ed1cdfec5b386a0774
parent d7c8835b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -88,13 +88,15 @@ message ActivityDisplayProto {
message ActivityStackProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 1;
    // To be removed soon.
    optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 1 [deprecated=true];
    optional int32 id = 2;
    repeated TaskRecordProto tasks = 3;
    optional .com.android.server.wm.IdentifierProto resumed_activity = 4;
    optional int32 display_id = 5;
    optional bool fullscreen = 6;
    optional .android.graphics.RectProto bounds = 7;
    optional .com.android.server.wm.StackProto stack = 8;
}

message TaskRecordProto {
+36 −11
Original line number Diff line number Diff line
@@ -123,6 +123,9 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {

    private boolean mSleeping;

    /** We started the process of removing the display from the system. */
    private boolean mRemoving;

    /**
     * The display is removed from the system and we are just waiting for all activities on it to be
     * finished before removing this object.
@@ -200,23 +203,37 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
        }
    }

    // TODO(display-unify): Merge with addChild below.
    void addChild(ActivityStack stack, int position) {
        addChild(stack, position, false /*fromDc*/);
    }

    void addChild(ActivityStack stack, int position, boolean fromDc) {
        boolean toTop = position == POSITION_TOP;
        if (position == POSITION_BOTTOM) {
            position = 0;
        } else if (position == POSITION_TOP) {
        } else if (toTop) {
            position = mStacks.size();
        }
        if (DEBUG_STACK) Slog.v(TAG_STACK, "addChild: attaching " + stack
                + " to displayId=" + mDisplayId + " position=" + position);
        addStackReferenceIfNeeded(stack);
        if (!fromDc) {
            mDisplayContent.setStackOnDisplay(stack, position);
        }
        positionChildAt(stack, position);
        mService.updateSleepIfNeededLocked();
    }

    void removeChild(ActivityStack stack) {
    // TODO(display-unify): Merge with removeChild below.
    void onChildRemoved(ActivityStack stack) {
        if (!mStacks.remove(stack)) {
            // Stack no longer here!
            return;
        }

        if (DEBUG_STACK) Slog.v(TAG_STACK, "removeChild: detaching " + stack
                + " from displayId=" + mDisplayId);
        mStacks.remove(stack);
        if (mPreferredTopFocusableStack == stack) {
            mPreferredTopFocusableStack = null;
        }
@@ -226,6 +243,10 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
        onStackOrderChanged(stack);
    }

    void removeChild(ActivityStack stack) {
        mDisplayContent.removeStackFromDisplay(stack);
    }

    void positionChildAtTop(ActivityStack stack, boolean includingParents) {
        positionChildAtTop(stack, includingParents, null /* updateLastFocusedStackReason */);
    }
@@ -286,12 +307,8 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {

        // Since positionChildAt() is called during the creation process of pinned stacks,
        // ActivityStack#getStack() can be null.
        if (stack.getTaskStack() != null && mDisplayContent != null) {
            mDisplayContent.positionStackAt(insertPosition,
                    stack.getTaskStack(), includingParents);
        }
        if (!wasContained) {
            stack.setParent(this);
        if (mDisplayContent != null) {
            mDisplayContent.positionStackAt(insertPosition, stack, includingParents);
        }
        onStackOrderChanged(stack);
    }
@@ -1186,7 +1203,15 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
        return mRemoved;
    }

    /**
     * @see #mRemoving
     */
    boolean isRemoving() {
        return mRemoving;
    }

    void remove() {
        mRemoving = true;
        final boolean destroyContentOnRemoval = shouldDestroyContentOnRemove();
        ActivityStack lastReparentedStack = null;
        mPreferredTopFocusableStack = null;
@@ -1213,7 +1238,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
                    final int windowingMode = toDisplay.hasSplitScreenPrimaryStack()
                            ? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
                            : WINDOWING_MODE_UNDEFINED;
                    stack.reparent(toDisplay, true /* onTop */, true /* displayRemoved */);
                    stack.reparent(toDisplay.mDisplayContent, true /* onTop */);
                    stack.setWindowingMode(windowingMode);
                    lastReparentedStack = stack;
                }
@@ -1251,7 +1276,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
            // Release this display if an empty home stack is the only thing left.
            // Since it is the last stack, this display will be released along with the stack
            // removal.
            stack.remove();
            stack.removeIfPossible();
        } else if (mStacks.isEmpty()) {
            mDisplayContent.removeIfPossible();
            mDisplayContent = null;
+9 −7
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.activityTypeToString;
import static android.content.Intent.ACTION_MAIN;
@@ -1992,9 +1994,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    /**
     * @return Stack value from current task, null if there is no task.
     */
    // TODO(stack-unify): Remove once ActivityStack and TaskStack are unified.
    <T extends ActivityStack> T getActivityStack() {
        return task != null ? (T) task.getStack() : null;
    ActivityStack getActivityStack() {
        return task != null ? task.getStack() : null;
    }

    int getStackId() {
@@ -2080,10 +2081,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return ActivityInfo.isResizeableMode(info.resizeMode) || info.supportsPictureInPicture();
    }

    /**
     * @return whether this activity is non-resizeable or forced to be resizeable
     */
    boolean isNonResizableOrForcedResizable() {
    /** @return whether this activity is non-resizeable or forced to be resizeable */
    boolean isNonResizableOrForcedResizable(int windowingMode) {
        if (windowingMode == WINDOWING_MODE_PINNED && info.supportsPictureInPicture()) {
            return false;
        }
        return info.resizeMode != RESIZE_MODE_RESIZEABLE
                && info.resizeMode != RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
    }
+119 −375

File changed.

Preview size limit exceeded, changes collapsed.

+4 −5
Original line number Diff line number Diff line
@@ -1713,8 +1713,8 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        // another AM call that is holding the AMS lock. In such a case, the pinnedBounds may be
        // incorrect if AMS.resizeStackWithBoundsFromWindowManager() is already called while waiting
        // for the AMS lock to be freed. So check and make sure these bounds are still good.
        final TaskStack stackController = stack.getTaskStack();
        if (stackController.pinnedStackResizeDisallowed()) {
        // TODO(stack-merge): Is this still relevant?
        if (stack.pinnedStackResizeDisallowed()) {
            return;
        }

@@ -1893,8 +1893,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {

        if (currentStack != null) {
            // Task has already been restored once. Just re-parent it to the new stack.
            task.reparent(stack.mTaskStack,
                    POSITION_TOP, true /*moveParents*/, "restoreRecentTaskLocked");
            task.reparent(stack, POSITION_TOP, true /*moveParents*/, "restoreRecentTaskLocked");
            return true;
        }

@@ -2470,7 +2469,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
    private void handleForcedResizableTaskIfNeeded(TaskRecord task, int reason) {
        final ActivityRecord topActivity = task.getTopActivity();
        if (topActivity == null || topActivity.noDisplay
                || !topActivity.isNonResizableOrForcedResizable()) {
                || !topActivity.isNonResizableOrForcedResizable(task.getWindowingMode())) {
            return;
        }
        mService.getTaskChangeNotificationController().notifyActivityForcedResizable(
Loading